]> git.lizzy.rs Git - rust.git/blob - tests/ui/span/send-is-not-static-ensures-scoping.rs
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / tests / ui / span / send-is-not-static-ensures-scoping.rs
1 struct Guard<'a> {
2     f: Box<dyn Fn() + Send + 'a>,
3 }
4
5 fn scoped<'a, F: Fn() + Send + 'a>(f: F) -> Guard<'a> {
6     Guard { f: Box::new(f) }
7 }
8
9 impl<'a> Guard<'a> {
10     fn join(self) {}
11 }
12
13 fn main() {
14     let bad = {
15         let x = 1;
16         let y = &x;
17         //~^ ERROR `x` does not live long enough
18
19         scoped(|| {
20             let _z = y;
21             //~^ ERROR `y` does not live long enough
22         })
23     };
24
25     bad.join();
26 }