diff options
Diffstat (limited to 'tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs')
-rw-r--r-- | tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs b/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs new file mode 100644 index 000000000..174ad245d --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs @@ -0,0 +1,14 @@ +// Test that a by-ref `FnMut` closure gets an error when it tries to +// mutate a value. + +fn call<F>(f: F) where F : Fn() { + f(); +} + +fn main() { + let mut counter = 0; + call(|| { + counter += 1; + //~^ ERROR cannot assign to `counter` + }); +} |