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