summaryrefslogtreecommitdiffstats
path: root/tests/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs
blob: 6d5a9876c373c37ab5a6f5c68ba3eb9b4496acc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// run-pass
#![allow(dead_code)]
#![allow(unused_variables)]
fn with_closure<A, F>(_: F)
    where F: FnOnce(Vec<A>, A)
{
}

fn expect_free_supply_free<'x>(x: &'x u32) {
    with_closure(|mut x: Vec<_>, y| {
        // Shows that the call to `x.push()` is influencing type of `y`...
        x.push(22_u32);

        // ...since we now know the type of `y` and can resolve the method call.
        let _ = y.wrapping_add(1);
    });
}

fn main() { }