summaryrefslogtreecommitdiffstats
path: root/src/test/ui/closures/closure-immutable-outer-variable.fixed
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/closures/closure-immutable-outer-variable.fixed13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/ui/closures/closure-immutable-outer-variable.fixed b/src/test/ui/closures/closure-immutable-outer-variable.fixed
new file mode 100644
index 000000000..1b0feede3
--- /dev/null
+++ b/src/test/ui/closures/closure-immutable-outer-variable.fixed
@@ -0,0 +1,13 @@
+// run-rustfix
+
+// Point at the captured immutable outer variable
+
+fn foo(mut f: Box<dyn FnMut()>) {
+ f();
+}
+
+fn main() {
+ let mut y = true;
+ foo(Box::new(move || y = !y) as Box<_>);
+ //~^ ERROR cannot assign to `y`, as it is not declared as mutable
+}