diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-01 07:42:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 07:42:27 -0700 |
| commit | 128fa2b981454ca2b72750ee22699780d5421153 (patch) | |
| tree | fcb3be6238b641bbfdf3de91f30d3b0d3f226d19 /src/librustc_error_codes/error_codes | |
| parent | 1505c1239554fd8c9a5f7a6f4823c7384a0c29e3 (diff) | |
| parent | 46bfc48272ba5312c439557e2901e1a4778e9487 (diff) | |
Rollup merge of #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 #61137 r? @GuillaumeGomez
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0687.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/librustc_error_codes/error_codes/E0687.md b/src/librustc_error_codes/error_codes/E0687.md new file mode 100644 index 00000000000..67b7db2d31f --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0687.md @@ -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! +} +``` |
