forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#92351 - TmLev:master, r=GuillaumeGomez
Add long error explanation for E0227 Part of the rust-lang#61137.
- Loading branch information
Showing
5 changed files
with
57 additions
and
3 deletions.
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,33 @@ | ||
This error indicates that the compiler is unable to determine whether there is | ||
exactly one unique region in the set of derived region bounds. | ||
|
||
Example of erroneous code: | ||
|
||
```compile_fail,E0227 | ||
trait Foo<'foo>: 'foo {} | ||
trait Bar<'bar>: 'bar {} | ||
trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {} | ||
struct Baz<'foo, 'bar> { | ||
baz: dyn FooBar<'foo, 'bar>, | ||
} | ||
``` | ||
|
||
Here, `baz` can have either `'foo` or `'bar` lifetimes. | ||
|
||
To resolve this error, provide an explicit lifetime: | ||
|
||
```rust | ||
trait Foo<'foo>: 'foo {} | ||
trait Bar<'bar>: 'bar {} | ||
|
||
trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {} | ||
|
||
struct Baz<'foo, 'bar, 'baz> | ||
where | ||
'baz: 'foo + 'bar, | ||
{ | ||
obj: dyn FooBar<'foo, 'bar> + 'baz, | ||
} | ||
``` |
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,12 @@ | ||
trait Foo<'foo>: 'foo {} | ||
trait Bar<'bar>: 'bar {} | ||
|
||
trait FooBar<'foo, 'bar>: Foo<'foo> + Bar<'bar> {} | ||
|
||
struct Baz<'foo, 'bar> { | ||
baz: dyn FooBar<'foo, 'bar>, | ||
//~^ ERROR ambiguous lifetime bound, explicit lifetime bound required | ||
} | ||
|
||
fn main() { | ||
} |
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,9 @@ | ||
error[E0227]: ambiguous lifetime bound, explicit lifetime bound required | ||
--> $DIR/E0227.rs:7:10 | ||
| | ||
LL | baz: dyn FooBar<'foo, 'bar>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0227`. |
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