-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suggest introducing an explicit lifetime if it does not exist
- Loading branch information
Showing
5 changed files
with
63 additions
and
19 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
9 changes: 9 additions & 0 deletions
9
src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.rs
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 @@ | ||
fn no_restriction<T>(x: &()) -> &() { | ||
with_restriction::<T>(x) //~ ERROR the parameter type `T` may not live long enough | ||
} | ||
|
||
fn with_restriction<'b, T: 'b>(x: &'b ()) -> &'b () { | ||
x | ||
} | ||
|
||
fn main() {} |
23 changes: 23 additions & 0 deletions
23
src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.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,23 @@ | ||
error[E0311]: the parameter type `T` may not live long enough | ||
--> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:2:5 | ||
| | ||
LL | with_restriction::<T>(x) | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the parameter type `T` must be valid for the anonymous lifetime defined here... | ||
--> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:1:25 | ||
| | ||
LL | fn no_restriction<T>(x: &()) -> &() { | ||
| ^^^ | ||
note: ...so that the type `T` will meet its required lifetime bounds | ||
--> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:2:5 | ||
| | ||
LL | with_restriction::<T>(x) | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
help: consider adding an explicit lifetime bound... | ||
| | ||
LL | fn no_restriction<'a, T: 'a>(x: &()) -> &() { | ||
| +++ ++++ | ||
|
||
error: aborting due to previous error | ||
|
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