rust/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs
2023-01-11 09:32:08 +00:00

12 lines
232 B
Rust

// Test that an unboxed closure that mutates a free variable will
// cause borrow conflicts.
fn main() {
let mut x = 0;
let f = || x += 1;
let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
f;
}