]> git.proxmox.com Git - rustc.git/blob - src/test/ui/generic-associated-types/issue-76535.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / generic-associated-types / issue-76535.rs
1 #![feature(generic_associated_types)]
2 //~^ WARNING the feature
3
4 pub trait SubTrait {}
5
6 pub trait SuperTrait {
7 type SubType<'a>: SubTrait;
8 //~^ ERROR missing generics for associated
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));
39 }