]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-project-from-hrtb-in-struct.rs
Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum
[rust.git] / src / test / ui / associated-types / associated-types-project-from-hrtb-in-struct.rs
1 // Check projection of an associated type out of a higher-ranked trait-bound
2 // in the context of a struct definition.
3
4 pub trait Foo<T> {
5     type A;
6
7     fn get(&self, t: T) -> Self::A;
8 }
9
10 struct SomeStruct<I: for<'x> Foo<&'x isize>> {
11     field: I::A
12     //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
13 }
14
15 enum SomeEnum<'b, I: for<'a> Foo<&'a isize>> {
16     TupleVariant(I::A),
17     //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
18     StructVariant { field: I::A },
19     //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
20     OkVariant(&'b usize),
21 }
22
23 // FIXME(eddyb) This one doesn't even compile because of the unsupported syntax.
24
25 // struct AnotherStruct<I : for<'x> Foo<&'x isize>> {
26 //     field: <I as for<'y> Foo<&'y isize>>::A
27 // }
28
29 struct YetAnotherStruct<'a, I: for<'x> Foo<&'x isize>> {
30     field: <I as Foo<&'a isize>>::A,
31 }
32
33 struct Why<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x,
34     'y, 'z, 'aa, I: for<'l, 'm> Foo<&'l &'m isize>> {
35     field: I::A,
36     //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
37 }
38
39 pub fn main() {}