Skip to content

Instantly share code, notes, and snippets.

@lqd
Created January 18, 2019 15:03
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/3b9d3142655093a1b0299e13af4098bc to your computer and use it in GitHub Desktop.
Save lqd/3b9d3142655093a1b0299e13af4098bc to your computer and use it in GitHub Desktop.
trait X {
type G;
fn make_g() -> Self::G;
}
impl<'a> X for fn(&'a ()) {
type G = &'a ();
fn make_g() -> Self::G {
&()
}
}
// Always an error, but the message is bad
fn higher_ranked_region_has_lost_its_binder() {
let x = <fn (&())>::make_g();
}
// error: implementation of `X` is not general enough
// --> src/main.rs:44:13
// |
// 44 | let x = <fn (&())>::make_g();
// | ^^^^^^^^^^^^^^^^^^
// |
// = note: `for<'r> fn(&'r ())` must implement `X`
// = note: but `fn(&'0 ())` only implements `X` for the lifetime `'0`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment