forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#72071 - PankajChaudhary5:ErrorCode-E0687, r…
…=davidtwco 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 rust-lang#61137 r? @GuillaumeGomez
- Loading branch information
Showing
4 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters