]>
Commit | Line | Data |
---|---|---|
5e7ed085 FG |
1 | #### Note: this error code is no longer emitted by the compiler. |
2 | ||
f035d41b XL |
3 | In-band lifetimes cannot be used in `fn`/`Fn` syntax. |
4 | ||
5 | Erroneous code examples: | |
6 | ||
5e7ed085 | 7 | ```ignore (feature got removed) |
f035d41b XL |
8 | #![feature(in_band_lifetimes)] |
9 | ||
10 | fn foo(x: fn(&'a u32)) {} // error! | |
11 | ||
12 | fn bar(x: &Fn(&'a u32)) {} // error! | |
13 | ||
14 | fn baz(x: fn(&'a u32), y: &'a u32) {} // error! | |
15 | ||
16 | struct Foo<'a> { x: &'a u32 } | |
17 | ||
18 | impl Foo<'a> { | |
19 | fn bar(&self, x: fn(&'a u32)) {} // error! | |
20 | } | |
21 | ``` | |
22 | ||
23 | Lifetimes used in `fn` or `Fn` syntax must be explicitly | |
24 | declared using `<...>` binders. For example: | |
25 | ||
26 | ``` | |
27 | fn foo<'a>(x: fn(&'a u32)) {} // ok! | |
28 | ||
29 | fn bar<'a>(x: &Fn(&'a u32)) {} // ok! | |
30 | ||
31 | fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok! | |
32 | ||
33 | struct Foo<'a> { x: &'a u32 } | |
34 | ||
35 | impl<'a> Foo<'a> { | |
36 | fn bar(&self, x: fn(&'a u32)) {} // ok! | |
37 | } | |
38 | ``` |