| 1 | /*! ```compile_fail,E0373 |
|---|---|
| 2 | |
| 3 | fn bad_scope<F>(f: F) |
| 4 | where F: FnOnce(&i32) + Send, |
| 5 | { |
| 6 | rayon_core::scope(|s| { |
| 7 | let x = 22; |
| 8 | s.spawn(|_| f(&x)); //~ ERROR `x` does not live long enough |
| 9 | }); |
| 10 | } |
| 11 | |
| 12 | fn good_scope<F>(f: F) |
| 13 | where F: FnOnce(&i32) + Send, |
| 14 | { |
| 15 | let x = 22; |
| 16 | rayon_core::scope(|s| { |
| 17 | s.spawn(|_| f(&x)); |
| 18 | }); |
| 19 | } |
| 20 | |
| 21 | fn main() { |
| 22 | } |
| 23 | |
| 24 | ``` */ |
| 25 |
