File: issue-65774-2.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (58 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#![feature(associated_type_defaults)]

trait MyDisplay { fn method(&self) { } }

impl<'a, T: MyDisplay> MyDisplay for &'a mut T { }

struct T;

trait MPU {
    type MpuConfig: MyDisplay = T;
    //~^ ERROR the trait bound `T: MyDisplay` is not satisfied
}

struct S;

impl MPU for S { }

trait MyWrite {
    fn my_write(&self, _: &dyn MyDisplay) { }
}

trait ProcessType {
    fn process_detail_fmt(&self, _: &mut dyn MyWrite);
}

struct Process;

impl ProcessType for Process {
    fn process_detail_fmt(&self, writer: &mut dyn MyWrite)
    {

        let mut val: Option<<S as MPU>::MpuConfig> = None;
        let valref: &mut <S as MPU>::MpuConfig = val.as_mut().unwrap();

        // // This causes a different ICE (but its similar if you squint right):
        // //
        // // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen
        //
        writer.my_write(valref)
        //~^ ERROR the trait bound `T: MyDisplay` is not satisfied

        // This one causes the ICE:
        // FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)),
        // depth=1),Unimplemented)
        /*let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
        closure(valref);*/
    }
}

fn create() -> &'static dyn ProcessType {
    let input: Option<&mut Process> = None;
    let process: &mut Process = input.unwrap();
    process
}

pub fn main() {
    create();
}