-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311 #106167
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
Merged
Merged
Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311 #106167
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,13 @@ | ||
// run-rustfix | ||
|
||
#![allow(warnings)] | ||
|
||
fn no_restriction<'a, T: 'a>(x: &'a ()) -> &() { | ||
with_restriction::<T>(x) //~ ERROR E0311 | ||
} | ||
|
||
fn with_restriction<'a, T: 'a>(x: &'a ()) -> &'a () { | ||
x | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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 hidden or 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
13 changes: 13 additions & 0 deletions
13
tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed
This file contains hidden or 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,13 @@ | ||
// run-rustfix | ||
|
||
#![allow(warnings)] | ||
|
||
fn no_restriction<'a, T: 'a>(x: &'a ()) -> &() { | ||
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() {} |
4 changes: 4 additions & 0 deletions
4
tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.rs
This file contains hidden or 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
10 changes: 5 additions & 5 deletions
10
tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr
This file contains hidden or 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 hidden or 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,45 @@ | ||
// run-rustfix | ||
|
||
#![allow(warnings)] | ||
|
||
fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `impl Sized` may not live long enough | ||
//~| NOTE ...so that the type `impl Sized` will meet its required lifetime bounds | ||
} | ||
|
||
fn foo1<'b>(d: impl Sized + 'b, p: &'b mut ()) -> impl Sized + '_ { | ||
//~^ HELP consider adding an explicit lifetime bound... | ||
(d, p) //~ NOTE ...so that the type `impl Sized` will meet its required lifetime bounds | ||
//~^ ERROR the parameter type `impl Sized` may not live long enough | ||
} | ||
|
||
fn foo2<'b, 'a>(d: impl Sized + 'a + 'b, p: &'b mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `impl Sized + 'a` may not live long enough | ||
//~| NOTE ...so that the type `impl Sized + 'a` will meet its required lifetime bounds | ||
} | ||
|
||
fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
//~| NOTE ...so that the type `T` will meet its required lifetime bounds | ||
} | ||
|
||
fn bar1<'b, T : Sized + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ { | ||
//~^ HELP consider adding an explicit lifetime bound... | ||
(d, p) //~ NOTE ...so that the type `T` will meet its required lifetime bounds | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
} | ||
|
||
fn bar2<'b, 'a, T : Sized + 'a + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
//~| NOTE ...so that the type `T` will meet its required lifetime bounds | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,45 @@ | ||
// run-rustfix | ||
|
||
#![allow(warnings)] | ||
|
||
fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `impl Sized` may not live long enough | ||
//~| NOTE ...so that the type `impl Sized` will meet its required lifetime bounds | ||
} | ||
|
||
fn foo1<'b>(d: impl Sized, p: &'b mut ()) -> impl Sized + '_ { | ||
//~^ HELP consider adding an explicit lifetime bound... | ||
(d, p) //~ NOTE ...so that the type `impl Sized` will meet its required lifetime bounds | ||
//~^ ERROR the parameter type `impl Sized` may not live long enough | ||
} | ||
|
||
fn foo2<'a>(d: impl Sized + 'a, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `impl Sized + 'a` may not live long enough | ||
//~| NOTE ...so that the type `impl Sized + 'a` will meet its required lifetime bounds | ||
} | ||
|
||
fn bar<T : Sized>(d: T, p: & mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
//~| NOTE ...so that the type `T` will meet its required lifetime bounds | ||
} | ||
|
||
fn bar1<'b, T : Sized>(d: T, p: &'b mut ()) -> impl Sized + '_ { | ||
//~^ HELP consider adding an explicit lifetime bound... | ||
(d, p) //~ NOTE ...so that the type `T` will meet its required lifetime bounds | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
} | ||
|
||
fn bar2<'a, T : Sized + 'a>(d: T, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here... | ||
//~^ HELP consider adding an explicit lifetime bound | ||
(d, p) | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
//~| NOTE ...so that the type `T` will meet its required lifetime bounds | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.