-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent type inferring #36285
Comments
This isn't really inconsistent. The reason the first one works and the other doesn't is because there's no inference happening in the first case. Coercions aren't part of type inference, they're applied when we encounter a type mismatch, there's not really any inconsistency here. I don't think this behaviour will change, so this should probably be closed. @rust-lang/lang sound good? |
@Aatch Indeed, in the first case the type information propagates down through If you remove the double boxing (which AFAICT is completely redundant), you can work around it: use std::any::Any;
use std::sync::{Arc, Mutex};
pub type Wild = Any + 'static + Send;
pub fn with_wild(_: Option<Arc<Wild>>) { }
struct Modest;
fn main() {
// Works
with_wild(Some(Arc::new(Mutex::new(Modest))));
let fluffy = Some(Arc::new(Mutex::new(Modest)));
with_wild(fluffy.map(|x| x as Arc<Wild>));
} You can also do the manual case on the original |
I've found the case where type inferring is inconsistent (I think so):
at playground
It fails with:
The text was updated successfully, but these errors were encountered: