about summary refs log tree commit diff
path: root/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs')
-rw-r--r--tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs
new file mode 100644
index 00000000000..b8fde2208ac
--- /dev/null
+++ b/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs
@@ -0,0 +1,28 @@
+// Verify the binding mode shifts - only when no `&` are auto-dereferenced is the
+// final default binding mode mutable.
+
+fn main() {
+    match &&Some(5i32) {
+        Some(n) => {
+            *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference
+            let _ = n;
+        }
+        None => {},
+    };
+
+    match &mut &Some(5i32) {
+        Some(n) => {
+            *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference
+            let _ = n;
+        }
+        None => {},
+    };
+
+    match &&mut Some(5i32) {
+        Some(n) => {
+            *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference
+            let _ = n;
+        }
+        None => {},
+    };
+}