diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/suggestions/lifetimes | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/ui/suggestions/lifetimes/issue-105544.fixed | 45 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/issue-105544.rs | 45 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/issue-105544.stderr | 110 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed | 29 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs (renamed from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs) | 3 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr | 30 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed (renamed from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed) | 0 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs (renamed from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs) | 0 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr (renamed from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs (renamed from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs) | 0 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr (renamed from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr) | 14 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs (renamed from src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs) | 0 | ||||
-rw-r--r-- | tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr (renamed from src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr) | 0 |
13 files changed, 269 insertions, 7 deletions
diff --git a/tests/ui/suggestions/lifetimes/issue-105544.fixed b/tests/ui/suggestions/lifetimes/issue-105544.fixed new file mode 100644 index 000000000..47087eb47 --- /dev/null +++ b/tests/ui/suggestions/lifetimes/issue-105544.fixed @@ -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() {} diff --git a/tests/ui/suggestions/lifetimes/issue-105544.rs b/tests/ui/suggestions/lifetimes/issue-105544.rs new file mode 100644 index 000000000..bd3bc1ef9 --- /dev/null +++ b/tests/ui/suggestions/lifetimes/issue-105544.rs @@ -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() {} diff --git a/tests/ui/suggestions/lifetimes/issue-105544.stderr b/tests/ui/suggestions/lifetimes/issue-105544.stderr new file mode 100644 index 000000000..08fe21b11 --- /dev/null +++ b/tests/ui/suggestions/lifetimes/issue-105544.stderr @@ -0,0 +1,110 @@ +error[E0311]: the parameter type `impl Sized` may not live long enough + --> $DIR/issue-105544.rs:7:5 + | +LL | (d, p) + | ^^^^^^ + | +note: the parameter type `impl Sized` must be valid for the anonymous lifetime defined here... + --> $DIR/issue-105544.rs:5:26 + | +LL | fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ { + | ^^^^^^^ +note: ...so that the type `impl Sized` will meet its required lifetime bounds + --> $DIR/issue-105544.rs:7:5 + | +LL | (d, p) + | ^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ { + | ++++ ++++ ++ + +error[E0309]: the parameter type `impl Sized` may not live long enough + --> $DIR/issue-105544.rs:14:5 + | +LL | (d, p) + | ^^^^^^ ...so that the type `impl Sized` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn foo1<'b>(d: impl Sized + 'b, p: &'b mut ()) -> impl Sized + '_ { + | ++++ + +error[E0311]: the parameter type `impl Sized + 'a` may not live long enough + --> $DIR/issue-105544.rs:20:5 + | +LL | (d, p) + | ^^^^^^ + | +note: the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here... + --> $DIR/issue-105544.rs:18:36 + | +LL | fn foo2<'a>(d: impl Sized + 'a, p: &mut ()) -> impl Sized + '_ { + | ^^^^^^^ +note: ...so that the type `impl Sized + 'a` will meet its required lifetime bounds + --> $DIR/issue-105544.rs:20:5 + | +LL | (d, p) + | ^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | fn foo2<'b, 'a>(d: impl Sized + 'a + 'b, p: &'b mut ()) -> impl Sized + '_ { + | +++ ++++ ++ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/issue-105544.rs:27:5 + | +LL | (d, p) + | ^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/issue-105544.rs:25:28 + | +LL | fn bar<T : Sized>(d: T, p: & mut ()) -> impl Sized + '_ { + | ^^^^^^^^ +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/issue-105544.rs:27:5 + | +LL | (d, p) + | ^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + '_ { + | +++ ++++ ++ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/issue-105544.rs:34:5 + | +LL | (d, p) + | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn bar1<'b, T : Sized + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ { + | ++++ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/issue-105544.rs:40:5 + | +LL | (d, p) + | ^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/issue-105544.rs:38:38 + | +LL | fn bar2<'a, T : Sized + 'a>(d: T, p: &mut ()) -> impl Sized + '_ { + | ^^^^^^^ +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/issue-105544.rs:40:5 + | +LL | (d, p) + | ^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | fn bar2<'b, 'a, T : Sized + 'a + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ { + | +++ ++++ ++ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0309, E0311. +For more information about an error, try `rustc --explain E0309`. diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed new file mode 100644 index 000000000..4013d98c3 --- /dev/null +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed @@ -0,0 +1,29 @@ +// Regression test for #81650 +// run-rustfix + +#![allow(warnings)] + +struct Foo<'a> { + x: &'a mut &'a i32, +} + +impl<'a> Foo<'a> { + fn bar<F, T>(&self, f: F) + where + F: FnOnce(&Foo<'a>) -> T, + F: 'a, + {} +} + +trait Test { + fn test(&self); +} + +fn func<'a, T: Test + 'a>(foo: &'a Foo<'a>, t: T) { + foo.bar(move |_| { + //~^ ERROR the parameter type `T` may not live long enough + t.test(); + }); +} + +fn main() {} diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs index c6802ac6c..4096d95e5 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs @@ -1,4 +1,7 @@ // Regression test for #81650 +// run-rustfix + +#![allow(warnings)] struct Foo<'a> { x: &'a mut &'a i32, diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr new file mode 100644 index 000000000..936d87f79 --- /dev/null +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr @@ -0,0 +1,30 @@ +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/missing-lifetimes-in-signature-2.rs:23:5 + | +LL | / foo.bar(move |_| { +LL | | +LL | | t.test(); +LL | | }); + | |______^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature-2.rs:22:24 + | +LL | fn func<T: Test>(foo: &Foo, t: T) { + | ^^^ +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature-2.rs:23:5 + | +LL | / foo.bar(move |_| { +LL | | +LL | | t.test(); +LL | | }); + | |______^ +help: consider adding an explicit lifetime bound... + | +LL | fn func<'a, T: Test + 'a>(foo: &'a Foo<'a>, t: T) { + | +++ ++++ ++ ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0311`. diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed index 3c06f4f88..3c06f4f88 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.fixed diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs index 110468cbb..110468cbb 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.rs diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr index 7b126c90e..7b126c90e 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-before-const.stderr diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index b641f5941..b641f5941 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index fa758bf05..c5c3f7b46 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -47,7 +47,7 @@ LL | | } | |_____^ help: consider adding an explicit lifetime bound... | -LL ~ fn bar<'a, G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ +LL ~ fn bar<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ LL | where LL ~ G: Get<T> + 'a, | @@ -76,8 +76,8 @@ LL | | } | |_____^ help: consider adding an explicit lifetime bound... | -LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | +++ ++++ +LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &'b mut T) -> impl FnOnce() + '_ + | +++ ++++ ++ error[E0311]: the parameter type `G` may not live long enough --> $DIR/missing-lifetimes-in-signature.rs:61:9 @@ -103,8 +103,8 @@ LL | | } | |_________^ help: consider adding an explicit lifetime bound... | -LL | fn qux<'c, 'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - | +++ ++++ +LL | fn qux<'c, 'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &'c mut T) -> impl FnOnce() + '_ { + | +++ ++++ ++ error[E0311]: the parameter type `G` may not live long enough --> $DIR/missing-lifetimes-in-signature.rs:73:5 @@ -132,8 +132,8 @@ LL | | } | |_____^ help: consider adding an explicit lifetime bound... | -LL | fn bat<'b, 'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a - | +++ ++++ +LL | fn bat<'b, 'a, G: 'a + 'b, T>(g: G, dest: &'b mut T) -> impl FnOnce() + '_ + 'a + | +++ ++++ ++ error[E0621]: explicit lifetime required in the type of `dest` --> $DIR/missing-lifetimes-in-signature.rs:73:5 diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs b/tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs index ff27011f8..ff27011f8 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs +++ b/tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr index c77ef79e7..c77ef79e7 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr |