Use structured suggestion when telling user about for<'a>
``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
This commit is contained in:
parent
54d6738a8d
commit
7d33094d3a
17 changed files with 157 additions and 64 deletions
|
@ -1632,9 +1632,13 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||||
..
|
..
|
||||||
} = &rib.kind
|
} = &rib.kind
|
||||||
{
|
{
|
||||||
diag.span_help(
|
diag.multipart_suggestion(
|
||||||
*span,
|
"consider introducing a higher-ranked lifetime here",
|
||||||
"consider introducing a higher-ranked lifetime here with `for<'a>`",
|
vec![
|
||||||
|
(span.shrink_to_lo(), "for<'a> ".into()),
|
||||||
|
(lifetime.ident.span.shrink_to_hi(), "'a ".into()),
|
||||||
|
],
|
||||||
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,10 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||||
LL | T: Into<&u32>,
|
LL | T: Into<&u32>,
|
||||||
| ^ explicit lifetime name needed here
|
| ^ explicit lifetime name needed here
|
||||||
|
|
|
|
||||||
help: consider introducing a higher-ranked lifetime here with `for<'a>`
|
help: consider introducing a higher-ranked lifetime here
|
||||||
--> $DIR/E0637.rs:13:8
|
|
||||||
|
|
|
|
||||||
LL | T: Into<&u32>,
|
LL | T: for<'a> Into<&'a u32>,
|
||||||
| ^
|
| +++++++ ++
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,10 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||||
LL | fn should_error<T>() where T : Into<&u32> {}
|
LL | fn should_error<T>() where T : Into<&u32> {}
|
||||||
| ^ explicit lifetime name needed here
|
| ^ explicit lifetime name needed here
|
||||||
|
|
|
|
||||||
help: consider introducing a higher-ranked lifetime here with `for<'a>`
|
help: consider introducing a higher-ranked lifetime here
|
||||||
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:32
|
|
||||||
|
|
|
|
||||||
LL | fn should_error<T>() where T : Into<&u32> {}
|
LL | fn should_error<T>() where T : for<'a> Into<&'a u32> {}
|
||||||
| ^
|
| +++++++ ++
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:20
|
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:20
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct Foo<T> {
|
||||||
|
t: T
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Foo<T>
|
||||||
|
where
|
||||||
|
T: for<'a> WithType<&'a u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,17 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct Foo<T> {
|
||||||
|
t: T
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Foo<T>
|
||||||
|
where
|
||||||
|
T: WithType<&u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,14 +1,13 @@
|
||||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||||
--> $DIR/where-clause-trait-impl-region.rs:11:17
|
--> $DIR/where-clause-inherent-impl-ampersand-rust2015.rs:13:17
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: WithType<&u32>
|
||||||
| ^ explicit lifetime name needed here
|
| ^ explicit lifetime name needed here
|
||||||
|
|
|
|
||||||
help: consider introducing a higher-ranked lifetime here with `for<'a>`
|
help: consider introducing a higher-ranked lifetime here
|
||||||
--> $DIR/where-clause-trait-impl-region.rs:11:8
|
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: for<'a> WithType<&'a u32>
|
||||||
| ^
|
| +++++++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// edition:2018
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct Foo<T> {
|
||||||
|
t: T
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Foo<T>
|
||||||
|
where
|
||||||
|
T: for<'a> WithType<&'a u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,18 @@
|
||||||
|
// edition:2018
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct Foo<T> {
|
||||||
|
t: T
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Foo<T>
|
||||||
|
where
|
||||||
|
T: WithType<&u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,14 +1,13 @@
|
||||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||||
--> $DIR/where-clause-trait-impl-region.rs:11:17
|
--> $DIR/where-clause-inherent-impl-ampersand-rust2018.rs:14:17
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: WithType<&u32>
|
||||||
| ^ explicit lifetime name needed here
|
| ^ explicit lifetime name needed here
|
||||||
|
|
|
|
||||||
help: consider introducing a higher-ranked lifetime here with `for<'a>`
|
help: consider introducing a higher-ranked lifetime here
|
||||||
--> $DIR/where-clause-trait-impl-region.rs:11:8
|
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: for<'a> WithType<&'a u32>
|
||||||
| ^
|
| +++++++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
// revisions: rust2015 rust2018
|
|
||||||
//[rust2018] edition:2018
|
|
||||||
|
|
||||||
trait WithType<T> {}
|
|
||||||
trait WithRegion<'a> { }
|
|
||||||
|
|
||||||
struct Foo<T> {
|
|
||||||
t: T
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Foo<T>
|
|
||||||
where
|
|
||||||
T: WithType<&u32>
|
|
||||||
//[rust2015]~^ ERROR `&` without an explicit lifetime name cannot be used here
|
|
||||||
//[rust2018]~^^ ERROR `&` without an explicit lifetime name cannot be used here
|
|
||||||
{ }
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
trait Foo { }
|
||||||
|
|
||||||
|
impl<T> Foo for Vec<T>
|
||||||
|
where
|
||||||
|
T: for<'a> WithType<&'a u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,14 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
trait Foo { }
|
||||||
|
|
||||||
|
impl<T> Foo for Vec<T>
|
||||||
|
where
|
||||||
|
T: WithType<&u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,14 +1,13 @@
|
||||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||||
--> $DIR/where-clause-inherent-impl-ampersand.rs:13:17
|
--> $DIR/where-clause-trait-impl-region-2015.rs:10:17
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: WithType<&u32>
|
||||||
| ^ explicit lifetime name needed here
|
| ^ explicit lifetime name needed here
|
||||||
|
|
|
|
||||||
help: consider introducing a higher-ranked lifetime here with `for<'a>`
|
help: consider introducing a higher-ranked lifetime here
|
||||||
--> $DIR/where-clause-inherent-impl-ampersand.rs:13:8
|
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: for<'a> WithType<&'a u32>
|
||||||
| ^
|
| +++++++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// run-rustfix
|
||||||
|
// edition:2018
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
trait Foo { }
|
||||||
|
|
||||||
|
impl<T> Foo for Vec<T>
|
||||||
|
where
|
||||||
|
T: for<'a> WithType<&'a u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// run-rustfix
|
||||||
|
// edition:2018
|
||||||
|
|
||||||
|
trait WithType<T> {}
|
||||||
|
trait WithRegion<'a> { }
|
||||||
|
|
||||||
|
trait Foo { }
|
||||||
|
|
||||||
|
impl<T> Foo for Vec<T>
|
||||||
|
where
|
||||||
|
T: WithType<&u32>
|
||||||
|
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||||
|
{ }
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,14 +1,13 @@
|
||||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||||
--> $DIR/where-clause-inherent-impl-ampersand.rs:13:17
|
--> $DIR/where-clause-trait-impl-region-2018.rs:11:17
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: WithType<&u32>
|
||||||
| ^ explicit lifetime name needed here
|
| ^ explicit lifetime name needed here
|
||||||
|
|
|
|
||||||
help: consider introducing a higher-ranked lifetime here with `for<'a>`
|
help: consider introducing a higher-ranked lifetime here
|
||||||
--> $DIR/where-clause-inherent-impl-ampersand.rs:13:8
|
|
||||||
|
|
|
|
||||||
LL | T: WithType<&u32>
|
LL | T: for<'a> WithType<&'a u32>
|
||||||
| ^
|
| +++++++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
// revisions: rust2015 rust2018
|
|
||||||
//[rust2018] edition:2018
|
|
||||||
|
|
||||||
trait WithType<T> {}
|
|
||||||
trait WithRegion<'a> { }
|
|
||||||
|
|
||||||
trait Foo { }
|
|
||||||
|
|
||||||
impl<T> Foo for Vec<T>
|
|
||||||
where
|
|
||||||
T: WithType<&u32>
|
|
||||||
//[rust2015,rust2018]~^ ERROR `&` without an explicit lifetime name cannot be used here
|
|
||||||
{ }
|
|
||||||
|
|
||||||
fn main() {}
|
|
Loading…
Add table
Add a link
Reference in a new issue