Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added detailed error code explanation for issue E0688 in Rust compiler. #74286

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -383,6 +383,7 @@ 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"),
E0688: include_str!("./error_codes/E0688.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 @@ -616,7 +617,6 @@ E0768: include_str!("./error_codes/E0768.md"),
E0640, // infer outlives requirements
// E0645, // trait aliases not finished
E0667, // `impl Trait` in projections
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
// E0707, // multiple elided lifetimes used in arguments of `async fn`
Expand Down
36 changes: 36 additions & 0 deletions src/librustc_error_codes/error_codes/E0688.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
In-band lifetimes were mixed with explicit lifetime binders.

Erroneous code example:

```compile_fail,E0688
#![feature(in_band_lifetimes)]

fn foo<'a>(x: &'a u32, y: &'b u32) {} // error!

struct Foo<'a> { x: &'a u32 }

impl Foo<'a> {
fn bar<'b>(x: &'a u32, y: &'b u32, z: &'c u32) {} // error!
}

impl<'b> Foo<'a> { // error!
fn baz() {}
}
```

In-band lifetimes cannot be mixed with explicit lifetime binders.
For example:

```
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) {} // ok!

struct Foo<'a> { x: &'a u32 }

impl<'a> Foo<'a> {
fn bar<'b,'c>(x: &'a u32, y: &'b u32, z: &'c u32) {} // ok!
}

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

error: aborting due to 3 previous errors

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