Skip to content

Commit 46bfc48

Browse files
committed
Added proper explanation of ErrorCode-E0687
1 parent 20fc02f commit 46bfc48

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ E0668: include_str!("./error_codes/E0668.md"),
380380
E0669: include_str!("./error_codes/E0669.md"),
381381
E0670: include_str!("./error_codes/E0670.md"),
382382
E0671: include_str!("./error_codes/E0671.md"),
383+
E0687: include_str!("./error_codes/E0687.md"),
383384
E0689: include_str!("./error_codes/E0689.md"),
384385
E0690: include_str!("./error_codes/E0690.md"),
385386
E0691: include_str!("./error_codes/E0691.md"),
@@ -599,7 +600,6 @@ E0751: include_str!("./error_codes/E0751.md"),
599600
E0640, // infer outlives requirements
600601
// E0645, // trait aliases not finished
601602
E0667, // `impl Trait` in projections
602-
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
603603
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
604604
// E0694, // an unknown tool name found in scoped attributes
605605
E0696, // `continue` pointing to a labeled block
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
```

src/test/ui/in-band-lifetimes/E0687.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ LL | fn bar(&self, x: fn(&'a u32)) {}
2424

2525
error: aborting due to 4 previous errors
2626

27+
For more information about this error, try `rustc --explain E0687`.

src/test/ui/in-band-lifetimes/E0687_where.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ LL | fn baz(x: &impl Fn(&'a u32)) {}
1212

1313
error: aborting due to 2 previous errors
1414

15+
For more information about this error, try `rustc --explain E0687`.

0 commit comments

Comments
 (0)