rust/tests/ui/borrowck/regions-escape-bound-fn-2.rs

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

14 lines
204 B
Rust
Raw Normal View History

2020-05-20 17:58:41 +00:00
fn with_int<F>(f: F)
where
F: FnOnce(&isize),
{
let x = 3;
f(&x);
}
fn main() {
2012-08-20 19:23:37 +00:00
let mut x = None;
with_int(|y| x = Some(y));
2020-05-20 17:58:41 +00:00
//~^ ERROR borrowed data escapes outside of closure
}