Point at unmet explicit lifetime obligation bound

This commit is contained in:
Esteban Küber 2021-07-30 08:12:10 -07:00
parent 7069a8c2b7
commit e5d42af6ba
24 changed files with 238 additions and 55 deletions

View file

@ -4,7 +4,13 @@ error[E0310]: the parameter type `U` may not live long enough
LL | struct Foo<U> {
| - help: consider adding an explicit lifetime bound...: `U: 'static`
LL | bar: Bar<U>
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:7:15
|
LL | struct Bar<T: 'static> {
| ^^^^^^^
error: aborting due to previous error

View file

@ -11,7 +11,13 @@ LL | | {
... |
LL | |
LL | | }
| |_^ ...so that the type `T` will meet its required lifetime bounds
| |_^ ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/issue-86483.rs:7:16
|
LL | for<'a> T: 'a,
| ^^
error[E0311]: the parameter type `T` may not live long enough
--> $DIR/issue-86483.rs:9:5
@ -20,7 +26,13 @@ LL | pub trait IceIce<T>
| - help: consider adding an explicit lifetime bound...: `T: 'a`
...
LL | type Ice<'v>: IntoIterator<Item = &'v T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/issue-86483.rs:7:16
|
LL | for<'a> T: 'a,
| ^^
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/issue-86483.rs:9:32

View file

@ -4,7 +4,7 @@ error[E0477]: the type `&'b ()` does not fulfill the required lifetime
LL | type Item<'a> = &'b ();
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'a` as defined on the associated item at 8:15
note: type must outlive the lifetime `'a` as defined on the associated item at 8:15 as required by this binding
--> $DIR/unsatisfied-outlives-bound.rs:8:15
|
LL | type Item<'a> = &'b ();
@ -16,7 +16,11 @@ error[E0477]: the type `&'a ()` does not fulfill the required lifetime
LL | type Item<'a> = &'a ();
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/unsatisfied-outlives-bound.rs:13:20
|
LL | type Item<'a>: 'static;
| ^^^^^^^
error: aborting due to 2 previous errors

View file

@ -4,7 +4,11 @@ error[E0477]: the type `&'a u32` does not fulfill the required lifetime
LL | let x = foo::<&'a u32>();
| ^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/issue-54943.rs:1:11
|
LL | fn foo<T: 'static>() { }
| ^^^^^^^
error: aborting due to previous error

View file

@ -16,7 +16,11 @@ error[E0477]: the type `&'a (dyn Dummy + Sync + 'a)` does not fulfill the requir
LL | assert_send::<&'a (dyn Dummy + Sync)>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/kindck-send-object1.rs:5:23
|
LL | fn assert_send<T:Send+'static>() { }
| ^^^^^^^
error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely
--> $DIR/kindck-send-object1.rs:29:5

View file

@ -5,7 +5,12 @@ LL | bar::<T::Output>()
| ^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `<T as MyTrait<'a>>::Output: 'a`...
= note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds
= note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds...
note: ...that is required by this bound
--> $DIR/projection-where-clause-env-wrong-bound.rs:29:8
|
LL | T: 'a,
| ^^
error: aborting due to previous error

View file

@ -5,7 +5,12 @@ LL | bar::<<T as MyTrait<'a>>::Output>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `<T as MyTrait<'a>>::Output: 'a`...
= note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds
= note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds...
note: ...that is required by this bound
--> $DIR/projection-where-clause-env-wrong-lifetime.rs:20:8
|
LL | T: 'a,
| ^^
error: aborting due to previous error

View file

@ -4,7 +4,11 @@ error[E0477]: the type `&'a i32` does not fulfill the required lifetime
LL | type Value = &'a i32;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:5:17
|
LL | type Value: 'a;
| ^^
error[E0477]: the type `&'a i32` does not fulfill the required lifetime
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:20:5
@ -12,7 +16,7 @@ error[E0477]: the type `&'a i32` does not fulfill the required lifetime
LL | type Value = &'a i32;
| ^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'b` as defined on the impl at 19:10
note: type must outlive the lifetime `'b` as defined on the impl at 19:10 as required by this binding
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:10
|
LL | impl<'a, 'b> Foo<'b> for &'a i64 {

View file

@ -4,7 +4,11 @@ error[E0477]: the type `&'a i32` does not fulfill the required lifetime
LL | type Value = &'a i32;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:5:17
|
LL | type Value: 'static;
| ^^^^^^^
error: aborting due to previous error

View file

@ -4,7 +4,11 @@ error[E0477]: the type `&'a isize` does not fulfill the required lifetime
LL | assert_send::<&'a isize>();
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
LL | fn assert_send<T:'static>() { }
| ^^^^^^^
error[E0477]: the type `&'a str` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5
@ -12,7 +16,11 @@ error[E0477]: the type `&'a str` does not fulfill the required lifetime
LL | assert_send::<&'a str>();
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
LL | fn assert_send<T:'static>() { }
| ^^^^^^^
error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5
@ -20,7 +28,11 @@ error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime
LL | assert_send::<&'a [isize]>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
LL | fn assert_send<T:'static>() { }
| ^^^^^^^
error[E0477]: the type `Box<&'a isize>` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5
@ -28,7 +40,11 @@ error[E0477]: the type `Box<&'a isize>` does not fulfill the required lifetime
LL | assert_send::<Box<&'a isize>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
LL | fn assert_send<T:'static>() { }
| ^^^^^^^
error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5
@ -36,7 +52,11 @@ error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime
LL | assert_send::<*const &'a isize>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
LL | fn assert_send<T:'static>() { }
| ^^^^^^^
error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5
@ -44,7 +64,11 @@ error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime
LL | assert_send::<*mut &'a isize>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
note: type must satisfy the static lifetime as required by this binding
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
LL | fn assert_send<T:'static>() { }
| ^^^^^^^
error: aborting due to 6 previous errors

View file

@ -23,7 +23,13 @@ LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | // oh dear!
LL | box B(&*v) as Box<X>
| ^^^^^^ ...so that the type `T` will meet its required lifetime bounds
| ^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/regions-close-object-into-object-5.rs:9:17
|
LL | struct B<'a, T: 'a>(&'a (A<T> + 'a));
| ^^
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/regions-close-object-into-object-5.rs:17:11

View file

@ -5,7 +5,12 @@ LL | check_bound(x, self)
| ^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `Self: 'a`...
= note: ...so that the type `Self` will meet its required lifetime bounds
= note: ...so that the type `Self` will meet its required lifetime bounds...
note: ...that is required by this bound
--> $DIR/regions-infer-bound-from-trait-self.rs:12:21
|
LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { }
| ^^
error: aborting due to previous error

View file

@ -4,7 +4,13 @@ error[E0309]: the parameter type `A` may not live long enough
LL | fn bar1<'a,A>(x: Inv<'a>, a: A) {
| - help: consider adding an explicit lifetime bound...: `A: 'a`
LL | check_bound(x, a)
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/regions-infer-bound-from-trait.rs:12:21
|
LL | fn check_bound<'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
@ -12,7 +18,13 @@ error[E0309]: the parameter type `A` may not live long enough
LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) {
| -- help: consider adding an explicit lifetime bound...: `A: 'a +`
LL | check_bound(x, a)
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/regions-infer-bound-from-trait.rs:12:21
|
LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { }
| ^^
error: aborting due to 2 previous errors

View file

@ -4,7 +4,13 @@ error[E0310]: the parameter type `U` may not live long enough
LL | struct Foo<U> {
| - help: consider adding an explicit lifetime bound...: `U: 'static`
LL | bar: Bar<U>
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds
| ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/dont-infer-static.rs:10:15
|
LL | struct Bar<T: 'static> {
| ^^^^^^^
error: aborting due to previous error

View file

@ -12,7 +12,13 @@ error[E0309]: the parameter type `T` may not live long enough
LL | impl<'a, T> Trait<'a, T> for u32 {
| - help: consider adding an explicit lifetime bound...: `T: 'a`
LL | type Out = RefOk<'a, T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
| ^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/regions-struct-not-wf.rs:16:20
|
LL | struct RefOk<'a, T:'a> {
| ^^
error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references
--> $DIR/regions-struct-not-wf.rs:25:5

View file

@ -9,7 +9,7 @@ fn foo(d: impl Debug + 'static) {
//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds
}
fn bar(d: impl Debug + 'static) {
fn bar(d: impl Debug + 'static) { //~ NOTE ...that is required by this bound
println!("{:?}", d)
}

View file

@ -9,7 +9,7 @@ fn foo(d: impl Debug) {
//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds
}
fn bar(d: impl Debug + 'static) {
fn bar(d: impl Debug + 'static) { //~ NOTE ...that is required by this bound
println!("{:?}", d)
}

View file

@ -5,7 +5,13 @@ LL | fn foo(d: impl Debug) {
| ---------- help: consider adding an explicit lifetime bound...: `impl Debug + 'static`
LL |
LL | bar(d);
| ^^^ ...so that the type `impl Debug` will meet its required lifetime bounds
| ^^^ ...so that the type `impl Debug` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/suggest-impl-trait-lifetime.rs:12:24
|
LL | fn bar(d: impl Debug + 'static) {
| ^^^^^^^
error: aborting due to previous error