summaryrefslogtreecommitdiffstats
path: root/src/test/ui/span/send-is-not-static-ensures-scoping.rs
blob: 2aecc2a7e0d96a8b79eb6386d349fdfe37ff276c (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
25
26
struct Guard<'a> {
    f: Box<dyn Fn() + Send + 'a>,
}

fn scoped<'a, F: Fn() + Send + 'a>(f: F) -> Guard<'a> {
    Guard { f: Box::new(f) }
}

impl<'a> Guard<'a> {
    fn join(self) {}
}

fn main() {
    let bad = {
        let x = 1;
        let y = &x;
        //~^ ERROR `x` does not live long enough

        scoped(|| {
            let _z = y;
            //~^ ERROR `y` does not live long enough
        })
    };

    bad.join();
}