]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0687.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0687.md
CommitLineData
f035d41b
XL
1In-band lifetimes cannot be used in `fn`/`Fn` syntax.
2
3Erroneous code examples:
4
5```compile_fail,E0687
6#![feature(in_band_lifetimes)]
7
8fn foo(x: fn(&'a u32)) {} // error!
9
10fn bar(x: &Fn(&'a u32)) {} // error!
11
12fn baz(x: fn(&'a u32), y: &'a u32) {} // error!
13
14struct Foo<'a> { x: &'a u32 }
15
16impl Foo<'a> {
17 fn bar(&self, x: fn(&'a u32)) {} // error!
18}
19```
20
21Lifetimes used in `fn` or `Fn` syntax must be explicitly
22declared using `<...>` binders. For example:
23
24```
25fn foo<'a>(x: fn(&'a u32)) {} // ok!
26
27fn bar<'a>(x: &Fn(&'a u32)) {} // ok!
28
29fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok!
30
31struct Foo<'a> { x: &'a u32 }
32
33impl<'a> Foo<'a> {
34 fn bar(&self, x: fn(&'a u32)) {} // ok!
35}
36```