]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-76535.rs
Merge commit '5ff7b632a95bac6955611d85040859128902c580' into sync-rustfmt-subtree
[rust.git] / src / test / ui / generic-associated-types / issue-76535.rs
1 #![feature(generic_associated_types)]
2
3 pub trait SubTrait {}
4
5 pub trait SuperTrait {
6     type SubType<'a>: SubTrait where Self: 'a;
7
8     fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>;
9 }
10
11 pub struct SubStruct<'a> {
12     sup: &'a mut SuperStruct,
13 }
14
15 impl<'a> SubTrait for SubStruct<'a> {}
16
17 pub struct SuperStruct {
18     value: u8,
19 }
20
21 impl SuperStruct {
22     pub fn new(value: u8) -> SuperStruct {
23         SuperStruct { value }
24     }
25 }
26
27 impl SuperTrait for SuperStruct {
28     type SubType<'a> = SubStruct<'a>;
29
30     fn get_sub<'a>(&'a mut self) -> Self::SubType<'a> {
31         SubStruct { sup: self }
32     }
33 }
34
35 fn main() {
36     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
37       //~^ ERROR missing generics for associated type
38       //~^^ ERROR the trait
39       //~| ERROR the trait
40 }