Suggest named lifetime in ADT with hrtb
This commit is contained in:
parent
24be307b53
commit
bde96776a1
3 changed files with 87 additions and 10 deletions
|
|
@ -7,18 +7,25 @@ pub trait Foo<T> {
|
|||
fn get(&self, t: T) -> Self::A;
|
||||
}
|
||||
|
||||
struct SomeStruct<I : for<'x> Foo<&'x isize>> {
|
||||
struct SomeStruct<I: for<'x> Foo<&'x isize>> {
|
||||
field: I::A
|
||||
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
|
||||
}
|
||||
|
||||
enum SomeEnum<I: for<'x> Foo<&'x 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
|
||||
}
|
||||
|
||||
// FIXME(eddyb) This one doesn't even compile because of the unsupported syntax.
|
||||
|
||||
// struct AnotherStruct<I : for<'x> Foo<&'x isize>> {
|
||||
// field: <I as for<'y> Foo<&'y isize>>::A
|
||||
// }
|
||||
|
||||
struct YetAnotherStruct<'a, I : for<'x> Foo<&'x isize>> {
|
||||
struct YetAnotherStruct<'a, I: for<'x> Foo<&'x isize>> {
|
||||
field: <I as Foo<&'a isize>>::A
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,38 @@ error[E0212]: cannot extract an associated type from a higher-ranked trait bound
|
|||
|
|
||||
LL | field: I::A
|
||||
| ^^^^
|
||||
|
|
||||
help: use a fully qualified path with explicit lifetimes
|
||||
|
|
||||
LL | struct SomeStruct<'a, I: for<'x> Foo<&'x isize>> {
|
||||
LL | field: <I as Foo<&'a isize>>::A
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
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:16:18
|
||||
|
|
||||
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),
|
||||
|
|
||||
|
||||
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:18:28
|
||||
|
|
||||
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 | TupleVariant(I::A),
|
||||
LL |
|
||||
LL | StructVariant { field: <I as Foo<&'a isize>>::A },
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue