-
-
Save lqd/c08e39c76393b93529352df250c4adc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0308]: mismatched types | |
--> src/main.rs:14:7 | |
| | |
14 | a.f(); | |
| ^ one type is more general than the other | |
| | |
= note: expected type `Trait` | |
found type `Trait` | |
error[E0308]: mismatched types | |
--> src/main.rs:32:13 | |
| | |
32 | let x = <fn (&())>::make_g(); | |
| ^^^^^^^^^^^^^^^^^^ one type is more general than the other | |
| | |
= note: expected type `X` | |
found type `X` | |
error: aborting due to 2 previous errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error: implementation of `Trait` is not general enough | |
--> src/main.rs:14:7 | |
| | |
14 | a.f(); | |
| ^ | |
| | |
= note: `Trait` would have to be implemented for the type `fn(&u8)` | |
= note: but `Trait` is actually implemented for the type `for<'r> fn(&'r u8)` | |
error: implementation of `X` is not general enough | |
--> src/main.rs:32:13 | |
| | |
32 | let x = <fn (&())>::make_g(); | |
| ^^^^^^^^^^^^^^^^^^ | |
| | |
= note: `X` would have to be implemented for the type `for<'r> fn(&'r ())` | |
= note: but `X` is actually implemented for the type `fn(&'0 ())`, for the specific lifetime `'0` | |
error: aborting due to 2 previous errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
trait Trait { | |
fn f(self); | |
} | |
impl<T> Trait for fn(&T) { | |
fn f(self) { | |
println!("f"); | |
} | |
} | |
fn main() { | |
let a: fn(_) = |_: &u8| {}; | |
a.f(); | |
} | |
// 2 | |
trait X { | |
type G; | |
fn make_g() -> Self::G; | |
} | |
impl<'a> X for fn(&'a ()) { | |
type G = &'a (); | |
fn make_g() -> Self::G { | |
&() | |
} | |
} | |
fn higher_ranked_region_has_lost_its_binder() { | |
let x = <fn (&())>::make_g(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment