Open typoon opened 8 years ago
The issue is early vs. late-bound lifetimes.
Triage: no change
Current error output:
error[[E0308]](https://doc.rust-lang.org/stable/error_codes/E0308.html): mismatched types
--> src/main.rs:12:31
|
12 | let fails: fn(MyStruct) = MyStruct::func; // ERROR: mismatched types
| ^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected fn pointer `for<'a> fn(MyStruct<'a>)`
found fn item `fn(MyStruct<'_>) {MyStruct::<'_>::func}`
The following code does not infer the type of the method correctly:
As one can see in the error message (found
fn(MyStruct<'_>) {MyStruct<'a>::func}
), it seems that the compiler is getting confused when inferring the type of the expression.If the lifetime from MyStruct is removed, the code compiles fine.
PS: Thanks to
huon
for simplifying the example demonstrating the issue