]>
Commit | Line | Data |
---|---|---|
5869c6ff | 1 | #![feature(generic_associated_types)] |
6a06907d | 2 | //~^ WARNING the feature |
5869c6ff XL |
3 | |
4 | pub trait SubTrait {} | |
5 | ||
6 | pub trait SuperTrait { | |
7 | type SubType<'a>: SubTrait; | |
6a06907d | 8 | //~^ ERROR missing generics for associated |
5869c6ff XL |
9 | |
10 | fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>; | |
11 | } | |
12 | ||
13 | pub struct SubStruct<'a> { | |
14 | sup: &'a mut SuperStruct, | |
15 | } | |
16 | ||
17 | impl<'a> SubTrait for SubStruct<'a> {} | |
18 | ||
19 | pub struct SuperStruct { | |
20 | value: u8, | |
21 | } | |
22 | ||
23 | impl SuperStruct { | |
24 | pub fn new(value: u8) -> SuperStruct { | |
25 | SuperStruct { value } | |
26 | } | |
27 | } | |
28 | ||
29 | impl SuperTrait for SuperStruct { | |
30 | type SubType<'a> = SubStruct<'a>; | |
31 | ||
32 | fn get_sub<'a>(&'a mut self) -> Self::SubType<'a> { | |
33 | SubStruct { sup: self } | |
34 | } | |
35 | } | |
36 | ||
37 | fn main() { | |
38 | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); | |
5869c6ff | 39 | } |