Skip to content

Instantly share code, notes, and snippets.

@jmgrosen
Created July 31, 2013 05:40
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 jmgrosen/6119593 to your computer and use it in GitHub Desktop.
Save jmgrosen/6119593 to your computer and use it in GitHub Desktop.
struct Thing;
fn do_stuff<'a>(thing: &'a Thing) -> &'a fn() {
let cloned_thing = thing.clone();
|| {
let cloned_cloned_thing = cloned_thing.clone();
}
}
fn main() {}
@jmgrosen
Copy link
Author

thing.rs:4:36: 7:5 error: cannot infer an appropriate lifetime due to conflicting requirements
thing.rs:4     let cloned_thing = thing.clone();
thing.rs:5     || {
thing.rs:6         let cloned_cloned_thing = cloned_thing.clone();
thing.rs:7     }
thing.rs:3:46: 8:1 note: first, the lifetime cannot outlive the block at 3:46...
thing.rs:3 fn do_stuff<'a>(thing: &'a Thing) -> &'a fn() {
thing.rs:4     let cloned_thing = thing.clone();
thing.rs:5     || {
thing.rs:6         let cloned_cloned_thing = cloned_thing.clone();
thing.rs:7     }
thing.rs:8 }
thing.rs:4:36: 7:5 note: ...due to the following expression
thing.rs:4     let cloned_thing = thing.clone();
thing.rs:5     || {
thing.rs:6         let cloned_cloned_thing = cloned_thing.clone();
thing.rs:7     }
thing.rs:3:46: 8:1 note: but, the lifetime must be valid for the lifetime &'a  as defined on the block at 3:46...
thing.rs:3 fn do_stuff<'a>(thing: &'a Thing) -> &'a fn() {
thing.rs:4     let cloned_thing = thing.clone();
thing.rs:5     || {
thing.rs:6         let cloned_cloned_thing = cloned_thing.clone();
thing.rs:7     }
thing.rs:8 }
thing.rs:4:36: 7:5 note: ...due to the following expression
thing.rs:4     let cloned_thing = thing.clone();
thing.rs:5     || {
thing.rs:6         let cloned_cloned_thing = cloned_thing.clone();
thing.rs:7     }
error: aborting due to previous error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment