-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added proper explanation of ErrorCode-E0687
- Loading branch information
1 parent
20fc02f
commit 46bfc48
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