summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/associated_type_bound/issue-51446.rs
blob: 7dd95de73ba416e0cb965bd0823c5a524a22a356 (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
// Regression test for #51446.
// check-pass

trait Foo {
    type Item;
    fn get(&self) -> Self::Item;
}

fn blah<T, F>(x: T, f: F) -> B<T::Item, impl Fn(T::Item)>
where
    T: Foo,
    F: Fn(T::Item),
{
    B { x: x.get(), f }
}

pub struct B<T, F>
where
    F: Fn(T),
{
    pub x: T,
    pub f: F,
}

impl Foo for i32 {
    type Item = i32;
    fn get(&self) -> i32 {
        *self
    }
}

fn main() {
    let _ = blah(0, |_| ());
}