about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-01-27 12:49:12 -0800
committerEsteban Küber <esteban@kuber.com.ar>2020-02-05 10:32:01 -0800
commitfa4594196d2bcc265c4cdc1382d33366b3008341 (patch)
tree127b29b44fedca563996cb4f88bede542796713e /src
parent7e1464336a627ecb962f4eb38173fbfbfdd2ccf0 (diff)
downloadrust-fa4594196d2bcc265c4cdc1382d33366b3008341.tar.gz
rust-fa4594196d2bcc265c4cdc1382d33366b3008341.zip
Suggest `'r` instead of `'lifetime`
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/diagnostics.rs16
-rw-r--r--src/test/ui/error-codes/E0106.stderr16
-rw-r--r--src/test/ui/impl-header-lifetime-elision/assoc-type.stderr8
-rw-r--r--src/test/ui/in-band-lifetimes/issue-61124-anon-lifetime-in-struct-declaration.stderr4
-rw-r--r--src/test/ui/issues/issue-19707.stderr12
-rw-r--r--src/test/ui/issues/issue-26638.stderr4
-rw-r--r--src/test/ui/issues/issue-30255.stderr12
-rw-r--r--src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr8
-rw-r--r--src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.stderr4
-rw-r--r--src/test/ui/proc-macro/item-error.stderr4
-rw-r--r--src/test/ui/regions/regions-in-enums-anon.stderr4
-rw-r--r--src/test/ui/regions/regions-in-structs-anon.stderr4
-rw-r--r--src/test/ui/suggestions/fn-missing-lifetime-in-item.rs8
-rw-r--r--src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr53
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr2
-rw-r--r--src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr4
-rw-r--r--src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr4
-rw-r--r--src/test/ui/underscore-lifetime/in-struct.stderr8
-rw-r--r--src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr4
19 files changed, 120 insertions, 59 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 56fb6600405..8346dc3b854 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -1498,8 +1498,8 @@ crate fn add_missing_lifetime_specifiers_label(
                         msg = "consider introducing a named lifetime parameter";
                         should_break = true;
                         match &generics.params {
-                            [] => (generics.span, "<'lifetime>".to_string()),
-                            [param, ..] => (param.span.shrink_to_lo(), "'lifetime, ".to_string()),
+                            [] => (generics.span, "<'r>".to_string()),
+                            [param, ..] => (param.span.shrink_to_lo(), "'r, ".to_string()),
                         }
                     }
                     MissingLifetimeSpot::HRLT { span, span_type } => {
@@ -1510,8 +1510,8 @@ crate fn add_missing_lifetime_specifiers_label(
                              https://doc.rust-lang.org/nomicon/hrtb.html",
                         );
                         let suggestion = match span_type {
-                            HRLTSpanType::Empty => "for<'lifetime> ",
-                            HRLTSpanType::Tail => ", 'lifetime",
+                            HRLTSpanType::Empty => "for<'r> ",
+                            HRLTSpanType::Tail => ", 'r",
                         };
                         (*span, suggestion.to_string())
                     }
@@ -1520,7 +1520,7 @@ crate fn add_missing_lifetime_specifiers_label(
                     if let Ok(snippet) = source_map.span_to_snippet(param.span) {
                         if snippet.starts_with("&") && !snippet.starts_with("&'") {
                             introduce_suggestion
-                                .push((param.span, format!("&'lifetime {}", &snippet[1..])));
+                                .push((param.span, format!("&'r {}", &snippet[1..])));
                         }
                     }
                 }
@@ -1543,13 +1543,13 @@ crate fn add_missing_lifetime_specifiers_label(
                 suggest_existing(err, format!("{}<{}>", snippet, name));
             }
             (0, _, Some("&")) => {
-                suggest_new(err, "&'lifetime ");
+                suggest_new(err, "&'r ");
             }
             (0, _, Some("'_")) => {
-                suggest_new(err, "'lifetime");
+                suggest_new(err, "'r");
             }
             (0, _, Some(snippet)) if !snippet.ends_with(">") => {
-                suggest_new(err, &format!("{}<'lifetime>", snippet));
+                suggest_new(err, &format!("{}<'r>", snippet));
             }
             _ => {
                 err.span_label(span, "expected lifetime parameter");
diff --git a/src/test/ui/error-codes/E0106.stderr b/src/test/ui/error-codes/E0106.stderr
index e01e0a6f54b..3792b8f637a 100644
--- a/src/test/ui/error-codes/E0106.stderr
+++ b/src/test/ui/error-codes/E0106.stderr
@@ -6,8 +6,8 @@ LL |     x: &bool,
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct Foo<'lifetime> {
-LL |     x: &'lifetime bool,
+LL | struct Foo<'r> {
+LL |     x: &'r bool,
    |
 
 error[E0106]: missing lifetime specifier
@@ -18,9 +18,9 @@ LL |     B(&bool),
    |
 help: consider introducing a named lifetime parameter
    |
-LL | enum Bar<'lifetime> {
+LL | enum Bar<'r> {
 LL |     A(u8),
-LL |     B(&'lifetime bool),
+LL |     B(&'r bool),
    |
 
 error[E0106]: missing lifetime specifier
@@ -31,8 +31,8 @@ LL | type MyStr = &str;
    |
 help: consider introducing a named lifetime parameter
    |
-LL | type MyStr<'lifetime> = &'lifetime str;
-   |           ^^^^^^^^^^^   ^^^^^^^^^^
+LL | type MyStr<'r> = &'r str;
+   |           ^^^^   ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/E0106.rs:17:10
@@ -42,8 +42,8 @@ LL |     baz: Baz,
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct Quux<'lifetime> {
-LL |     baz: Baz<'lifetime>,
+LL | struct Quux<'r> {
+LL |     baz: Baz<'r>,
    |
 
 error[E0106]: missing lifetime specifiers
diff --git a/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr b/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr
index 14c53f90665..d3968917bed 100644
--- a/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr
+++ b/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr
@@ -6,8 +6,8 @@ LL |     type Output = &i32;
    |
 help: consider introducing a named lifetime parameter
    |
-LL |     type Output<'lifetime> = &'lifetime i32;
-   |                ^^^^^^^^^^^   ^^^^^^^^^^
+LL |     type Output<'r> = &'r i32;
+   |                ^^^^   ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/assoc-type.rs:16:20
@@ -17,8 +17,8 @@ LL |     type Output = &'_ i32;
    |
 help: consider introducing a named lifetime parameter
    |
-LL |     type Output<'lifetime> = &'lifetime i32;
-   |                ^^^^^^^^^^^    ^^^^^^^^^
+LL |     type Output<'r> = &'r i32;
+   |                ^^^^    ^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/in-band-lifetimes/issue-61124-anon-lifetime-in-struct-declaration.stderr b/src/test/ui/in-band-lifetimes/issue-61124-anon-lifetime-in-struct-declaration.stderr
index 5f101a24c1d..3688b222a35 100644
--- a/src/test/ui/in-band-lifetimes/issue-61124-anon-lifetime-in-struct-declaration.stderr
+++ b/src/test/ui/in-band-lifetimes/issue-61124-anon-lifetime-in-struct-declaration.stderr
@@ -6,8 +6,8 @@ LL | struct Heartbreak(Betrayal);
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct Heartbreak<'lifetime>(Betrayal<'lifetime>);
-   |                  ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
+LL | struct Heartbreak<'r>(Betrayal<'r>);
+   |                  ^^^^ ^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-19707.stderr b/src/test/ui/issues/issue-19707.stderr
index f8917b7bdd0..8246b0e5401 100644
--- a/src/test/ui/issues/issue-19707.stderr
+++ b/src/test/ui/issues/issue-19707.stderr
@@ -11,8 +11,8 @@ LL | type Foo = fn(&u8, &u8) -> &u8;
    |               ^^^  ^^^
 help: consider introducing a named lifetime parameter
    |
-LL | type Foo<'lifetime> = fn(&'lifetime u8, &'lifetime u8) -> &'lifetime u8;
-   |         ^^^^^^^^^^^      ^^^^^^^^^^^^^  ^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | type Foo<'r> = fn(&'r u8, &'r u8) -> &'r u8;
+   |         ^^^^      ^^^^^^  ^^^^^^     ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/issue-19707.rs:5:27
@@ -28,12 +28,12 @@ LL | fn bar<F: Fn(&u8, &u8) -> &u8>(f: &F) {}
    = note: for more information on Higher-Ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html
 help: consider introducing a Higher-Ranked lifetime
    |
-LL | fn bar<F: for<'lifetime> Fn(&'lifetime u8, &'lifetime u8) -> &'lifetime u8>(f: &F) {}
-   |           ^^^^^^^^^^^^^^    ^^^^^^^^^^^^^  ^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn bar<F: for<'r> Fn(&'r u8, &'r u8) -> &'r u8>(f: &F) {}
+   |           ^^^^^^^    ^^^^^^  ^^^^^^     ^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn bar<'lifetime, F: Fn(&'lifetime u8, &'lifetime u8) -> &'lifetime u8>(f: &F) {}
-   |        ^^^^^^^^^^       ^^^^^^^^^^^^^  ^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn bar<'r, F: Fn(&'r u8, &'r u8) -> &'r u8>(f: &F) {}
+   |        ^^^       ^^^^^^  ^^^^^^     ^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-26638.stderr b/src/test/ui/issues/issue-26638.stderr
index 882102799d9..8c114cf1ae8 100644
--- a/src/test/ui/issues/issue-26638.stderr
+++ b/src/test/ui/issues/issue-26638.stderr
@@ -11,8 +11,8 @@ LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.ne
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn parse_type<'lifetime>(iter: Box<dyn Iterator<Item=&str>+'static>) -> &'lifetime str { iter.next() }
-   |              ^^^^^^^^^^^                                                ^^^^^^^^^^
+LL | fn parse_type<'r>(iter: Box<dyn Iterator<Item=&str>+'static>) -> &'r str { iter.next() }
+   |              ^^^^                                                ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/issue-26638.rs:4:40
diff --git a/src/test/ui/issues/issue-30255.stderr b/src/test/ui/issues/issue-30255.stderr
index fbe715de932..fff3766e12d 100644
--- a/src/test/ui/issues/issue-30255.stderr
+++ b/src/test/ui/issues/issue-30255.stderr
@@ -11,8 +11,8 @@ LL | fn f(a: &S, b: i32) -> &i32 {
    |         ^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn f<'lifetime>(a: &'lifetime S, b: i32) -> &'lifetime i32 {
-   |     ^^^^^^^^^^^    ^^^^^^^^^^^^             ^^^^^^^^^^
+LL | fn f<'r>(a: &'r S, b: i32) -> &'r i32 {
+   |     ^^^^    ^^^^^             ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/issue-30255.rs:14:34
@@ -27,8 +27,8 @@ LL | fn g(a: &S, b: bool, c: &i32) -> &i32 {
    |         ^^              ^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn g<'lifetime>(a: &'lifetime S, b: bool, c: &'lifetime i32) -> &'lifetime i32 {
-   |     ^^^^^^^^^^^    ^^^^^^^^^^^^              ^^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn g<'r>(a: &'r S, b: bool, c: &'r i32) -> &'r i32 {
+   |     ^^^^    ^^^^^              ^^^^^^^     ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/issue-30255.rs:19:44
@@ -43,8 +43,8 @@ LL | fn h(a: &bool, b: bool, c: &S, d: &i32) -> &i32 {
    |         ^^^^^              ^^     ^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn h<'lifetime>(a: &'lifetime bool, b: bool, c: &'lifetime S, d: &'lifetime i32) -> &'lifetime i32 {
-   |     ^^^^^^^^^^^    ^^^^^^^^^^^^^^^              ^^^^^^^^^^^^     ^^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn h<'r>(a: &'r bool, b: bool, c: &'r S, d: &'r i32) -> &'r i32 {
+   |     ^^^^    ^^^^^^^^              ^^^^^     ^^^^^^^     ^^^
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr
index 01236e3c773..638c8b8612c 100644
--- a/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr
+++ b/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr
@@ -19,8 +19,8 @@ LL | fn g(_x: &isize, _y: &isize) -> &isize {
    |          ^^^^^^      ^^^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn g<'lifetime>(_x: &'lifetime isize, _y: &'lifetime isize) -> &'lifetime isize {
-   |     ^^^^^^^^^^^     ^^^^^^^^^^^^^^^^      ^^^^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn g<'r>(_x: &'r isize, _y: &'r isize) -> &'r isize {
+   |     ^^^^     ^^^^^^^^^      ^^^^^^^^^     ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:17:19
@@ -35,8 +35,8 @@ LL | fn h(_x: &Foo) -> &isize {
    |          ^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn h<'lifetime>(_x: &'lifetime Foo) -> &'lifetime isize {
-   |     ^^^^^^^^^^^     ^^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn h<'r>(_x: &'r Foo) -> &'r isize {
+   |     ^^^^     ^^^^^^^     ^^^
 
 error[E0106]: missing lifetime specifier
   --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:21:20
diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.stderr
index bea1a8bf2c1..e1982ea393e 100644
--- a/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.stderr
+++ b/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.stderr
@@ -11,8 +11,8 @@ LL | fn foo(x: &i32, y: &i32) -> &i32 {
    |           ^^^^     ^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn foo<'lifetime>(x: &'lifetime i32, y: &'lifetime i32) -> &'lifetime i32 {
-   |       ^^^^^^^^^^^    ^^^^^^^^^^^^^^     ^^^^^^^^^^^^^^     ^^^^^^^^^^
+LL | fn foo<'r>(x: &'r i32, y: &'r i32) -> &'r i32 {
+   |       ^^^^    ^^^^^^^     ^^^^^^^     ^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/proc-macro/item-error.stderr b/src/test/ui/proc-macro/item-error.stderr
index 01eadbe252e..be33f2e2f76 100644
--- a/src/test/ui/proc-macro/item-error.stderr
+++ b/src/test/ui/proc-macro/item-error.stderr
@@ -6,8 +6,8 @@ LL |     a: &u64
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct A<'lifetime> {
-LL |     a: &'lifetime u64
+LL | struct A<'r> {
+LL |     a: &'r u64
    |
 
 error: aborting due to previous error
diff --git a/src/test/ui/regions/regions-in-enums-anon.stderr b/src/test/ui/regions/regions-in-enums-anon.stderr
index 41655a210b3..46555df5936 100644
--- a/src/test/ui/regions/regions-in-enums-anon.stderr
+++ b/src/test/ui/regions/regions-in-enums-anon.stderr
@@ -6,8 +6,8 @@ LL |     Bar(&isize)
    |
 help: consider introducing a named lifetime parameter
    |
-LL | enum Foo<'lifetime> {
-LL |     Bar(&'lifetime isize)
+LL | enum Foo<'r> {
+LL |     Bar(&'r isize)
    |
 
 error: aborting due to previous error
diff --git a/src/test/ui/regions/regions-in-structs-anon.stderr b/src/test/ui/regions/regions-in-structs-anon.stderr
index fbe8036880f..e807810db26 100644
--- a/src/test/ui/regions/regions-in-structs-anon.stderr
+++ b/src/test/ui/regions/regions-in-structs-anon.stderr
@@ -6,8 +6,8 @@ LL |     x: &isize
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct Foo<'lifetime> {
-LL |     x: &'lifetime isize
+LL | struct Foo<'r> {
+LL |     x: &'r isize
    |
 
 error: aborting due to previous error
diff --git a/src/test/ui/suggestions/fn-missing-lifetime-in-item.rs b/src/test/ui/suggestions/fn-missing-lifetime-in-item.rs
new file mode 100644
index 00000000000..dac6610b335
--- /dev/null
+++ b/src/test/ui/suggestions/fn-missing-lifetime-in-item.rs
@@ -0,0 +1,8 @@
+struct S1<F: Fn(&i32, &i32) -> &'a i32>(F); //~ ERROR use of undeclared lifetime name `'a`
+struct S2<F: Fn(&i32, &i32) -> &i32>(F); //~ ERROR missing lifetime specifier
+struct S3<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
+//~^ ERROR binding for associated type `Output` references lifetime `'a`, which does not appear
+struct S4<F: for<'x> Fn(&'x i32, &'x i32) -> &'x i32>(F);
+const C: Option<Box<dyn for<'a> Fn(&usize, &usize) -> &'a usize>> = None;
+//~^ ERROR binding for associated type `Output` references lifetime `'a`, which does not appear
+fn main() {}
diff --git a/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr
new file mode 100644
index 00000000000..c1a40ebc892
--- /dev/null
+++ b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr
@@ -0,0 +1,53 @@
+error[E0261]: use of undeclared lifetime name `'a`
+  --> $DIR/fn-missing-lifetime-in-item.rs:1:33
+   |
+LL | struct S1<F: Fn(&i32, &i32) -> &'a i32>(F);
+   |                                 ^^ undeclared lifetime
+   |
+   = note: for more information on Higher-Ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider introducing lifetime `'a` here
+   |
+LL | struct S1<'a, F: Fn(&i32, &i32) -> &'a i32>(F);
+   |           ^^^
+help: consider introducing a Higher-Ranked lifetime `'a` here
+   |
+LL | struct S1<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
+   |              ^^^^^^^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/fn-missing-lifetime-in-item.rs:2:32
+   |
+LL | struct S2<F: Fn(&i32, &i32) -> &i32>(F);
+   |                                ^ expected named lifetime parameter
+   |
+help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2
+  --> $DIR/fn-missing-lifetime-in-item.rs:2:17
+   |
+LL | struct S2<F: Fn(&i32, &i32) -> &i32>(F);
+   |                 ^^^^  ^^^^
+   = note: for more information on Higher-Ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider introducing a Higher-Ranked lifetime
+   |
+LL | struct S2<F: for<'r> Fn(&'r i32, &'r i32) -> &'r i32>(F);
+   |              ^^^^^^^    ^^^^^^^  ^^^^^^^     ^^^
+help: consider introducing a named lifetime parameter
+   |
+LL | struct S2<'r, F: Fn(&'r i32, &'r i32) -> &'r i32>(F);
+   |           ^^^       ^^^^^^^  ^^^^^^^     ^^^
+
+error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types
+  --> $DIR/fn-missing-lifetime-in-item.rs:3:40
+   |
+LL | struct S3<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
+   |                                        ^^^^^^^
+
+error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types
+  --> $DIR/fn-missing-lifetime-in-item.rs:6:55
+   |
+LL | const C: Option<Box<dyn for<'a> Fn(&usize, &usize) -> &'a usize>> = None;
+   |                                                       ^^^^^^^^^
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0106, E0261, E0582.
+For more information about an error, try `rustc --explain E0106`.
diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr
index 1e15196f8ec..459000a3722 100644
--- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr
+++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr
@@ -11,7 +11,7 @@ LL |     let _: dyn Foo(&isize, &usize) -> &usize;
    |                    ^^^^^^  ^^^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn main<'lifetime>() {
+LL | fn main<'r>() {
 LL |     eq::< dyn for<'a> Foo<(&'a isize,), Output=&'a isize>,
 LL |           dyn Foo(&isize) -> &isize                                   >();
 LL |     eq::< dyn for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>,
diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr
index 04df2e45703..d0efd788dc1 100644
--- a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr
+++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr
@@ -6,8 +6,8 @@ LL |     x: Box<dyn Debug + '_>,
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct Foo<'lifetime> {
-LL |     x: Box<dyn Debug + 'lifetime>,
+LL | struct Foo<'r> {
+LL |     x: Box<dyn Debug + 'r>,
    |
 
 error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
diff --git a/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr b/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr
index 97014dae2b9..998028622c2 100644
--- a/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr
+++ b/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr
@@ -11,8 +11,8 @@ LL | fn foo(x: &u32, y: &u32) -> &'_ u32 { loop { } }
    |           ^^^^     ^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn foo<'lifetime>(x: &'lifetime u32, y: &'lifetime u32) -> &'lifetime u32 { loop { } }
-   |       ^^^^^^^^^^^    ^^^^^^^^^^^^^^     ^^^^^^^^^^^^^^      ^^^^^^^^^
+LL | fn foo<'r>(x: &'r u32, y: &'r u32) -> &'r u32 { loop { } }
+   |       ^^^^    ^^^^^^^     ^^^^^^^      ^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/underscore-lifetime/in-struct.stderr b/src/test/ui/underscore-lifetime/in-struct.stderr
index e01b39a4b64..406e0a92013 100644
--- a/src/test/ui/underscore-lifetime/in-struct.stderr
+++ b/src/test/ui/underscore-lifetime/in-struct.stderr
@@ -6,8 +6,8 @@ LL |     x: &'_ u32,
    |
 help: consider introducing a named lifetime parameter
    |
-LL | struct Foo<'lifetime> {
-LL |     x: &'lifetime u32,
+LL | struct Foo<'r> {
+LL |     x: &'r u32,
    |
 
 error[E0106]: missing lifetime specifier
@@ -18,8 +18,8 @@ LL |     Variant(&'_ u32),
    |
 help: consider introducing a named lifetime parameter
    |
-LL | enum Bar<'lifetime> {
-LL |     Variant(&'lifetime u32),
+LL | enum Bar<'r> {
+LL |     Variant(&'r u32),
    |
 
 error: aborting due to 2 previous errors
diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
index ef3ad18ee88..94f3499df5f 100644
--- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
+++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
@@ -37,8 +37,8 @@ LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y }
    |            ^^^^^^     ^^^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn foo2<'lifetime>(_: &'_ u8, y: &'_ u8) -> &'lifetime u8 { y }
-   |        ^^^^^^^^^^^                           ^^^^^^^^^
+LL | fn foo2<'r>(_: &'_ u8, y: &'_ u8) -> &'r u8 { y }
+   |        ^^^^                           ^^
 
 error: aborting due to 5 previous errors