]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0687.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0687.md
1 In-band lifetimes cannot be used in `fn`/`Fn` syntax.
2
3 Erroneous code examples:
4
5 ```compile_fail,E0687
6 #![feature(in_band_lifetimes)]
7
8 fn foo(x: fn(&'a u32)) {} // error!
9
10 fn bar(x: &Fn(&'a u32)) {} // error!
11
12 fn baz(x: fn(&'a u32), y: &'a u32) {} // error!
13
14 struct Foo<'a> { x: &'a u32 }
15
16 impl Foo<'a> {
17     fn bar(&self, x: fn(&'a u32)) {} // error!
18 }
19 ```
20
21 Lifetimes used in `fn` or `Fn` syntax must be explicitly
22 declared using `<...>` binders. For example:
23
24 ```
25 fn foo<'a>(x: fn(&'a u32)) {} // ok!
26
27 fn bar<'a>(x: &Fn(&'a u32)) {} // ok!
28
29 fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok!
30
31 struct Foo<'a> { x: &'a u32 }
32
33 impl<'a> Foo<'a> {
34     fn bar(&self, x: fn(&'a u32)) {} // ok!
35 }
36 ```