summary refs log tree commit diff
path: root/tests/crashes/129372.rs
blob: 43be01b35df29b44a6cd9f8d433f42113b70e45e (plain)
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
//@ known-bug: #129372
//@ compile-flags: -Cdebuginfo=2 -Copt-level=0

pub struct Wrapper<T>(T);
struct Struct;

pub trait TraitA {
    type AssocA<'t>;
}
pub trait TraitB {
    type AssocB;
}

pub fn helper(v: impl MethodTrait) {
    let _local_that_causes_ice = v.method();
}

pub fn main() {
    helper(Wrapper(Struct));
}

pub trait MethodTrait {
    type Assoc<'a>;

    fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a>;
}

impl<T: TraitB> MethodTrait for T
where
    <T as TraitB>::AssocB: TraitA,
{
    type Assoc<'a> = <T::AssocB as TraitA>::AssocA<'a>;

    fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a> {
        move |_| loop {}
    }
}

impl<T, B> TraitB for Wrapper<B>
where
    B: TraitB<AssocB = T>,
{
    type AssocB = T;
}

impl TraitB for Struct {
    type AssocB = Struct;
}

impl TraitA for Struct {
    type AssocA<'t> = Self;
}