review comments

This commit is contained in:
Esteban Küber 2020-01-27 14:08:59 -08:00
parent fa4594196d
commit 2100b31535
21 changed files with 60 additions and 60 deletions

View file

@ -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");

View file

@ -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",
);
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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<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
= 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<'r> Fn(&'r u8, &'r u8) -> &'r u8>(f: &F) {}
LL | fn bar<F: for<'a> 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

View file

@ -11,7 +11,7 @@ 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<'r>(iter: Box<dyn Iterator<Item=&str>+'static>) -> &'r str { iter.next() }
LL | fn parse_type<'a>(iter: Box<dyn Iterator<Item=&str>+'static>) -> &'a str { iter.next() }
| ^^^^ ^^^
error[E0106]: missing lifetime specifier

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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<dyn for<'a, 'b> 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<dyn for<'a, 'b> FnOnce(&'a isize,
| ^^^^

View file

@ -4,12 +4,12 @@ error[E0261]: use of undeclared lifetime name `'a`
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
= 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<F: for<'a> 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<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
= 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);
LL | struct S2<F: for<'a> 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

View file

@ -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)>,

View file

@ -6,8 +6,8 @@ LL | x: Box<dyn Debug + '_>,
|
help: consider introducing a named lifetime parameter
|
LL | struct Foo<'r> {
LL | x: Box<dyn Debug + 'r>,
LL | struct Foo<'a> {
LL | x: Box<dyn Debug + 'a>,
|
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound

View file

@ -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

View file

@ -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

View file

@ -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