summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-steal-closure.rs
blob: 83e93522c9483c93951eba13dfd3a32f29fe5c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![feature(fn_traits)]

struct ClosureBox<'a> {
    cl: Box<dyn FnMut() + 'a>,
}

fn box_it<'r>(x: Box<dyn FnMut() + 'r>) -> ClosureBox<'r> {
    ClosureBox {cl: x}
}

fn main() {
    let mut cl_box = {
        let mut i = 3;
        box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough
    };
    cl_box.cl.call_mut(());
}