about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-07 08:50:12 +0000
committerbors <bors@rust-lang.org>2018-08-07 08:50:12 +0000
commit9e472c2acea2b7714985390abb6b7fe420a4f346 (patch)
tree0c62c12671d80d97bfece58c1f6640266a110054
parent11a902431b8e66da8486b3b9a2d8527746c6ab1a (diff)
parent49b0a1e073f708edb172cba50d8cb352204cfdc4 (diff)
downloadrust-9e472c2acea2b7714985390abb6b7fe420a4f346.tar.gz
rust-9e472c2acea2b7714985390abb6b7fe420a4f346.zip
Auto merge of #52450 - PramodBisht:issue/52413, r=estebank
Closes #52413: Provide structured suggestion instead of label

Provide structured suggestion instead of label
r? @estebank
-rw-r--r--src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs10
-rw-r--r--src/librustc/infer/error_reporting/nice_region_error/util.rs7
-rw-r--r--src/test/ui/in-band-lifetimes/mismatched.nll.stderr6
-rw-r--r--src/test/ui/in-band-lifetimes/mismatched.stderr6
-rw-r--r--src/test/ui/in-band-lifetimes/mismatched_trait.nll.stderr2
-rw-r--r--src/test/ui/in-band-lifetimes/mismatched_trait.stderr2
-rw-r--r--src/test/ui/issue-13058.stderr2
-rw-r--r--src/test/ui/issue-14285.nll.stderr2
-rw-r--r--src/test/ui/issue-14285.stderr2
-rw-r--r--src/test/ui/issue-15034.nll.stderr2
-rw-r--r--src/test/ui/issue-15034.stderr2
-rw-r--r--src/test/ui/issue-16922.nll.stderr2
-rw-r--r--src/test/ui/issue-16922.stderr2
-rw-r--r--src/test/ui/issue-3154.nll.stderr2
-rw-r--r--src/test/ui/issue-3154.stderr2
-rw-r--r--src/test/ui/issue-40288-2.nll.stderr4
-rw-r--r--src/test/ui/issue-40288-2.stderr4
-rw-r--r--src/test/ui/issue-46983.stderr2
-rw-r--r--src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr7
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr2
-rw-r--r--src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr2
-rw-r--r--src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr2
-rw-r--r--src/test/ui/nll/guarantor-issue-46974.stderr2
-rw-r--r--src/test/ui/nll/ty-outlives/impl-trait-captures.stderr6
40 files changed, 62 insertions, 52 deletions
diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
index 51abfa2505a..ca71b0aeed9 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
@@ -65,9 +65,10 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
             region_info
         );
 
-        let (arg, new_ty, br, is_first, scope_def_id, is_impl_item) = (
+        let (arg, new_ty, new_ty_span, br, is_first, scope_def_id, is_impl_item) = (
             anon_arg_info.arg,
             anon_arg_info.arg_ty,
+            anon_arg_info.arg_ty_span,
             anon_arg_info.bound_region,
             anon_arg_info.is_first,
             region_info.def_id,
@@ -110,9 +111,10 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
             E0621,
             "explicit lifetime required in {}",
             error_var
-        ).span_label(
-            arg.pat.span,
-            format!("consider changing {} to `{}`", span_label_var, new_ty),
+        ).span_suggestion(
+            new_ty_span,
+            &format!("add explicit lifetime `{}` to {}", named, span_label_var),
+            new_ty.to_string()
         )
             .span_label(span, format!("lifetime `{}` required", named))
             .emit();
diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs
index 1cc2b9d50b9..28320ce3ad1 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/util.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs
@@ -27,6 +27,8 @@ pub(super) struct AnonymousArgInfo<'tcx> {
     pub arg_ty: Ty<'tcx>,
     // the ty::BoundRegion corresponding to the anonymous region
     pub bound_region: ty::BoundRegion,
+    // arg_ty_span contains span of argument type
+    pub arg_ty_span : Span,
     // corresponds to id the argument is the first parameter
     // in the declaration
     pub is_first: bool,
@@ -74,12 +76,16 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
         if let Some(node_id) = hir.as_local_node_id(id) {
             if let Some(body_id) = hir.maybe_body_owned_by(node_id) {
                 let body = hir.body(body_id);
+                let owner_id = hir.body_owner(body_id);
+                let fn_decl = hir.fn_decl(owner_id).unwrap();
                 if let Some(tables) = self.tables {
                     body.arguments
                         .iter()
                         .enumerate()
                         .filter_map(|(index, arg)| {
                             // May return None; sometimes the tables are not yet populated.
+                            let ty_hir_id = fn_decl.inputs[index].hir_id;
+                            let arg_ty_span = hir.span(hir.hir_to_node_id(ty_hir_id));
                             let ty = tables.node_id_to_type_opt(arg.hir_id)?;
                             let mut found_anon_region = false;
                             let new_arg_ty = self.tcx.fold_regions(&ty, &mut false, |r, _| {
@@ -95,6 +101,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
                                 Some(AnonymousArgInfo {
                                     arg: arg,
                                     arg_ty: new_arg_ty,
+                                    arg_ty_span : arg_ty_span,
                                     bound_region: bound_region,
                                     is_first: is_first,
                                 })
diff --git a/src/test/ui/in-band-lifetimes/mismatched.nll.stderr b/src/test/ui/in-band-lifetimes/mismatched.nll.stderr
index c923e6610ce..1470783c206 100644
--- a/src/test/ui/in-band-lifetimes/mismatched.nll.stderr
+++ b/src/test/ui/in-band-lifetimes/mismatched.nll.stderr
@@ -14,9 +14,9 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/mismatched.rs:14:42
    |
 LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
-   |                    -                     ^ lifetime `'a` required
-   |                    |
-   |                    consider changing the type of `y` to `&'a u32`
+   |                       ----               ^ lifetime `'a` required
+   |                       |
+   |                       help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
 
 error: unsatisfied lifetime constraints
   --> $DIR/mismatched.rs:16:46
diff --git a/src/test/ui/in-band-lifetimes/mismatched.stderr b/src/test/ui/in-band-lifetimes/mismatched.stderr
index d2748b2da4b..ed932a97ba4 100644
--- a/src/test/ui/in-band-lifetimes/mismatched.stderr
+++ b/src/test/ui/in-band-lifetimes/mismatched.stderr
@@ -2,9 +2,9 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/mismatched.rs:14:42
    |
 LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
-   |                    -                     ^ lifetime `'a` required
-   |                    |
-   |                    consider changing the type of `y` to `&'a u32`
+   |                       ----               ^ lifetime `'a` required
+   |                       |
+   |                       help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
 
 error[E0623]: lifetime mismatch
   --> $DIR/mismatched.rs:16:46
diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait.nll.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait.nll.stderr
index 886e3834d1d..a01f3219dc5 100644
--- a/src/test/ui/in-band-lifetimes/mismatched_trait.nll.stderr
+++ b/src/test/ui/in-band-lifetimes/mismatched_trait.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/mismatched_trait.rs:16:9
    |
 LL |     fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
-   |                               - consider changing the type of `y` to `&'a u32`
+   |                                  ---- help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
 LL |         y //~ ERROR explicit lifetime required
    |         ^ lifetime `'a` required
 
diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait.stderr
index 71b46f6d4d6..745b82c20b4 100644
--- a/src/test/ui/in-band-lifetimes/mismatched_trait.stderr
+++ b/src/test/ui/in-band-lifetimes/mismatched_trait.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/mismatched_trait.rs:16:9
    |
 LL |     fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
-   |                               - consider changing the type of `y` to `&'a u32`
+   |                                  ---- help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
 LL |         y //~ ERROR explicit lifetime required
    |         ^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-13058.stderr b/src/test/ui/issue-13058.stderr
index cef5f5ae475..5e8319d26ad 100644
--- a/src/test/ui/issue-13058.stderr
+++ b/src/test/ui/issue-13058.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `cont`
   --> $DIR/issue-13058.rs:24:26
    |
 LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
-   |                                                               ---- consider changing the type of `cont` to `&'r T`
+   |                                                                     -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T`
 LL | {
 LL |     let cont_iter = cont.iter();
    |                          ^^^^ lifetime `'r` required
diff --git a/src/test/ui/issue-14285.nll.stderr b/src/test/ui/issue-14285.nll.stderr
index 440365cae3e..c95d540b25c 100644
--- a/src/test/ui/issue-14285.nll.stderr
+++ b/src/test/ui/issue-14285.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `a`
   --> $DIR/issue-14285.rs:22:7
    |
 LL | fn foo<'a>(a: &Foo) -> B<'a> {
-   |            - consider changing the type of `a` to `&'a (dyn Foo + 'a)`
+   |               ---- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)`
 LL |     B(a)    //~ ERROR 22:5: 22:9: explicit lifetime required in the type of `a` [E0621]
    |       ^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-14285.stderr b/src/test/ui/issue-14285.stderr
index b5ab7bdb9d1..52163f81b7b 100644
--- a/src/test/ui/issue-14285.stderr
+++ b/src/test/ui/issue-14285.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `a`
   --> $DIR/issue-14285.rs:22:5
    |
 LL | fn foo<'a>(a: &Foo) -> B<'a> {
-   |            - consider changing the type of `a` to `&'a (dyn Foo + 'a)`
+   |               ---- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)`
 LL |     B(a)    //~ ERROR 22:5: 22:9: explicit lifetime required in the type of `a` [E0621]
    |     ^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-15034.nll.stderr b/src/test/ui/issue-15034.nll.stderr
index 19fe83f8f6c..4c8482630c5 100644
--- a/src/test/ui/issue-15034.nll.stderr
+++ b/src/test/ui/issue-15034.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `lexer`
   --> $DIR/issue-15034.rs:27:25
    |
 LL |     pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
-   |                ----- consider changing the type of `lexer` to `&'a mut Lexer<'a>`
+   |                       ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
 LL |         Parser { lexer: lexer }
    |                         ^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-15034.stderr b/src/test/ui/issue-15034.stderr
index 3bbf4235a29..c87bec00d95 100644
--- a/src/test/ui/issue-15034.stderr
+++ b/src/test/ui/issue-15034.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `lexer`
   --> $DIR/issue-15034.rs:27:25
    |
 LL |     pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
-   |                ----- consider changing the type of `lexer` to `&'a mut Lexer<'a>`
+   |                       ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
 LL |         Parser { lexer: lexer }
    |                         ^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-16922.nll.stderr b/src/test/ui/issue-16922.nll.stderr
index 902baaf579f..1bd26faedaa 100644
--- a/src/test/ui/issue-16922.nll.stderr
+++ b/src/test/ui/issue-16922.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `value`
   --> $DIR/issue-16922.rs:14:5
    |
 LL | fn foo<T: Any>(value: &T) -> Box<Any> {
-   |                ----- consider changing the type of `value` to `&'static T`
+   |                       -- help: add explicit lifetime `'static` to the type of `value`: `&'static T`
 LL |     Box::new(value) as Box<Any>
    |     ^^^^^^^^^^^^^^^ lifetime `'static` required
 
diff --git a/src/test/ui/issue-16922.stderr b/src/test/ui/issue-16922.stderr
index cf81d4b4d08..e70869eb183 100644
--- a/src/test/ui/issue-16922.stderr
+++ b/src/test/ui/issue-16922.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `value`
   --> $DIR/issue-16922.rs:14:5
    |
 LL | fn foo<T: Any>(value: &T) -> Box<Any> {
-   |                ----- consider changing the type of `value` to `&'static T`
+   |                       -- help: add explicit lifetime `'static` to the type of `value`: `&'static T`
 LL |     Box::new(value) as Box<Any>
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
 
diff --git a/src/test/ui/issue-3154.nll.stderr b/src/test/ui/issue-3154.nll.stderr
index 4420f9dcae4..91010bd3209 100644
--- a/src/test/ui/issue-3154.nll.stderr
+++ b/src/test/ui/issue-3154.nll.stderr
@@ -14,7 +14,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/issue-3154.rs:16:15
    |
 LL | fn thing<'a,Q>(x: &Q) -> thing<'a,Q> {
-   |                - consider changing the type of `x` to `&'a Q`
+   |                   -- help: add explicit lifetime `'a` to the type of `x`: `&'a Q`
 LL |     thing{ x: x } //~ ERROR 16:5: 16:18: explicit lifetime required in the type of `x` [E0621]
    |               ^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-3154.stderr b/src/test/ui/issue-3154.stderr
index cc0cfd768c4..01299d74808 100644
--- a/src/test/ui/issue-3154.stderr
+++ b/src/test/ui/issue-3154.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/issue-3154.rs:16:5
    |
 LL | fn thing<'a,Q>(x: &Q) -> thing<'a,Q> {
-   |                - consider changing the type of `x` to `&'a Q`
+   |                   -- help: add explicit lifetime `'a` to the type of `x`: `&'a Q`
 LL |     thing{ x: x } //~ ERROR 16:5: 16:18: explicit lifetime required in the type of `x` [E0621]
    |     ^^^^^^^^^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/issue-40288-2.nll.stderr b/src/test/ui/issue-40288-2.nll.stderr
index 1d2b2660342..dcc9e0a8a65 100644
--- a/src/test/ui/issue-40288-2.nll.stderr
+++ b/src/test/ui/issue-40288-2.nll.stderr
@@ -38,7 +38,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/issue-40288-2.rs:17:9
    |
 LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
-   |                                                      - consider changing the type of `y` to `&'a T`
+   |                                                         -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
 ...
 LL |         slice[0] = y;
    |         ^^^^^^^^^^^^ lifetime `'a` required
@@ -47,7 +47,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/issue-40288-2.rs:32:9
    |
 LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
-   |                                                       - consider changing the type of `y` to `&'a T`
+   |                                                          -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
 ...
 LL |         dst.head = y;
    |         ^^^^^^^^^^^^ lifetime `'a` required
diff --git a/src/test/ui/issue-40288-2.stderr b/src/test/ui/issue-40288-2.stderr
index d2313ef89a7..fd0b4c01636 100644
--- a/src/test/ui/issue-40288-2.stderr
+++ b/src/test/ui/issue-40288-2.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/issue-40288-2.rs:19:5
    |
 LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
-   |                                                      - consider changing the type of `y` to `&'a T`
+   |                                                         -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
 ...
 LL |     out[0]
    |     ^^^^^^ lifetime `'a` required
@@ -11,7 +11,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/issue-40288-2.rs:34:5
    |
 LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
-   |                                                       - consider changing the type of `y` to `&'a T`
+   |                                                          -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
 ...
 LL |     out.head
    |     ^^^^^^^^ lifetime `'a` required
diff --git a/src/test/ui/issue-46983.stderr b/src/test/ui/issue-46983.stderr
index 31aeebd5a72..c4f2b3eba7d 100644
--- a/src/test/ui/issue-46983.stderr
+++ b/src/test/ui/issue-46983.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/issue-46983.rs:14:5
    |
 LL | fn foo(x: &u32) -> &'static u32 {
-   |        - consider changing the type of `x` to `&'static u32`
+   |           ---- help: add explicit lifetime `'static` to the type of `x`: `&'static u32`
 LL |     &*x
    |     ^^^ lifetime `'static` required
 
diff --git a/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.nll.stderr b/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.nll.stderr
index d422a63bcad..89313f898d5 100644
--- a/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.nll.stderr
+++ b/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/42701_one_named_and_one_anonymous.rs:16:5
    |
 LL |   fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
-   |                           - consider changing the type of `x` to `&'a i32`
+   |                              ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL | /     if true {
 LL | |         let p: &i32 = &a.field;
 LL | |         &*p
diff --git a/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.stderr b/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.stderr
index 87cb1748913..b886450336d 100644
--- a/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.stderr
+++ b/src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/42701_one_named_and_one_anonymous.rs:20:9
    |
 LL | fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
-   |                         - consider changing the type of `x` to `&'a i32`
+   |                            ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 ...
 LL |         &*x //~ ERROR explicit lifetime
    |         ^^^ lifetime `'a` required
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.nll.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.nll.stderr
index e5b001def56..3976cb30426 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `other`
   --> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:18:15
    |
 LL |     fn bar(&self, other: Foo) -> Foo<'a> {
-   |                   ----- consider changing the type of `other` to `Foo<'a>`
+   |                          --- help: add explicit lifetime `'a` to the type of `other`: `Foo<'a>`
 LL |         match *self {
    |               ^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr
index 29163361e23..5847f755b3c 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `other`
   --> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:21:21
    |
 LL |     fn bar(&self, other: Foo) -> Foo<'a> {
-   |                   ----- consider changing the type of `other` to `Foo<'a>`
+   |                          --- help: add explicit lifetime `'a` to the type of `other`: `Foo<'a>`
 ...
 LL |                     other //~ ERROR explicit lifetime
    |                     ^^^^^ lifetime `'a` required
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.nll.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.nll.stderr
index e1dfeb0ac6a..00eff2fe3ae 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:8
    |
 LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
-   |            - consider changing the type of `x` to `&'a i32`
+   |               ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL |     if x > y { x } else { y } //~ ERROR explicit lifetime
    |        ^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
index e18156179a2..a4e1fe5e183 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:16
    |
 LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
-   |            - consider changing the type of `x` to `&'a i32`
+   |               ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL |     if x > y { x } else { y } //~ ERROR explicit lifetime
    |                ^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr
index 4d9517eca60..a3b46aa04a6 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr
@@ -8,10 +8,9 @@ error[E0621]: explicit lifetime required in parameter type
   --> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:16
    |
 LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
-   |            ----^-
-   |            |   |
-   |            |   lifetime `'a` required
-   |            consider changing type to `(&'a i32, &'a i32)`
+   |                ^   --------------- help: add explicit lifetime `'a` to type: `(&'a i32, &'a i32)`
+   |                |
+   |                lifetime `'a` required
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
index f208fb57f5b..a260c7bf7e9 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in parameter type
   --> $DIR/ex1-return-one-existing-name-if-else-3.rs:12:27
    |
 LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
-   |            ------ consider changing type to `(&'a i32, &'a i32)`
+   |                    --------------- help: add explicit lifetime `'a` to type: `(&'a i32, &'a i32)`
 LL |     if x > y { x } else { y } //~ ERROR explicit lifetime
    |                           ^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.nll.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.nll.stderr
index e264b3428c9..465b33be2d0 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:7
    |
 LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
-   |            - consider changing the type of `x` to `&'a i32`
+   |               ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL |    if x > y { x } else { y } //~ ERROR explicit lifetime
    |       ^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
index 7604b9a9017..8eac8761bd4 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:15
    |
 LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
-   |            - consider changing the type of `x` to `&'a i32`
+   |               ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL |    if x > y { x } else { y } //~ ERROR explicit lifetime
    |               ^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.nll.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.nll.stderr
index 6119f3c5605..a62d7cc5a6f 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:5
    |
 LL |   fn foo<'a>(&'a self, x: &i32) -> &i32 {
-   |                        - consider changing the type of `x` to `&'a i32`
+   |                           ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL | 
 LL |     if true { &self.field } else { x } //~ ERROR explicit lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
index 83c6ff19867..0ae98aeb843 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:36
    |
 LL |   fn foo<'a>(&'a self, x: &i32) -> &i32 {
-   |                        - consider changing the type of `x` to `&'a i32`
+   |                           ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
 LL | 
 LL |     if true { &self.field } else { x } //~ ERROR explicit lifetime
    |                                    ^ lifetime `'a` required
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.nll.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.nll.stderr
index 5e49e4ec4a9..93f8254f825 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex1-return-one-existing-name-if-else.rs:12:8
    |
 LL | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
-   |                        - consider changing the type of `y` to `&'a i32`
+   |                           ---- help: add explicit lifetime `'a` to the type of `y`: `&'a i32`
 LL |     if x > y { x } else { y } //~ ERROR explicit lifetime
    |        ^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
index 9893eee77e8..b68b90e77de 100644
--- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
+++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex1-return-one-existing-name-if-else.rs:12:27
    |
 LL | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
-   |                        - consider changing the type of `y` to `&'a i32`
+   |                           ---- help: add explicit lifetime `'a` to the type of `y`: `&'a i32`
 LL |     if x > y { x } else { y } //~ ERROR explicit lifetime
    |                           ^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr
index 087c9eb389b..a5fa83266a3 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex2a-push-one-existing-name-2.rs:16:5
    |
 LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
-   |            - consider changing the type of `x` to `Ref<'a, i32>`
+   |               -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
 LL |     y.push(x); //~ ERROR explicit lifetime
    |     ^^^^^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr
index 5c9b7666de6..6f0a5179d6b 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex2a-push-one-existing-name-2.rs:16:12
    |
 LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
-   |            - consider changing the type of `x` to `Ref<'a, i32>`
+   |               -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
 LL |     y.push(x); //~ ERROR explicit lifetime
    |            ^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr
index 4cfb76f85f2..a8286ba2952 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex2a-push-one-existing-name-early-bound.rs:17:12
    |
 LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T)
-   |                                       - consider changing the type of `y` to `&'a T`
+   |                                          -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
 ...
 LL |     x.push(y); //~ ERROR explicit lifetime required
    |            ^ lifetime `'a` required
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr
index 80192af2217..294a9106619 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex2a-push-one-existing-name.rs:16:5
    |
 LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
-   |                                       - consider changing the type of `y` to `Ref<'a, i32>`
+   |                                          -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>`
 LL |     x.push(y); //~ ERROR explicit lifetime
    |     ^^^^^^^^^ lifetime `'a` required
 
diff --git a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
index ede76bca2ba..ebe465aa581 100644
--- a/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
+++ b/src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
   --> $DIR/ex2a-push-one-existing-name.rs:16:12
    |
 LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
-   |                                       - consider changing the type of `y` to `Ref<'a, i32>`
+   |                                          -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>`
 LL |     x.push(y); //~ ERROR explicit lifetime
    |            ^ lifetime `'a` required
 
diff --git a/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr b/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
index a823e62d3b8..a019a7224c6 100644
--- a/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
+++ b/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/region-lbr-anon-does-not-outlive-static.rs:19:5
    |
 LL | fn foo(x: &u32) -> &'static u32 {
-   |        - consider changing the type of `x` to `&ReStatic u32`
+   |           ---- help: add explicit lifetime `ReStatic` to the type of `x`: `&ReStatic u32`
 LL |     &*x
    |     ^^^ lifetime `ReStatic` required
 
diff --git a/src/test/ui/nll/guarantor-issue-46974.stderr b/src/test/ui/nll/guarantor-issue-46974.stderr
index 3cb20cc975f..6fc48129986 100644
--- a/src/test/ui/nll/guarantor-issue-46974.stderr
+++ b/src/test/ui/nll/guarantor-issue-46974.stderr
@@ -13,7 +13,7 @@ error[E0621]: explicit lifetime required in the type of `s`
   --> $DIR/guarantor-issue-46974.rs:25:5
    |
 LL | fn bar(s: &Box<(i32,)>) -> &'static i32 {
-   |        - consider changing the type of `s` to `&'static std::boxed::Box<(i32,)>`
+   |           ------------ help: add explicit lifetime `'static` to the type of `s`: `&'static std::boxed::Box<(i32,)>`
 LL |     // FIXME(#46983): error message should be better
 LL |     &s.0 //~ ERROR explicit lifetime required in the type of `s` [E0621]
    |     ^^^^ lifetime `'static` required
diff --git a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
index f836960a28c..a4f0e53386f 100644
--- a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
+++ b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
@@ -7,10 +7,12 @@ LL |     x
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/impl-trait-captures.rs:21:5
    |
-LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
-   |               - consider changing the type of `x` to `&ReEarlyBound(0, 'a) T`
 LL |     x
    |     ^ lifetime `ReEarlyBound(0, 'a)` required
+help: add explicit lifetime `ReEarlyBound(0, 'a)` to the type of `x`
+   |
+LL | fn foo<'a, T>(x: &ReEarlyBound(0, 'a) T) -> impl Foo<'a> {
+   |                  ^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error