You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It fails to see that the closure should be generic on the lifetime of the input, resulting in this error:
error[E0271]:type mismatch resolving `for<'r> <[closure@<anon>:7:19:7:25]as std::ops::FnOnce<(&'ri32,)>>::Output == ()`
--> <anon>:8:5
|
8 | take_trait(my_func);
| ^^^^^^^^^^ expected bound lifetime parameter , found concrete lifetime
|
= note: concrete lifetime that was found is lifetime '_#0r
= note: required because of the requirements on the impl of `MyTrait` for `[closure@<anon>:7:19:7:25]`
= note: required by `take_trait`
error[E0281]:type mismatch: the type `[closure@<anon>:7:19:7:25]` implements the trait `std::ops::Fn<(_,)>`, but the trait `for<'r> std::ops::Fn<(&'ri32,)>` is required (expected concrete lifetime, found bound lifetime parameter)
--> <anon>:8:5
|
8 | take_trait(my_func);
| ^^^^^^^^^^
|
= note: required because of the requirements on the impl of `MyTrait` for `[closure@<anon>:7:19:7:25]`
= note: required by `take_trait`
error: aborting due to 2 previous errors
The same thing happens when taking lifetime-generic structs as input: the type needs to be manually annotated, or inference will fail. Is there any way to make this work, or to at least get a better error message? I'm interested in helping fix this if someone could point me in the right direction.
The text was updated successfully, but these errors were encountered:
I just ran into this so I poked around the issue tracker a bit. The inference issue looks like #32600 and #26937 (these three seem like duplicates). #24680 concerns the error message.
This compiles:
When we take out the
&_
type annotation, it breaks:It fails to see that the closure should be generic on the lifetime of the input, resulting in this error:
The same thing happens when taking lifetime-generic structs as input: the type needs to be manually annotated, or inference will fail. Is there any way to make this work, or to at least get a better error message? I'm interested in helping fix this if someone could point me in the right direction.
The text was updated successfully, but these errors were encountered: