diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index b809b40a39908..552d9d1d3f9de 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -316,13 +316,16 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let type_test_span = type_test.span; if let Some(lower_bound_region) = lower_bound_region { - let generic_ty = type_test.generic_kind.to_ty(self.infcx.tcx); + let generic_ty = self.regioncx.name_regions( + self.infcx.tcx, + type_test.generic_kind.to_ty(self.infcx.tcx), + ); let origin = RelateParamBound(type_test_span, generic_ty, None); self.buffer_error(self.infcx.err_ctxt().construct_generic_bound_failure( self.body.source.def_id().expect_local(), type_test_span, Some(origin), - type_test.generic_kind, + self.regioncx.name_regions(self.infcx.tcx, type_test.generic_kind), lower_bound_region, )); } else { diff --git a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index f8dbe08af6166..34498f68f6795 100644 --- a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -23,16 +23,20 @@ LL | | T: Anything<'b, 'c>, | = note: defining type: no_relationships_late::<'?1, '?2, T> -error[E0309]: the associated type `>::AssocType` may not live long enough +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:38:39 | LL | fn no_relationships_late<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) - | -- the associated type `>::AssocType` must be valid for the lifetime `'a` as defined here... + | -- the associated type `>::AssocType` must be valid for the lifetime `'a` as defined here... ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^ ...so that the type `>::AssocType` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ ...so that the type `>::AssocType` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL - T: Anything<'b, 'c>, +LL + T: Anything<'b, 'c>, >::AssocType: 'a | - = help: consider adding an explicit lifetime bound `>::AssocType: 'a`... note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 @@ -59,16 +63,20 @@ LL | | 'a: 'a, | = note: defining type: no_relationships_early::<'?1, '?2, '?3, T> -error[E0309]: the associated type `>::AssocType` may not live long enough +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:48:39 | LL | fn no_relationships_early<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) - | -- the associated type `>::AssocType` must be valid for the lifetime `'a` as defined here... + | -- the associated type `>::AssocType` must be valid for the lifetime `'a` as defined here... ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^ ...so that the type `>::AssocType` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ ...so that the type `>::AssocType` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL - 'a: 'a, +LL + 'a: 'a, >::AssocType: 'a | - = help: consider adding an explicit lifetime bound `>::AssocType: 'a`... note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr index f8ecc0c68267f..a53c01e506e50 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr +++ b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr @@ -1,13 +1,17 @@ -error[E0309]: the associated type `>::Output` may not live long enough +error[E0309]: the associated type `>::Output` may not live long enough --> $DIR/projection-where-clause-env-wrong-bound.rs:15:5 | LL | fn foo1<'a, 'b, T>() -> &'a () - | -- the associated type `>::Output` must be valid for the lifetime `'a` as defined here... + | -- the associated type `>::Output` must be valid for the lifetime `'a` as defined here... ... LL | bar::() - | ^^^^^^^^^^^^^^^^ ...so that the type `>::Output` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ ...so that the type `>::Output` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL - >::Output: 'b, +LL + >::Output: 'b, >::Output: 'a | - = help: consider adding an explicit lifetime bound `>::Output: 'a`... error: aborting due to 1 previous error diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs index 987148dcefb0c..9e3590ca71545 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs +++ b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs @@ -12,7 +12,7 @@ where >::Output: 'a, { bar::<>::Output>() - //~^ ERROR the associated type `>::Output` may not live long enough + //~^ ERROR the associated type `>::Output` may not live long enough } fn bar<'a, T>() -> &'a () diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr index 13ad665e2615e..36a0f40246e8a 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr +++ b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr @@ -1,13 +1,17 @@ -error[E0309]: the associated type `>::Output` may not live long enough +error[E0309]: the associated type `>::Output` may not live long enough --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 | LL | fn foo1<'a, 'b, T>() -> &'a () - | -- the associated type `>::Output` must be valid for the lifetime `'a` as defined here... + | -- the associated type `>::Output` must be valid for the lifetime `'a` as defined here... ... LL | bar::<>::Output>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `>::Output` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `>::Output` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL - >::Output: 'a, +LL + >::Output: 'a, >::Output: 'a | - = help: consider adding an explicit lifetime bound `>::Output: 'a`... error: aborting due to 1 previous error