1 In a `fn` type, a lifetime appears only in the return type
2 and not in the arguments types.
4 Erroneous code example:
8 // Here, `'a` appears only in the return type:
9 let x: for<'a> fn() -> &'a i32;
13 The problem here is that the lifetime isn't contrained by any of the arguments,
14 making it impossible to determine how long it's supposed to live.
16 To fix this issue, either use the lifetime in the arguments, or use the
17 `'static` lifetime. Example:
21 // Here, `'a` appears only in the return type:
22 let x: for<'a> fn(&'a i32) -> &'a i32;
23 let y: fn() -> &'static i32;
27 Note: The examples above used to be (erroneously) accepted by the
28 compiler, but this was since corrected. See [issue #33685] for more
31 [issue #33685]: https://github.com/rust-lang/rust/issues/33685