]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/issue-65774-2.rs
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
[rust.git] / tests / ui / associated-types / issue-65774-2.rs
1 #![feature(associated_type_defaults)]
2
3 trait MyDisplay { fn method(&self) { } }
4
5 impl<'a, T: MyDisplay> MyDisplay for &'a mut T { }
6
7 struct T;
8
9 trait MPU {
10     type MpuConfig: MyDisplay = T;
11     //~^ ERROR the trait bound `T: MyDisplay` is not satisfied
12 }
13
14 struct S;
15
16 impl MPU for S { }
17
18 trait MyWrite {
19     fn my_write(&self, _: &dyn MyDisplay) { }
20 }
21
22 trait ProcessType {
23     fn process_detail_fmt(&self, _: &mut dyn MyWrite);
24 }
25
26 struct Process;
27
28 impl ProcessType for Process {
29     fn process_detail_fmt(&self, writer: &mut dyn MyWrite)
30     {
31
32         let mut val: Option<<S as MPU>::MpuConfig> = None;
33         let valref: &mut <S as MPU>::MpuConfig = val.as_mut().unwrap();
34
35         // // This causes a different ICE (but its similar if you squint right):
36         // //
37         // // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen
38         //
39         writer.my_write(valref)
40         //~^ ERROR the trait bound `T: MyDisplay` is not satisfied
41
42         // This one causes the ICE:
43         // FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)),
44         // depth=1),Unimplemented)
45         /*let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
46         closure(valref);*/
47     }
48 }
49
50 fn create() -> &'static dyn ProcessType {
51     let input: Option<&mut Process> = None;
52     let process: &mut Process = input.unwrap();
53     process
54 }
55
56 pub fn main() {
57     create();
58 }