]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-86787.rs
Rollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum
[rust.git] / src / test / ui / generic-associated-types / issue-86787.rs
1 #![feature(generic_associated_types)]
2 // check-fail
3
4 enum Either<L, R> {
5     Left(L),
6     Right(R),
7 }
8
9 pub trait HasChildrenOf {
10     type T;
11     type TRef<'a>;
12     //~^ missing required
13
14     fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>>;
15     fn take_children(self) -> Vec<Self::T>;
16 }
17
18 impl<Left, Right> HasChildrenOf for Either<Left, Right>
19 where
20     Left: HasChildrenOf,
21     Right: HasChildrenOf,
22 {
23     type T = Either<Left::T, Right::T>;
24     // We used to error below because the where clause doesn't match the trait.
25     // Now, we error early on the trait itself.
26     type TRef<'a>
27     where
28     <Left as HasChildrenOf>::T: 'a,
29     <Right as HasChildrenOf>::T: 'a
30     = Either<&'a Left::T, &'a Right::T>;
31
32     fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>> {
33         todo!()
34     }
35
36     fn take_children(self) -> Vec<Self::T> {
37         todo!()
38     }
39 }
40
41 fn main() {}