Auto merge of #68545 - estebank:verbose-bound-display, r=petrochenkov
Use better bound names in `-Zverbose` mode r? @petrochenkov as per https://github.com/rust-lang/rust/pull/67951/files#r365524015
This commit is contained in:
commit
698fcd38fa
@ -1778,8 +1778,8 @@ fn binding_suggestion<'tcx, S: fmt::Display>(
|
||||
}
|
||||
|
||||
let mut err = match *sub {
|
||||
ty::ReEarlyBound(_)
|
||||
| ty::ReFree(ty::FreeRegion { bound_region: ty::BrNamed(..), .. }) => {
|
||||
ty::ReEarlyBound(ty::EarlyBoundRegion { name, .. })
|
||||
| ty::ReFree(ty::FreeRegion { bound_region: ty::BrNamed(_, name), .. }) => {
|
||||
// Does the required lifetime have a nice name we can print?
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
@ -1788,7 +1788,11 @@ fn binding_suggestion<'tcx, S: fmt::Display>(
|
||||
"{} may not live long enough",
|
||||
labeled_user_string
|
||||
);
|
||||
binding_suggestion(&mut err, type_param_span, bound_kind, sub);
|
||||
// Explicitely use the name instead of `sub`'s `Display` impl. The `Display` impl
|
||||
// for the bound is not suitable for suggestions when `-Zverbose` is set because it
|
||||
// uses `Debug` output, so we handle it specially here so that suggestions are
|
||||
// always correct.
|
||||
binding_suggestion(&mut err, type_param_span, bound_kind, name);
|
||||
err
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ LL | | require(value);
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/impl-trait-outlives.rs:22:42
|
||||
@ -12,7 +12,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -31,7 +31,7 @@ error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not liv
|
||||
LL | with_signature(x, |mut y| Box::new(y.next()))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: 'a`...
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-no-regions-closure.rs:34:23
|
||||
@ -92,7 +92,7 @@ error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not liv
|
||||
LL | with_signature(x, |mut y| Box::new(y.next()))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: 'a`...
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-no-regions-closure.rs:52:23
|
||||
|
@ -4,7 +4,7 @@ error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not liv
|
||||
LL | Box::new(x.next())
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: 'a`...
|
||||
|
||||
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
|
||||
--> $DIR/projection-no-regions-fn.rs:28:5
|
||||
@ -12,7 +12,7 @@ error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not liv
|
||||
LL | Box::new(x.next())
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: 'a`...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -33,7 +33,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReFree(DefId(0:15 ~ projection_one_region_closure[317d]::no_relationships_late[0]), BrNamed(DefId(0:16 ~ projection_one_region_closure[317d]::no_relationships_late[0]::'a[0]), 'a))`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/projection-one-region-closure.rs:45:39
|
||||
@ -82,7 +82,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/projection-one-region-closure.rs:56:39
|
||||
|
@ -32,7 +32,7 @@ error[E0309]: the associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may
|
||||
LL | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Anything<'_#5r, '_#6r>>::AssocType: ReFree(DefId(0:17 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(DefId(0:18 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]::'a[0]), 'a))`...
|
||||
= help: consider adding an explicit lifetime bound `<T as Anything<'_#5r, '_#6r>>::AssocType: 'a`...
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-two-region-trait-bound-closure.rs:48:29
|
||||
@ -67,7 +67,7 @@ error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may
|
||||
LL | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: 'a`...
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-two-region-trait-bound-closure.rs:61:29
|
||||
|
@ -53,7 +53,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | twice(cell, value, |a, b| invoke(a, b));
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReFree(DefId(0:12 ~ ty_param_closure_approximate_lower_bound[317d]::generic_fail[0]), BrNamed(DefId(0:13 ~ ty_param_closure_approximate_lower_bound[317d]::generic_fail[0]::'a[0]), 'a))`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -31,7 +31,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | with_signature(x, |y| y)
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/ty-param-closure-outlives-from-return-type.rs:41:5
|
||||
@ -39,7 +39,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
||||
LL | x
|
||||
| ^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -46,7 +46,7 @@ LL | | require(&x, &y)
|
||||
LL | | })
|
||||
| |_____^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReFree(DefId(0:11 ~ ty_param_closure_outlives_from_where_clause[317d]::no_region[0]), BrNamed(DefId(0:12 ~ ty_param_closure_outlives_from_where_clause[317d]::no_region[0]::'a[0]), 'a))`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26
|
||||
@ -126,7 +126,7 @@ LL | | require(&x, &y)
|
||||
LL | | })
|
||||
| |_____^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: ReFree(DefId(0:19 ~ ty_param_closure_outlives_from_where_clause[317d]::wrong_region[0]), BrNamed(DefId(0:20 ~ ty_param_closure_outlives_from_where_clause[317d]::wrong_region[0]::'a[0]), 'a))`...
|
||||
= help: consider adding an explicit lifetime bound `T: 'a`...
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26
|
||||
|
Loading…
Reference in New Issue
Block a user