1 #![feature(associated_type_defaults)]
2 
method(&self)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 {
my_write(&self, _: &dyn MyDisplay)19     fn my_write(&self, _: &dyn MyDisplay) { }
20 }
21 
22 trait ProcessType {
process_detail_fmt(&self, _: &mut dyn MyWrite)23     fn process_detail_fmt(&self, _: &mut dyn MyWrite);
24 }
25 
26 struct Process;
27 
28 impl ProcessType for Process {
process_detail_fmt(&self, writer: &mut dyn MyWrite)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 
41         // This one causes the ICE:
42         // FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)),
43         // depth=1),Unimplemented)
44         let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
45         //~^ ERROR the trait bound `T: MyDisplay` is not satisfied
46         closure(valref);
47     }
48 }
49 
create() -> &'static dyn ProcessType50 fn create() -> &'static dyn ProcessType {
51     let input: Option<&mut Process> = None;
52     let process: &mut Process = input.unwrap();
53     process
54 }
55 
main()56 pub fn main() {
57     create();
58 }
59