-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix invalid syntax in impl Trait parameter type suggestions for E0311
- Loading branch information
Showing
14 changed files
with
365 additions
and
39 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,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 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
13 changes: 13 additions & 0 deletions
13
tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed
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,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 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 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,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 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.