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.
Auto merge of rust-lang#44782 - estebank:issue-36700, r=GuillaumeGomez
Point at parameter type on E0301 On "the parameter type `T` may not live long enough" error, point to the parameter type suggesting lifetime bindings: ``` error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 27 | struct Foo<T> { | - help: consider adding an explicit lifetime bound `T: 'static`... 28 | foo: &'static T | ^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'static T` does not outlive the data it points at --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 28 | foo: &'static T | ^^^^^^^^^^^^^^^ ``` Fix rust-lang#36700.
- Loading branch information
Showing
8 changed files
with
102 additions
and
20 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
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
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
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
30 changes: 30 additions & 0 deletions
30
src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
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,30 @@ | ||
error[E0309]: the parameter type `T` may not live long enough | ||
--> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 | ||
| | ||
17 | struct List<'a, T: ListItem<'a>> { | ||
| -- help: consider adding an explicit lifetime bound `T: 'a`... | ||
18 | slice: &'a [T] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
note: ...so that the reference type `&'a [T]` does not outlive the data it points at | ||
--> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 | ||
| | ||
18 | slice: &'a [T] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error[E0310]: the parameter type `T` may not live long enough | ||
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | ||
| | ||
27 | struct Foo<T> { | ||
| - help: consider adding an explicit lifetime bound `T: 'static`... | ||
28 | foo: &'static T | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: ...so that the reference type `&'static T` does not outlive the data it points at | ||
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | ||
| | ||
28 | foo: &'static T | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|