]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-76535.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / generic-associated-types / issue-76535.rs
1 // revisions: base extended
2
3 #![feature(generic_associated_types)]
4 #![cfg_attr(extended, feature(generic_associated_types_extended))]
5 #![cfg_attr(extended, allow(incomplete_features))]
6
7 pub trait SubTrait {}
8
9 pub trait SuperTrait {
10     type SubType<'a>: SubTrait where Self: 'a;
11
12     fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>;
13 }
14
15 pub struct SubStruct<'a> {
16     sup: &'a mut SuperStruct,
17 }
18
19 impl<'a> SubTrait for SubStruct<'a> {}
20
21 pub struct SuperStruct {
22     value: u8,
23 }
24
25 impl SuperStruct {
26     pub fn new(value: u8) -> SuperStruct {
27         SuperStruct { value }
28     }
29 }
30
31 impl SuperTrait for SuperStruct {
32     type SubType<'a> = SubStruct<'a>;
33
34     fn get_sub<'a>(&'a mut self) -> Self::SubType<'a> {
35         SubStruct { sup: self }
36     }
37 }
38
39 fn main() {
40     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
41       //~^ ERROR missing generics for associated type
42       //[base]~^^ ERROR the trait
43       //[base]~| ERROR the trait
44 }