Skip to content

Commit

Permalink
Rollup merge of #72071 - PankajChaudhary5:ErrorCode-E0687, r=davidtwco
Browse files Browse the repository at this point in the history
Added detailed error code explanation for issue E0687 in Rust compiler.

Added proper error explanation for issue E0687 in the Rust compiler.
Error Code E0687

Sub Part of Issue #61137

r? @GuillaumeGomez
  • Loading branch information
Manishearth authored Jul 1, 2020
2 parents 1505c12 + 46bfc48 commit 128fa2b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ E0668: include_str!("./error_codes/E0668.md"),
E0669: include_str!("./error_codes/E0669.md"),
E0670: include_str!("./error_codes/E0670.md"),
E0671: include_str!("./error_codes/E0671.md"),
E0687: include_str!("./error_codes/E0687.md"),
E0689: include_str!("./error_codes/E0689.md"),
E0690: include_str!("./error_codes/E0690.md"),
E0691: include_str!("./error_codes/E0691.md"),
Expand Down Expand Up @@ -613,7 +614,6 @@ E0766: include_str!("./error_codes/E0766.md"),
E0640, // infer outlives requirements
// E0645, // trait aliases not finished
E0667, // `impl Trait` in projections
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
// E0694, // an unknown tool name found in scoped attributes
// E0702, // replaced with a generic attribute input check
Expand Down
36 changes: 36 additions & 0 deletions src/librustc_error_codes/error_codes/E0687.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
In-band lifetimes cannot be used in `fn`/`Fn` syntax.

Erroneous code examples:

```compile_fail,E0687
#![feature(in_band_lifetimes)]
fn foo(x: fn(&'a u32)) {} // error!
fn bar(x: &Fn(&'a u32)) {} // error!
fn baz(x: fn(&'a u32), y: &'a u32) {} // error!
struct Foo<'a> { x: &'a u32 }
impl Foo<'a> {
fn bar(&self, x: fn(&'a u32)) {} // error!
}
```

Lifetimes used in `fn` or `Fn` syntax must be explicitly
declared using `<...>` binders. For example:

```
fn foo<'a>(x: fn(&'a u32)) {} // ok!
fn bar<'a>(x: &Fn(&'a u32)) {} // ok!
fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok!
struct Foo<'a> { x: &'a u32 }
impl<'a> Foo<'a> {
fn bar(&self, x: fn(&'a u32)) {} // ok!
}
```
1 change: 1 addition & 0 deletions src/test/ui/in-band-lifetimes/E0687.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ LL | fn bar(&self, x: fn(&'a u32)) {}

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0687`.
1 change: 1 addition & 0 deletions src/test/ui/in-band-lifetimes/E0687_where.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ LL | fn baz(x: &impl Fn(&'a u32)) {}

error: aborting due to 2 previous errors

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

0 comments on commit 128fa2b

Please sign in to comment.