diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index 86252203f1d..0c93a192667 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -2263,7 +2263,7 @@ pub struct PolyTraitRef<'hir> { /// The `'a` in `for<'a> Foo<&'a T>`. pub bound_generic_params: &'hir [GenericParam<'hir>], - /// The `Foo<&'a T>` in `for <'a> Foo<&'a T>`. + /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>`. pub trait_ref: TraitRef<'hir>, pub span: Span, diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 8346dc3b854..b62c9f4747c 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -1498,20 +1498,20 @@ crate fn add_missing_lifetime_specifiers_label( msg = "consider introducing a named lifetime parameter"; should_break = true; match &generics.params { - [] => (generics.span, "<'r>".to_string()), - [param, ..] => (param.span.shrink_to_lo(), "'r, ".to_string()), + [] => (generics.span, "<'a>".to_string()), + [param, ..] => (param.span.shrink_to_lo(), "'a, ".to_string()), } } MissingLifetimeSpot::HRLT { span, span_type } => { - msg = "consider introducing a Higher-Ranked lifetime"; + msg = "consider introducing a higher-ranked lifetime"; should_break = false; err.note( - "for more information on Higher-Ranked lifetimes, visit \ + "for more information on higher-ranked lifetimes, visit \ https://doc.rust-lang.org/nomicon/hrtb.html", ); let suggestion = match span_type { - HRLTSpanType::Empty => "for<'r> ", - HRLTSpanType::Tail => ", 'r", + HRLTSpanType::Empty => "for<'a> ", + HRLTSpanType::Tail => ", 'a", }; (*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!("&'r {}", &snippet[1..]))); + .push((param.span, format!("&'a {}", &snippet[1..]))); } } } @@ -1543,13 +1543,13 @@ crate fn add_missing_lifetime_specifiers_label( suggest_existing(err, format!("{}<{}>", snippet, name)); } (0, _, Some("&")) => { - suggest_new(err, "&'r "); + suggest_new(err, "&'a "); } (0, _, Some("'_")) => { - suggest_new(err, "'r"); + suggest_new(err, "'a"); } (0, _, Some(snippet)) if !snippet.ends_with(">") => { - suggest_new(err, &format!("{}<'r>", snippet)); + suggest_new(err, &format!("{}<'a>", snippet)); } _ => { err.span_label(span, "expected lifetime parameter"); diff --git a/src/librustc_resolve/lifetimes.rs b/src/librustc_resolve/lifetimes.rs index 97d314c8f65..69deffe4a4c 100644 --- a/src/librustc_resolve/lifetimes.rs +++ b/src/librustc_resolve/lifetimes.rs @@ -1873,7 +1873,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { err.span_suggestion( *span, &format!( - "consider introducing a Higher-Ranked lifetime `{}` here", + "consider introducing a higher-ranked lifetime `{}` here", lifetime_ref ), match span_type { @@ -1884,7 +1884,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { Applicability::MaybeIncorrect, ); err.note( - "for more information on Higher-Ranked lifetimes, visit \ + "for more information on higher-ranked lifetimes, visit \ https://doc.rust-lang.org/nomicon/hrtb.html", ); } diff --git a/src/test/ui/error-codes/E0106.stderr b/src/test/ui/error-codes/E0106.stderr index 3792b8f637a..a23bcbfd71a 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<'r> { -LL | x: &'r bool, +LL | struct Foo<'a> { +LL | x: &'a bool, | error[E0106]: missing lifetime specifier @@ -18,9 +18,9 @@ LL | B(&bool), | help: consider introducing a named lifetime parameter | -LL | enum Bar<'r> { +LL | enum Bar<'a> { LL | A(u8), -LL | B(&'r bool), +LL | B(&'a bool), | error[E0106]: missing lifetime specifier @@ -31,7 +31,7 @@ LL | type MyStr = &str; | help: consider introducing a named lifetime parameter | -LL | type MyStr<'r> = &'r str; +LL | type MyStr<'a> = &'a str; | ^^^^ ^^^ error[E0106]: missing lifetime specifier @@ -42,8 +42,8 @@ LL | baz: Baz, | help: consider introducing a named lifetime parameter | -LL | struct Quux<'r> { -LL | baz: Baz<'r>, +LL | struct Quux<'a> { +LL | baz: Baz<'a>, | 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 d3968917bed..211a3286cc3 100644 --- a/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr +++ b/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr @@ -6,7 +6,7 @@ LL | type Output = &i32; | help: consider introducing a named lifetime parameter | -LL | type Output<'r> = &'r i32; +LL | type Output<'a> = &'a i32; | ^^^^ ^^^ error[E0106]: missing lifetime specifier @@ -17,7 +17,7 @@ LL | type Output = &'_ i32; | help: consider introducing a named lifetime parameter | -LL | type Output<'r> = &'r i32; +LL | type Output<'a> = &'a 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 3688b222a35..f2a4150632d 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,7 +6,7 @@ LL | struct Heartbreak(Betrayal); | help: consider introducing a named lifetime parameter | -LL | struct Heartbreak<'r>(Betrayal<'r>); +LL | struct Heartbreak<'a>(Betrayal<'a>); | ^^^^ ^^^^^^^^^^^^ 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 8246b0e5401..e84bfb969d4 100644 --- a/src/test/ui/issues/issue-19707.stderr +++ b/src/test/ui/issues/issue-19707.stderr @@ -11,7 +11,7 @@ LL | type Foo = fn(&u8, &u8) -> &u8; | ^^^ ^^^ help: consider introducing a named lifetime parameter | -LL | type Foo<'r> = fn(&'r u8, &'r u8) -> &'r u8; +LL | type Foo<'a> = fn(&'a u8, &'a u8) -> &'a u8; | ^^^^ ^^^^^^ ^^^^^^ ^^^ error[E0106]: missing lifetime specifier @@ -25,14 +25,14 @@ help: this function's return type contains a borrowed value, but the signature d | LL | fn bar &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 + = 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 Fn(&'r u8, &'r u8) -> &'r u8>(f: &F) {} +LL | fn bar Fn(&'a u8, &'a u8) -> &'a u8>(f: &F) {} | ^^^^^^^ ^^^^^^ ^^^^^^ ^^^ help: consider introducing a named lifetime parameter | -LL | fn bar<'r, F: Fn(&'r u8, &'r u8) -> &'r u8>(f: &F) {} +LL | fn bar<'a, F: Fn(&'a u8, &'a u8) -> &'a 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 8c114cf1ae8..75cd5332fd9 100644 --- a/src/test/ui/issues/issue-26638.stderr +++ b/src/test/ui/issues/issue-26638.stderr @@ -11,7 +11,7 @@ LL | fn parse_type(iter: Box+'static>) -> &str { iter.ne | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider introducing a named lifetime parameter | -LL | fn parse_type<'r>(iter: Box+'static>) -> &'r str { iter.next() } +LL | fn parse_type<'a>(iter: Box+'static>) -> &'a str { iter.next() } | ^^^^ ^^^ error[E0106]: missing lifetime specifier diff --git a/src/test/ui/issues/issue-30255.stderr b/src/test/ui/issues/issue-30255.stderr index fff3766e12d..3c26365d5d1 100644 --- a/src/test/ui/issues/issue-30255.stderr +++ b/src/test/ui/issues/issue-30255.stderr @@ -11,7 +11,7 @@ LL | fn f(a: &S, b: i32) -> &i32 { | ^^ help: consider introducing a named lifetime parameter | -LL | fn f<'r>(a: &'r S, b: i32) -> &'r i32 { +LL | fn f<'a>(a: &'a S, b: i32) -> &'a i32 { | ^^^^ ^^^^^ ^^^ error[E0106]: missing lifetime specifier @@ -27,7 +27,7 @@ LL | fn g(a: &S, b: bool, c: &i32) -> &i32 { | ^^ ^^^^ help: consider introducing a named lifetime parameter | -LL | fn g<'r>(a: &'r S, b: bool, c: &'r i32) -> &'r i32 { +LL | fn g<'a>(a: &'a S, b: bool, c: &'a i32) -> &'a i32 { | ^^^^ ^^^^^ ^^^^^^^ ^^^ error[E0106]: missing lifetime specifier @@ -43,7 +43,7 @@ LL | fn h(a: &bool, b: bool, c: &S, d: &i32) -> &i32 { | ^^^^^ ^^ ^^^^ help: consider introducing a named lifetime parameter | -LL | fn h<'r>(a: &'r bool, b: bool, c: &'r S, d: &'r i32) -> &'r i32 { +LL | fn h<'a>(a: &'a bool, b: bool, c: &'a S, d: &'a i32) -> &'a 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 638c8b8612c..b81ce552b39 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,7 +19,7 @@ LL | fn g(_x: &isize, _y: &isize) -> &isize { | ^^^^^^ ^^^^^^ help: consider introducing a named lifetime parameter | -LL | fn g<'r>(_x: &'r isize, _y: &'r isize) -> &'r isize { +LL | fn g<'a>(_x: &'a isize, _y: &'a isize) -> &'a isize { | ^^^^ ^^^^^^^^^ ^^^^^^^^^ ^^^ error[E0106]: missing lifetime specifier @@ -35,7 +35,7 @@ LL | fn h(_x: &Foo) -> &isize { | ^^^^ help: consider introducing a named lifetime parameter | -LL | fn h<'r>(_x: &'r Foo) -> &'r isize { +LL | fn h<'a>(_x: &'a Foo) -> &'a isize { | ^^^^ ^^^^^^^ ^^^ error[E0106]: missing lifetime specifier 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 e1982ea393e..47b048a7a97 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,7 +11,7 @@ LL | fn foo(x: &i32, y: &i32) -> &i32 { | ^^^^ ^^^^ help: consider introducing a named lifetime parameter | -LL | fn foo<'r>(x: &'r i32, y: &'r i32) -> &'r i32 { +LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a 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 be33f2e2f76..27f7639d213 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<'r> { -LL | a: &'r u64 +LL | struct A<'a> { +LL | a: &'a 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 46555df5936..b3649c5b485 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<'r> { -LL | Bar(&'r isize) +LL | enum Foo<'a> { +LL | Bar(&'a 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 e807810db26..60a6fb9a0fa 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<'r> { -LL | x: &'r isize +LL | struct Foo<'a> { +LL | x: &'a isize | error: aborting due to previous error diff --git a/src/test/ui/regions/regions-name-undeclared.stderr b/src/test/ui/regions/regions-name-undeclared.stderr index cb72d1ec9bc..498667abe36 100644 --- a/src/test/ui/regions/regions-name-undeclared.stderr +++ b/src/test/ui/regions/regions-name-undeclared.stderr @@ -89,12 +89,12 @@ error[E0261]: use of undeclared lifetime name `'b` LL | ... &'b isize, | ^^ undeclared lifetime | - = note: for more information on Higher-Ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html + = note: for more information on higher-ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, | ^^^^ -help: consider introducing a Higher-Ranked lifetime `'b` here +help: consider introducing a higher-ranked lifetime `'b` here | LL | b: Box FnOnce(&'a isize, | ^^^^ @@ -105,12 +105,12 @@ error[E0261]: use of undeclared lifetime name `'b` LL | ... &'b isize)>, | ^^ undeclared lifetime | - = note: for more information on Higher-Ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html + = note: for more information on higher-ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, | ^^^^ -help: consider introducing a Higher-Ranked lifetime `'b` here +help: consider introducing a higher-ranked lifetime `'b` here | LL | b: Box FnOnce(&'a isize, | ^^^^ diff --git a/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr index c1a40ebc892..858f23f1362 100644 --- a/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr +++ b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr @@ -4,12 +4,12 @@ error[E0261]: use of undeclared lifetime name `'a` LL | struct S1 &'a i32>(F); | ^^ undeclared lifetime | - = note: for more information on Higher-Ranked lifetimes, visit https://doc.rust-lang.org/nomicon/hrtb.html + = 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 +help: consider introducing a higher-ranked lifetime `'a` here | LL | struct S1 Fn(&i32, &i32) -> &'a i32>(F); | ^^^^^^^ @@ -25,14 +25,14 @@ help: this function's return type contains a borrowed value, but the signature d | LL | struct S2 &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 + = 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 Fn(&'r i32, &'r i32) -> &'r i32>(F); +LL | struct S2 Fn(&'a i32, &'a i32) -> &'a i32>(F); | ^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^ help: consider introducing a named lifetime parameter | -LL | struct S2<'r, F: Fn(&'r i32, &'r i32) -> &'r i32>(F); +LL | struct S2<'a, F: Fn(&'a i32, &'a i32) -> &'a i32>(F); | ^^^ ^^^^^^^ ^^^^^^^ ^^^ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types 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 459000a3722..2431e8ece38 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<'r>() { +LL | fn main<'a>() { 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 d0efd788dc1..fe242e6a909 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, | help: consider introducing a named lifetime parameter | -LL | struct Foo<'r> { -LL | x: Box, +LL | struct Foo<'a> { +LL | x: Box, | 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 998028622c2..0e410e25ecf 100644 --- a/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr +++ b/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr @@ -11,7 +11,7 @@ LL | fn foo(x: &u32, y: &u32) -> &'_ u32 { loop { } } | ^^^^ ^^^^ help: consider introducing a named lifetime parameter | -LL | fn foo<'r>(x: &'r u32, y: &'r u32) -> &'r u32 { loop { } } +LL | fn foo<'a>(x: &'a u32, y: &'a u32) -> &'a 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 406e0a92013..4275cc26f73 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<'r> { -LL | x: &'r u32, +LL | struct Foo<'a> { +LL | x: &'a u32, | error[E0106]: missing lifetime specifier @@ -18,8 +18,8 @@ LL | Variant(&'_ u32), | help: consider introducing a named lifetime parameter | -LL | enum Bar<'r> { -LL | Variant(&'r u32), +LL | enum Bar<'a> { +LL | Variant(&'a 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 94f3499df5f..f2eab86ae57 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -37,7 +37,7 @@ LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } | ^^^^^^ ^^^^^^ help: consider introducing a named lifetime parameter | -LL | fn foo2<'r>(_: &'_ u8, y: &'_ u8) -> &'r u8 { y } +LL | fn foo2<'a>(_: &'_ u8, y: &'_ u8) -> &'a u8 { y } | ^^^^ ^^ error: aborting due to 5 previous errors