Tweak binding lifetime suggestion text
We already have a structured suggestion, but the wording made it seem like that wasn't the case. Fix #65286. r? @varkor
This commit is contained in:
parent
a643ee8d69
commit
c816430f99
@ -1781,14 +1781,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
bound_kind: GenericKind<'tcx>,
|
||||
sub: S,
|
||||
) {
|
||||
let consider = format!(
|
||||
"consider adding an explicit lifetime bound {}",
|
||||
if type_param_span.map(|(_, _, is_impl_trait)| is_impl_trait).unwrap_or(false) {
|
||||
format!(" `{}` to `{}`...", sub, bound_kind)
|
||||
} else {
|
||||
format!("`{}: {}`...", bound_kind, sub)
|
||||
},
|
||||
);
|
||||
let msg = "consider adding an explicit lifetime bound";
|
||||
if let Some((sp, has_lifetimes, is_impl_trait)) = type_param_span {
|
||||
let suggestion = if is_impl_trait {
|
||||
format!("{} + {}", bound_kind, sub)
|
||||
@ -1796,13 +1789,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
let tail = if has_lifetimes { " + " } else { "" };
|
||||
format!("{}: {}{}", bound_kind, sub, tail)
|
||||
};
|
||||
err.span_suggestion_short(
|
||||
err.span_suggestion(
|
||||
sp,
|
||||
&consider,
|
||||
&format!("{}...", msg),
|
||||
suggestion,
|
||||
Applicability::MaybeIncorrect, // Issue #41966
|
||||
);
|
||||
} else {
|
||||
let consider = format!(
|
||||
"{} {}...",
|
||||
msg,
|
||||
if type_param_span.map(|(_, _, is_impl_trait)| is_impl_trait).unwrap_or(false) {
|
||||
format!(" `{}` to `{}`", sub, bound_kind)
|
||||
} else {
|
||||
format!("`{}: {}`", bound_kind, sub)
|
||||
},
|
||||
);
|
||||
err.help(&consider);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
LL | impl <T: Sync> Foo for T { }
|
||||
| -- ^^^
|
||||
| |
|
||||
| help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| help: consider adding an explicit lifetime bound...: `T: 'static +`
|
||||
|
|
||||
note: ...so that the type `T` will meet its required lifetime bounds
|
||||
--> $DIR/builtin-superkinds-self-type.rs:10:16
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:5
|
||||
|
|
||||
LL | struct Foo<U> {
|
||||
| - help: consider adding an explicit lifetime bound `U: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `U: 'static`
|
||||
LL | bar: Bar<U>
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
|
@ -67,7 +67,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| help: consider adding an explicit lifetime bound...: `T: 'static +`
|
||||
|
|
||||
note: ...so that the type `T` will meet its required lifetime bounds
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:22:51
|
||||
|
@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
LL | fn foo<T>(x: T) -> impl Any + 'static {
|
||||
| - ^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
|
||||
note: ...so that the type `T` will meet its required lifetime bounds
|
||||
--> $DIR/type_parameters_captured.rs:7:20
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/lifetime-doesnt-live-long-enough.rs:19:5
|
||||
|
|
||||
LL | struct Foo<T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | foo: &'static T
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ error[E0309]: the parameter type `K` may not live long enough
|
||||
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
|
||||
|
|
||||
LL | trait X<K>: Sized {
|
||||
| - help: consider adding an explicit lifetime bound `K: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `K: 'a`
|
||||
LL | fn foo<'a, L: X<&'a Nested<K>>>();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -45,7 +45,7 @@ error[E0309]: the parameter type `L` may not live long enough
|
||||
LL | fn baz<'a, L, M: X<&'a Nested<L>>>() {
|
||||
| - ^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider adding an explicit lifetime bound `L: 'a`...
|
||||
| help: consider adding an explicit lifetime bound...: `L: 'a`
|
||||
|
|
||||
note: ...so that the reference type `&'a Nested<L>` does not outlive the data it points at
|
||||
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:22
|
||||
@ -57,7 +57,7 @@ error[E0309]: the parameter type `K` may not live long enough
|
||||
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
|
||||
|
|
||||
LL | impl<K> Nested<K> {
|
||||
| - help: consider adding an explicit lifetime bound `K: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `K: 'a`
|
||||
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -71,7 +71,7 @@ error[E0309]: the parameter type `M` may not live long enough
|
||||
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
|
||||
|
|
||||
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
|
||||
| ^^^^^^^^^^^^^^^^ -- help: consider adding an explicit lifetime bound `M: 'a`...
|
||||
| ^^^^^^^^^^^^^^^^ -- help: consider adding an explicit lifetime bound...: `M: 'a +`
|
||||
|
|
||||
note: ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
|
||||
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^^^^^^^^^^
|
||||
@ -17,7 +17,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
@ -32,7 +32,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:9
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^
|
||||
@ -47,7 +47,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:9
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^^^^^^
|
||||
@ -62,7 +62,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:11
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^^^
|
||||
@ -77,7 +77,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:11
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^^^
|
||||
@ -92,7 +92,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:11
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // oh dear!
|
||||
LL | box B(&*v) as Box<X>
|
||||
| ^^^
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:10:5
|
||||
|
|
||||
LL | fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
|
||||
| -- help: consider adding an explicit lifetime bound `A: 'static`...
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'static +`
|
||||
LL | box v as Box<dyn SomeTrait + 'static>
|
||||
| ^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:10:5
|
||||
|
|
||||
LL | fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
|
||||
| -- help: consider adding an explicit lifetime bound `A: 'static`...
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'static +`
|
||||
LL | box v as Box<dyn SomeTrait + 'static>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -30,7 +30,7 @@ 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> {
|
||||
| -- help: consider adding an explicit lifetime bound `A: 'b`...
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'b +`
|
||||
LL | box v as Box<dyn SomeTrait + 'b>
|
||||
| ^^^^^
|
||||
|
|
||||
@ -44,7 +44,7 @@ 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> {
|
||||
| -- help: consider adding an explicit lifetime bound `A: 'b`...
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'b +`
|
||||
LL | box v as Box<dyn SomeTrait + 'b>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:6:5
|
||||
|
|
||||
LL | fn p1<T>(v: T) -> Box<dyn X + 'static>
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
...
|
||||
LL | Box::new(v)
|
||||
| ^^^^^^^^^^^
|
||||
@ -17,7 +17,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:12:5
|
||||
|
|
||||
LL | fn p2<T>(v: Box<T>) -> Box<dyn X + 'static>
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
...
|
||||
LL | Box::new(v)
|
||||
| ^^^^^^^^^^^
|
||||
@ -32,7 +32,7 @@ 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>
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | Box::new(v)
|
||||
| ^^^^^^^^^^^
|
||||
@ -47,7 +47,7 @@ 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>
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | Box::new(v)
|
||||
| ^^^^^^^^^^^
|
||||
|
@ -2,7 +2,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:18:18
|
||||
|
|
||||
LL | enum Ref1<'a, T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | Ref1Variant1(RequireOutlives<'a, T>)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:23:25
|
||||
|
|
||||
LL | enum Ref2<'a, T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | Ref2Variant1,
|
||||
LL | Ref2Variant2(isize, RequireOutlives<'a, T>),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -31,7 +31,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:35:1
|
||||
|
|
||||
LL | enum RefDouble<'a, 'b, T> {
|
||||
| ^ - help: consider adding an explicit lifetime bound `T: 'b`...
|
||||
| ^ - help: consider adding an explicit lifetime bound...: `T: 'b`
|
||||
| _|
|
||||
| |
|
||||
LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>)
|
||||
@ -52,7 +52,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:36:23
|
||||
|
|
||||
LL | enum RefDouble<'a, 'b, T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'b`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'b`
|
||||
LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -2,7 +2,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-implied-bounds-projection-gap-1.rs:16:10
|
||||
|
|
||||
LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo)
|
||||
| -- help: consider adding an explicit lifetime bound `T: 'x`...
|
||||
| -- help: consider adding an explicit lifetime bound...: `T: 'x +`
|
||||
LL | {
|
||||
LL | wf::<&'x T>();
|
||||
| ^^^^^
|
||||
|
@ -2,7 +2,7 @@ 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) {
|
||||
| - help: consider adding an explicit lifetime bound `A: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `A: 'a`
|
||||
LL | check_bound(x, a)
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ 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) {
|
||||
| -- help: consider adding an explicit lifetime bound `A: 'a`...
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'a +`
|
||||
LL | check_bound(x, a)
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/dont-infer-static.rs:8:5
|
||||
|
|
||||
LL | struct Foo<U> {
|
||||
| - help: consider adding an explicit lifetime bound `U: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `U: 'static`
|
||||
LL | bar: Bar<U>
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
|
@ -2,7 +2,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:18:18
|
||||
|
|
||||
LL | enum Ref1<'a, T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | Ref1Variant1(RequireOutlives<'a, T>)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:23:25
|
||||
|
|
||||
LL | enum Ref2<'a, T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | Ref2Variant1,
|
||||
LL | Ref2Variant2(isize, RequireOutlives<'a, T>),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -31,7 +31,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:35:1
|
||||
|
|
||||
LL | enum RefDouble<'a, 'b, T> {
|
||||
| ^ - help: consider adding an explicit lifetime bound `T: 'b`...
|
||||
| ^ - help: consider adding an explicit lifetime bound...: `T: 'b`
|
||||
| _|
|
||||
| |
|
||||
LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>)
|
||||
@ -52,7 +52,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-enum-not-wf.rs:36:23
|
||||
|
|
||||
LL | enum RefDouble<'a, 'b, T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'b`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'b`
|
||||
LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -2,7 +2,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-struct-not-wf.rs:13:5
|
||||
|
|
||||
LL | impl<'a, T> Trait<'a, T> for usize {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | type Out = &'a T;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-struct-not-wf.rs:21:5
|
||||
|
|
||||
LL | impl<'a, T> Trait<'a, T> for u32 {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | type Out = RefOk<'a, T>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn foo(d: impl Debug + 'static) {
|
||||
//~^ HELP consider adding an explicit lifetime bound `'static` to `impl Debug`
|
||||
//~^ HELP consider adding an explicit lifetime bound...
|
||||
bar(d);
|
||||
//~^ ERROR the parameter type `impl Debug` may not live long enough
|
||||
//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn foo(d: impl Debug) {
|
||||
//~^ HELP consider adding an explicit lifetime bound `'static` to `impl Debug`
|
||||
//~^ HELP consider adding an explicit lifetime bound...
|
||||
bar(d);
|
||||
//~^ ERROR the parameter type `impl Debug` may not live long enough
|
||||
//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds
|
||||
|
@ -1,6 +1,9 @@
|
||||
error[E0310]: the parameter type `impl Debug` may not live long enough
|
||||
--> $DIR/suggest-impl-trait-lifetime.rs:7:5
|
||||
|
|
||||
LL | fn foo(d: impl Debug) {
|
||||
| ---------- help: consider adding an explicit lifetime bound...: `impl Debug + 'static`
|
||||
LL |
|
||||
LL | bar(d);
|
||||
| ^^^
|
||||
|
|
||||
@ -9,10 +12,6 @@ note: ...so that the type `impl Debug` will meet its required lifetime bounds
|
||||
|
|
||||
LL | bar(d);
|
||||
| ^^^
|
||||
help: consider adding an explicit lifetime bound `'static` to `impl Debug`...
|
||||
|
|
||||
LL | fn foo(d: impl Debug + 'static) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -25,7 +25,7 @@ LL | type WrongGeneric<T> = impl 'static;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
|
||||
note: ...so that the type `T` will meet its required lifetime bounds
|
||||
--> $DIR/generic_type_does_not_live_long_enough.rs:9:1
|
||||
|
@ -2,7 +2,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/wf-impl-associated-type-region.rs:10:5
|
||||
|
|
||||
LL | impl<'a, T> Foo<'a> for T {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | type Bar = &'a T;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/wf-in-fn-type-static.rs:13:5
|
||||
|
|
||||
LL | struct Foo<T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // needs T: 'static
|
||||
LL | x: fn() -> &'static T
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -17,7 +17,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/wf-in-fn-type-static.rs:18:5
|
||||
|
|
||||
LL | struct Bar<T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // needs T: Copy
|
||||
LL | x: fn(&'static T)
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/wf-in-obj-type-static.rs:14:5
|
||||
|
|
||||
LL | struct Foo<T> {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | // needs T: 'static
|
||||
LL | x: dyn Object<&'static T>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,7 +2,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:5
|
||||
|
|
||||
LL | impl<'a, T> Trait<'a, T> for usize {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | type Out = &'a fn(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
@ -16,7 +16,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5
|
||||
|
|
||||
LL | impl<'a, T> Trait<'a, T> for u32 {
|
||||
| - help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | type Out = &'a dyn Baz<T>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
Loading…
x
Reference in New Issue
Block a user