diff options
Diffstat (limited to 'tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs')
-rw-r--r-- | tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs b/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs new file mode 100644 index 000000000..835a1f598 --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs @@ -0,0 +1,11 @@ +// 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; +} |