about summary refs log tree commit diff
path: root/tests/ui/pattern
diff options
context:
space:
mode:
authorJules Bertholet <julesbertholet@quoi.xyz>2024-04-05 23:28:34 -0400
committerJules Bertholet <julesbertholet@quoi.xyz>2024-04-15 23:27:19 -0400
commit83f330fbd45be04a693e89e9602f0ab2ffab16e2 (patch)
tree5459ed032209310ea53f6a3f0c5d8343fc150266 /tests/ui/pattern
parentef1d084c0b5b0ff7143bbca966442cd24151313b (diff)
downloadrust-83f330fbd45be04a693e89e9602f0ab2ffab16e2.tar.gz
rust-83f330fbd45be04a693e89e9602f0ab2ffab16e2.zip
Migration lint
Rustfix remains TODO
Diffstat (limited to 'tests/ui/pattern')
-rw-r--r--tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs18
-rw-r--r--tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr35
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs
new file mode 100644
index 00000000000..2992e61fbbc
--- /dev/null
+++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs
@@ -0,0 +1,18 @@
+//@ edition: 2021
+#![feature(mut_dont_reset_binding_mode_2024)]
+#![allow(unused)]
+#![forbid(dereferencing_mut_binding)]
+
+struct Foo(u8);
+
+fn main() {
+    let Foo(mut a) = &Foo(0);
+    //~^ ERROR: dereferencing `mut` binding
+    //~| WARN: this changes meaning in Rust 2024
+    a = 42;
+
+    let Foo(mut a) = &mut Foo(0);
+    //~^ ERROR: dereferencing `mut` binding
+    //~| WARN: this changes meaning in Rust 2024
+    a = 42;
+}
diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr
new file mode 100644
index 00000000000..72b72f0df5d
--- /dev/null
+++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr
@@ -0,0 +1,35 @@
+error: dereferencing `mut` binding
+  --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13
+   |
+LL |     let Foo(mut a) = &Foo(0);
+   |             ^^^^^ `mut` dereferences the type of this binding
+   |
+   = warning: this changes meaning in Rust 2024
+   = note: for more information, see 123076
+help: this will change in edition 2024
+  --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13
+   |
+LL |     let Foo(mut a) = &Foo(0);
+   |             ^^^^^
+note: the lint level is defined here
+  --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:4:11
+   |
+LL | #![forbid(dereferencing_mut_binding)]
+   |           ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: dereferencing `mut` binding
+  --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:14:13
+   |
+LL |     let Foo(mut a) = &mut Foo(0);
+   |             ^^^^^ `mut` dereferences the type of this binding
+   |
+   = warning: this changes meaning in Rust 2024
+   = note: for more information, see 123076
+help: this will change in edition 2024
+  --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:14:13
+   |
+LL |     let Foo(mut a) = &mut Foo(0);
+   |             ^^^^^
+
+error: aborting due to 2 previous errors
+