summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-nested-fns.rs
blob: d9698ced3defb9cc10b6dc83f69151b9b007eba7 (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
fn ignore<T>(t: T) {}

fn nested<'x>(x: &'x isize) {
    let y = 3;
    let mut ay = &y;
    //~^ ERROR `y` does not live long enough [E0597]

    ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| {
        ay = x;
        ay = &y;
        //~^ ERROR `y` does not live long enough
        ay = z;
        //~^ ERROR borrowed data escapes outside of closure [E0521]
    }));

    ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
        if false { return x; }
        //~^ ERROR lifetime may not live long enough
        if false { return ay; }
        return z;
    }));
}

fn main() {}