diff options
Diffstat (limited to 'tests/ui/regions')
10 files changed, 126 insertions, 45 deletions
diff --git a/tests/ui/regions/closure-in-projection-issue-97405.rs b/tests/ui/regions/closure-in-projection-issue-97405.rs index e567d5c27..548953397 100644 --- a/tests/ui/regions/closure-in-projection-issue-97405.rs +++ b/tests/ui/regions/closure-in-projection-issue-97405.rs @@ -1,5 +1,5 @@ // Regression test for #97405. -// In `good_generic_fn` the param `T` ends up in the substs of closures/generators, +// In `good_generic_fn` the param `T` ends up in the substs of closures/coroutines, // but we should be able to prove `<Gen<T> as Iterator>::Item: 'static` without // requiring `T: 'static` diff --git a/tests/ui/regions/closure-in-projection-issue-97405.stderr b/tests/ui/regions/closure-in-projection-issue-97405.stderr index c08f1059e..7070dfef1 100644 --- a/tests/ui/regions/closure-in-projection-issue-97405.stderr +++ b/tests/ui/regions/closure-in-projection-issue-97405.stderr @@ -3,27 +3,33 @@ error[E0310]: the associated type `<impl Iterator as Iterator>::Item` may not li | LL | assert_static(opaque(async move { t; }).next()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the associated type `<impl Iterator as Iterator>::Item` must be valid for the static lifetime... + | ...so that the type `<impl Iterator as Iterator>::Item` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<impl Iterator as Iterator>::Item: 'static`... - = note: ...so that the type `<impl Iterator as Iterator>::Item` will meet its required lifetime bounds error[E0310]: the associated type `<impl Iterator as Iterator>::Item` may not live long enough --> $DIR/closure-in-projection-issue-97405.rs:26:5 | LL | assert_static(opaque(move || { t; }).next()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the associated type `<impl Iterator as Iterator>::Item` must be valid for the static lifetime... + | ...so that the type `<impl Iterator as Iterator>::Item` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<impl Iterator as Iterator>::Item: 'static`... - = note: ...so that the type `<impl Iterator as Iterator>::Item` will meet its required lifetime bounds error[E0310]: the associated type `<impl Iterator as Iterator>::Item` may not live long enough --> $DIR/closure-in-projection-issue-97405.rs:28:5 | LL | assert_static(opaque(opaque(async move { t; }).next()).next()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the associated type `<impl Iterator as Iterator>::Item` must be valid for the static lifetime... + | ...so that the type `<impl Iterator as Iterator>::Item` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<impl Iterator as Iterator>::Item: 'static`... - = note: ...so that the type `<impl Iterator as Iterator>::Item` will meet its required lifetime bounds error: aborting due to 3 previous errors diff --git a/tests/ui/regions/regions-close-associated-type-into-object.stderr b/tests/ui/regions/regions-close-associated-type-into-object.stderr index f7dcaa9d9..6fb514377 100644 --- a/tests/ui/regions/regions-close-associated-type-into-object.stderr +++ b/tests/ui/regions/regions-close-associated-type-into-object.stderr @@ -3,36 +3,56 @@ error[E0310]: the associated type `<T as Iter>::Item` may not live long enough | LL | Box::new(item) | ^^^^^^^^^^^^^^ + | | + | the associated type `<T as Iter>::Item` must be valid for the static lifetime... + | ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds | - = help: consider adding an explicit lifetime bound `<T as Iter>::Item: 'static`... - = note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds +help: consider adding an explicit lifetime bound + | +LL | fn bad1<T: Iter>(v: T) -> Box<dyn X + 'static> where <T as Iter>::Item: 'static + | ++++++++++++++++++++++++++++++++ error[E0310]: the associated type `<T as Iter>::Item` may not live long enough --> $DIR/regions-close-associated-type-into-object.rs:22:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ + | | + | the associated type `<T as Iter>::Item` must be valid for the static lifetime... + | ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound | - = help: consider adding an explicit lifetime bound `<T as Iter>::Item: 'static`... - = note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds +LL | where Box<T::Item> : X, <T as Iter>::Item: 'static + | ++++++++++++++++++++++++++++ error[E0309]: the associated type `<T as Iter>::Item` may not live long enough --> $DIR/regions-close-associated-type-into-object.rs:28:5 | +LL | fn bad3<'a, T: Iter>(v: T) -> Box<dyn X + 'a> + | -- the associated type `<T as Iter>::Item` must be valid for the lifetime `'a` as defined here... +... LL | Box::new(item) - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds | - = help: consider adding an explicit lifetime bound `<T as Iter>::Item: 'a`... - = note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds +help: consider adding an explicit lifetime bound + | +LL | fn bad3<'a, T: Iter>(v: T) -> Box<dyn X + 'a> where <T as Iter>::Item: 'a + | +++++++++++++++++++++++++++ error[E0309]: the associated type `<T as Iter>::Item` may not live long enough --> $DIR/regions-close-associated-type-into-object.rs:35:5 | +LL | fn bad4<'a, T: Iter>(v: T) -> Box<dyn X + 'a> + | -- the associated type `<T as Iter>::Item` must be valid for the lifetime `'a` as defined here... +... LL | Box::new(item) - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound | - = help: consider adding an explicit lifetime bound `<T as Iter>::Item: 'a`... - = note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds +LL | where Box<T::Item> : X, <T as Iter>::Item: 'a + | +++++++++++++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/regions/regions-close-object-into-object-4.stderr b/tests/ui/regions/regions-close-object-into-object-4.stderr index 7a9f1ab00..b8b414b7e 100644 --- a/tests/ui/regions/regions-close-object-into-object-4.stderr +++ b/tests/ui/regions/regions-close-object-into-object-4.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:9:5 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | ^^^^^^^^ + | | + | the parameter type `U` must be valid for the static lifetime... + | ...so that the type `U` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | +++++++++ @@ -13,9 +16,12 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:9:5 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `U` must be valid for the static lifetime... + | ...so that the type `U` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | +++++++++ @@ -24,9 +30,13 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:9:5 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `U` must be valid for the static lifetime... + | ...so that the type `U` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound | LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | +++++++++ @@ -61,9 +71,12 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:9:14 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | ^^^^^^ + | | + | the parameter type `U` must be valid for the static lifetime... + | ...so that the type `U` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | +++++++++ diff --git a/tests/ui/regions/regions-close-object-into-object-5.stderr b/tests/ui/regions/regions-close-object-into-object-5.stderr index 311e8868c..4a2f4f847 100644 --- a/tests/ui/regions/regions-close-object-into-object-5.stderr +++ b/tests/ui/regions/regions-close-object-into-object-5.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:17:5 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { | +++++++++ @@ -13,9 +16,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:17:5 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { | +++++++++ @@ -24,9 +30,13 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:17:5 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound | LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { | +++++++++ @@ -44,9 +54,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:17:14 | LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { | +++++++++ diff --git a/tests/ui/regions/regions-close-over-type-parameter-1.stderr b/tests/ui/regions/regions-close-over-type-parameter-1.stderr index b7b557d7a..1cd5b7f22 100644 --- a/tests/ui/regions/regions-close-over-type-parameter-1.stderr +++ b/tests/ui/regions/regions-close-over-type-parameter-1.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:11:5 | LL | Box::new(v) as Box<dyn SomeTrait + 'static> - | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | ^^^^^^^^^^^ + | | + | the parameter type `A` must be valid for the static lifetime... + | ...so that the type `A` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn make_object1<A: SomeTrait + 'static>(v: A) -> Box<dyn SomeTrait + 'static> { | +++++++++ @@ -12,10 +15,12 @@ LL | fn make_object1<A: SomeTrait + 'static>(v: A) -> Box<dyn SomeTrait + 'stati error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | +LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> { + | -- the parameter type `A` must be valid for the lifetime `'b` as defined here... LL | Box::new(v) as Box<dyn SomeTrait + 'b> | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn make_object3<'a, 'b, A: SomeTrait + 'a + 'b>(v: A) -> Box<dyn SomeTrait + 'b> { | ++++ diff --git a/tests/ui/regions/regions-close-param-into-object.stderr b/tests/ui/regions/regions-close-param-into-object.stderr index 9162be5b9..385441d32 100644 --- a/tests/ui/regions/regions-close-param-into-object.stderr +++ b/tests/ui/regions/regions-close-param-into-object.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:6:5 | LL | Box::new(v) - | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | where T : X + 'static | +++++++++ @@ -13,9 +16,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:12:5 | LL | Box::new(v) - | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn p2<T: 'static>(v: Box<T>) -> Box<dyn X + 'static> | +++++++++ @@ -23,10 +29,13 @@ LL | fn p2<T: 'static>(v: Box<T>) -> Box<dyn X + 'static> error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:18:5 | +LL | fn p3<'a,T>(v: T) -> Box<dyn X + 'a> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | where T : X + 'a | ++++ @@ -34,10 +43,13 @@ LL | where T : X + 'a error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:24:5 | +LL | fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn p4<'a,T: 'a>(v: Box<T>) -> Box<dyn X + 'a> | ++++ diff --git a/tests/ui/regions/regions-implied-bounds-projection-gap-1.stderr b/tests/ui/regions/regions-implied-bounds-projection-gap-1.stderr index 7c9f40556..8c1791fc1 100644 --- a/tests/ui/regions/regions-implied-bounds-projection-gap-1.stderr +++ b/tests/ui/regions/regions-implied-bounds-projection-gap-1.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-implied-bounds-projection-gap-1.rs:16:5 | +LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) + | -- the parameter type `T` must be valid for the lifetime `'x` as defined here... +LL | { LL | wf::<&'x T>(); | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn func<'x, T:Trait1<'x> + 'x>(t: &'x T::Foo) | ++++ diff --git a/tests/ui/regions/regions-infer-bound-from-trait-self.stderr b/tests/ui/regions/regions-infer-bound-from-trait-self.stderr index e88f79a3a..d0c4b9a57 100644 --- a/tests/ui/regions/regions-infer-bound-from-trait-self.stderr +++ b/tests/ui/regions/regions-infer-bound-from-trait-self.stderr @@ -1,11 +1,16 @@ error[E0309]: the parameter type `Self` may not live long enough --> $DIR/regions-infer-bound-from-trait-self.rs:46:9 | +LL | trait InheritsFromNothing<'a> : Sized { + | -- the parameter type `Self` must be valid for the lifetime `'a` as defined here... +LL | fn foo(self, x: Inv<'a>) { LL | check_bound(x, self) - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `Self` will meet its required lifetime bounds | - = help: consider adding an explicit lifetime bound `Self: 'a`... - = note: ...so that the type `Self` will meet its required lifetime bounds +help: consider adding an explicit lifetime bound + | +LL | trait InheritsFromNothing<'a> : Sized where Self: 'a { + | ++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/regions/regions-infer-bound-from-trait.stderr b/tests/ui/regions/regions-infer-bound-from-trait.stderr index 3ee71543d..b9be11a46 100644 --- a/tests/ui/regions/regions-infer-bound-from-trait.stderr +++ b/tests/ui/regions/regions-infer-bound-from-trait.stderr @@ -1,10 +1,12 @@ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-infer-bound-from-trait.rs:33:5 | +LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { + | -- the parameter type `A` must be valid for the lifetime `'a` as defined here... LL | check_bound(x, a) | ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn bar1<'a,A: 'a>(x: Inv<'a>, a: A) { | ++++ @@ -12,10 +14,12 @@ LL | fn bar1<'a,A: 'a>(x: Inv<'a>, a: A) { error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-infer-bound-from-trait.rs:37:5 | +LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { + | -- the parameter type `A` must be valid for the lifetime `'a` as defined here... LL | check_bound(x, a) | ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn bar2<'a,'b,A:Is<'b> + 'a>(x: Inv<'a>, y: Inv<'b>, a: A) { | ++++ |