Select an appropriate unused lifetime name in suggestion

This commit is contained in:
Esteban Küber 2020-02-13 22:45:48 -08:00
parent a643ee8d69
commit 8bafe883b6
3 changed files with 71 additions and 13 deletions

View file

@ -12,11 +12,12 @@ struct SomeStruct<I: for<'x> Foo<&'x isize>> {
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
}
enum SomeEnum<I: for<'x> Foo<&'x isize>> {
enum SomeEnum<'b, I: for<'a> Foo<&'a isize>> {
TupleVariant(I::A),
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
StructVariant { field: I::A },
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
OkVariant(&'b usize),
}
// FIXME(eddyb) This one doesn't even compile because of the unsupported syntax.
@ -26,7 +27,13 @@ enum SomeEnum<I: for<'x> Foo<&'x isize>> {
// }
struct YetAnotherStruct<'a, I: for<'x> Foo<&'x isize>> {
field: <I as Foo<&'a isize>>::A
field: <I as Foo<&'a isize>>::A,
}
struct Why<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x,
'y, 'z, 'aa, I: for<'l, 'm> Foo<&'l &'m isize>> {
field: I::A,
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
}
pub fn main() {}

View file

@ -18,8 +18,8 @@ LL | TupleVariant(I::A),
|
help: use a fully qualified path with explicit lifetimes
|
LL | enum SomeEnum<'a, I: for<'x> Foo<&'x isize>> {
LL | TupleVariant(<I as Foo<&'a isize>>::A),
LL | enum SomeEnum<'c, 'b, I: for<'a> Foo<&'a isize>> {
LL | TupleVariant(<I as Foo<&'c isize>>::A),
|
error[E0212]: cannot extract an associated type from a higher-ranked trait bound in this context
@ -30,11 +30,24 @@ LL | StructVariant { field: I::A },
|
help: use a fully qualified path with explicit lifetimes
|
LL | enum SomeEnum<'a, I: for<'x> Foo<&'x isize>> {
LL | enum SomeEnum<'c, 'b, I: for<'a> Foo<&'a isize>> {
LL | TupleVariant(I::A),
LL |
LL | StructVariant { field: <I as Foo<&'a isize>>::A },
LL | StructVariant { field: <I as Foo<&'c isize>>::A },
|
error: aborting due to 3 previous errors
error[E0212]: cannot extract an associated type from a higher-ranked trait bound in this context
--> $DIR/associated-types-project-from-hrtb-in-struct.rs:35:12
|
LL | field: I::A,
| ^^^^
|
help: use a fully qualified path with explicit lifetimes
|
LL | struct Why<'bb, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x,
LL | 'y, 'z, 'aa, I: for<'l, 'm> Foo<&'l &'m isize>> {
LL | field: <I as Foo<&'bb &'bb isize>>::A,
|
error: aborting due to 4 previous errors