summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/closure-requirements/propagate-multiple-requirements.rs
blob: a9d2a07715d49532a5ad4da67f3d673169555992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Test that we propagate *all* requirements to the caller, not just the first
// one.

fn once<S, T, U, F: FnOnce(S, T) -> U>(f: F, s: S, t: T) -> U {
    f(s, t)
}

pub fn dangle() -> &'static [i32] {
    let other_local_arr = [0, 2, 4];
    let local_arr = other_local_arr;
    let mut out: &mut &'static [i32] = &mut (&[1] as _);
    once(|mut z: &[i32], mut out_val: &mut &[i32]| {
        // We unfortunately point to the first use in the closure in the error
        // message
        z = &local_arr; //~ ERROR
        *out_val = &local_arr;
    }, &[] as &[_], &mut *out);
    *out
}

fn main() {
    println!("{:?}", dangle());
}