rust/tests/ui/borrowck/borrowck-in-static.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
299 B
Rust
Raw Normal View History

// check that borrowck looks inside consts/statics
2024-03-12 19:02:45 -05:00
static FN : &'static (dyn Fn() -> Box<dyn Fn()->Box<i32>> + Sync) = &|| {
let x = Box::new(0);
Box::new(|| x) //~ ERROR cannot move out of `x`, a captured variable in an `Fn` closure
};
fn main() {
let f = (FN)();
f();
f();
}