summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs')
-rw-r--r--src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs
new file mode 100644
index 000000000..b8fde2208
--- /dev/null
+++ b/src/test/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 => {},
+ };
+}