-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Closure type mismatch on higher-ranked bounds #51004
Comments
I believe this is the same issue as #41078. |
@Mark-Simulacrum I'm not sure this is a proper duplicate-- when I've hit that other issue, I've always been able to get it to go away by explicitly writing out the signature of the closure types. I can't do that here-- you'll notice that the type of the closure is specified manually, yet it still fails. |
I'm going to reopen this, as I think it at least needs further investigation in order to determine if it is the same as #41076 (which I doubt). |
cc @eddyb @nikomatsakis, this is a pretty persistent and important issue for async/await work. It might be most expedient to address it by adding |
@nikomatsakis Looks like this works fine if the bound in @aturon Not entirely opposed to |
Triage: Rust 1.74 gives more details on why it rejects this code. Playground link. It assigns different lifetimes to the closure input and output, contrary to usual elision rules:
|
In the following code, identical impls for a concrete type, a
fn
type, and a closure exist yet the only the closure fails to meet the higher-ranked bound:The error is this:
Edit: the closure can be made to work through coercion to a
fn
pointer (which is unsurprising, since it's then the same asfoo
).take_fn_lt({ |x: &u8| -> &u8 { x } } as fn(&u8) -> &u8);
compiles.The text was updated successfully, but these errors were encountered: