Skip to content

Instantly share code, notes, and snippets.

@lqd

lqd/PR.txt Secret

Created January 25, 2019 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lqd/c08e39c76393b93529352df250c4adc5 to your computer and use it in GitHub Desktop.
Save lqd/c08e39c76393b93529352df250c4adc5 to your computer and use it in GitHub Desktop.
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
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
// 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