about summary refs log tree commit diff
path: root/tests/ui/closures/generic-typed-nested-closures-59494.rs
blob: 04d7b00ff7fabf253f9ff5982dbab4cfafb44210 (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
// https://github.com/rust-lang/rust/issues/59494
fn t7p<A, B, C>(f: impl Fn(B) -> C, g: impl Fn(A) -> B) -> impl Fn(A) -> C {
    move |a: A| -> C { f(g(a)) }
}

fn t8n<A, B, C>(f: impl Fn(A) -> B, g: impl Fn(A) -> C) -> impl Fn(A) -> (B, C)
where
    A: Copy,
{
    move |a: A| -> (B, C) {
        let b = a;
        let fa = f(a);
        let ga = g(b);
        (fa, ga)
    }
}

fn main() {
    let f = |(_, _)| {};
    let g = |(a, _)| a;
    let t7 = |env| |a| |b| t7p(f, g)(((env, a), b));
    //~^ ERROR mismatched types
    let t8 = t8n(t7, t7p(f, g));
}