diff --git a/src/librustc_infer/infer/error_reporting/mod.rs b/src/librustc_infer/infer/error_reporting/mod.rs index 77119b8618f17..1ed890962da58 100644 --- a/src/librustc_infer/infer/error_reporting/mod.rs +++ b/src/librustc_infer/infer/error_reporting/mod.rs @@ -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); } } diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr index 2fdb3836dd969..999a5839ba690 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr @@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough LL | impl 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 diff --git a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr index 689a3757343b1..fbc4e8abc42fd 100644 --- a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr +++ b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr @@ -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 { - | - help: consider adding an explicit lifetime bound `U: 'static`... + | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | bar: Bar | ^^^^^^^^^^^ | diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 7f92e709af556..cffa5ee8f1461 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -67,7 +67,7 @@ error[E0310]: the parameter type `T` may not live long enough LL | fn ty_param_wont_outlive_static(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 diff --git a/src/test/ui/impl-trait/type_parameters_captured.stderr b/src/test/ui/impl-trait/type_parameters_captured.stderr index 708b479ab17ef..34f0f7f1d731c 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.stderr @@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough LL | fn foo(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 diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr index 4e50064efb4ec..e60c461743c8f 100644 --- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr @@ -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 { - | - 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: 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>>(); | ^^^^^^^^^^^^^^^^ | @@ -45,7 +45,7 @@ error[E0309]: the parameter type `L` may not live long enough LL | fn baz<'a, L, M: X<&'a Nested>>() { | - ^^^^^^^^^^^^^^^^ | | - | 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` 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 Nested { - | - 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>>() { | ^^^^^^^^^^^^^^^^ | @@ -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: '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` does not outlive the data it points at --> $DIR/lifetime-doesnt-live-long-enough.rs:44:36 diff --git a/src/test/ui/regions/regions-close-object-into-object-5.stderr b/src/test/ui/regions/regions-close-object-into-object-5.stderr index 7c530cec7c31a..14727000b2c24 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.stderr @@ -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+'static>) -> Box { - | - 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 | ^^^^^^^^^^ @@ -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+'static>) -> Box { - | - 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 | ^^^^^^^^^^^^^^^^^^^^ @@ -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+'static>) -> Box { - | - 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 | ^ @@ -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+'static>) -> Box { - | - 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 | ^^^^^^ @@ -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+'static>) -> Box { - | - 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 | ^^^ @@ -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+'static>) -> Box { - | - 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 | ^^^ @@ -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+'static>) -> Box { - | - 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 | ^^^ diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr index 81534b7b770d0..ed9a604e717dd 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr @@ -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(v: A) -> Box { - | -- help: consider adding an explicit lifetime bound `A: 'static`... + | -- help: consider adding an explicit lifetime bound...: `A: 'static +` LL | box v as Box | ^^^^^ | @@ -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(v: A) -> Box { - | -- help: consider adding an explicit lifetime bound `A: 'static`... + | -- help: consider adding an explicit lifetime bound...: `A: 'static +` LL | box v as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -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 { - | -- help: consider adding an explicit lifetime bound `A: 'b`... + | -- help: consider adding an explicit lifetime bound...: `A: 'b +` LL | box v as Box | ^^^^^ | @@ -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 { - | -- help: consider adding an explicit lifetime bound `A: 'b`... + | -- help: consider adding an explicit lifetime bound...: `A: 'b +` LL | box v as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/src/test/ui/regions/regions-close-param-into-object.stderr b/src/test/ui/regions/regions-close-param-into-object.stderr index 7f2c646c12196..3b1a89d9ced77 100644 --- a/src/test/ui/regions/regions-close-param-into-object.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.stderr @@ -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(v: T) -> Box - | - 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(v: Box) -> Box - | - 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 - | - 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) -> Box - | - help: consider adding an explicit lifetime bound `T: 'a`... + | - help: consider adding an explicit lifetime bound...: `T: 'a` ... LL | Box::new(v) | ^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-enum-not-wf.stderr b/src/test/ui/regions/regions-enum-not-wf.stderr index 8701408566759..297fcb088d2bf 100644 --- a/src/test/ui/regions/regions-enum-not-wf.stderr +++ b/src/test/ui/regions/regions-enum-not-wf.stderr @@ -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>) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr index 7fbc1622c3a4f..2f1a4cea8e9ac 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr @@ -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>(); | ^^^^^ diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.stderr index 382d932e81add..a5a0ff52fac12 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait.stderr @@ -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) | ^^^^^^^^^^^ | diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr index b049d8a4ab3c3..c3cfc5a4d97c8 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr @@ -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 { - | - help: consider adding an explicit lifetime bound `U: 'static`... + | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | bar: Bar | ^^^^^^^^^^^ | diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr index 8701408566759..297fcb088d2bf 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr @@ -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>) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr index 825c1015c51d7..f6658891fa622 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -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>; | ^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed index 8592af1262e6f..589ee1a474ad6 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed @@ -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 diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs index c67d78ea4c73b..9a87129fbf28a 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs @@ -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 diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr index cba231d0e86e5..b6e6c0bbf32df 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr @@ -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 diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr index 5a7f9d74eba5b..22e2391f8380b 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr @@ -25,7 +25,7 @@ LL | type WrongGeneric = impl 'static; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | fn wrong_generic(t: T) -> WrongGeneric { - | - 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 diff --git a/src/test/ui/wf/wf-impl-associated-type-region.stderr b/src/test/ui/wf/wf-impl-associated-type-region.stderr index 9cc36025305f6..9942c80effe4b 100644 --- a/src/test/ui/wf/wf-impl-associated-type-region.stderr +++ b/src/test/ui/wf/wf-impl-associated-type-region.stderr @@ -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; | ^^^^^^^^^^^^^^^^^ | diff --git a/src/test/ui/wf/wf-in-fn-type-static.stderr b/src/test/ui/wf/wf-in-fn-type-static.stderr index 8952c78aacd71..7dc8f5a96611b 100644 --- a/src/test/ui/wf/wf-in-fn-type-static.stderr +++ b/src/test/ui/wf/wf-in-fn-type-static.stderr @@ -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 { - | - 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 { - | - 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) | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/wf/wf-in-obj-type-static.stderr b/src/test/ui/wf/wf-in-obj-type-static.stderr index c461da76a2576..32c3198d55be4 100644 --- a/src/test/ui/wf/wf-in-obj-type-static.stderr +++ b/src/test/ui/wf/wf-in-obj-type-static.stderr @@ -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 { - | - 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> | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index f1cf514e6b298..52786fb3bca96 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |