about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorllogiq <bogusandre@gmail.com>2025-06-08 13:21:14 +0000
committerGitHub <noreply@github.com>2025-06-08 13:21:14 +0000
commit9e7782b809383d7c9293d71be9334d4790b0915e (patch)
tree692def9fad41d0673ea25962735fb90555bf73b7 /tests
parent3af333e3469d7a49dd048f98f216698e85e5eebd (diff)
parentb5eac2482032277359ca3ccd621706ee931ef81e (diff)
downloadrust-9e7782b809383d7c9293d71be9334d4790b0915e.tar.gz
rust-9e7782b809383d7c9293d71be9334d4790b0915e.zip
Fix `match_single_binding` misses curlies on type signatures (#15017)
Closes rust-lang/rust-clippy#14991

----

changelog: [`match_single_binding`] fix missing curlies on type
signatures
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/match_single_binding.fixed16
-rw-r--r--tests/ui/match_single_binding.rs18
-rw-r--r--tests/ui/match_single_binding.stderr35
3 files changed, 68 insertions, 1 deletions
diff --git a/tests/ui/match_single_binding.fixed b/tests/ui/match_single_binding.fixed
index bdf39796ebf..e11dea35204 100644
--- a/tests/ui/match_single_binding.fixed
+++ b/tests/ui/match_single_binding.fixed
@@ -188,3 +188,19 @@ fn issue14634() {
     let id!(_a) = dbg!(b + 1);
     //~^^^ match_single_binding
 }
+
+mod issue14991 {
+    struct AnnoConstWOBlock {
+        inner: [(); {
+            let _n = 1;
+            42
+        }],
+    }
+
+    struct AnnoConstWBlock {
+        inner: [(); {
+            let _n = 1;
+            42
+        }],
+    }
+}
diff --git a/tests/ui/match_single_binding.rs b/tests/ui/match_single_binding.rs
index 419ff95d873..d498da30fc8 100644
--- a/tests/ui/match_single_binding.rs
+++ b/tests/ui/match_single_binding.rs
@@ -249,3 +249,21 @@ fn issue14634() {
     };
     //~^^^ match_single_binding
 }
+
+mod issue14991 {
+    struct AnnoConstWOBlock {
+        inner: [(); match 1 {
+            //~^ match_single_binding
+            _n => 42,
+        }],
+    }
+
+    struct AnnoConstWBlock {
+        inner: [(); {
+            match 1 {
+                //~^ match_single_binding
+                _n => 42,
+            }
+        }],
+    }
+}
diff --git a/tests/ui/match_single_binding.stderr b/tests/ui/match_single_binding.stderr
index bdd0134a5f1..f274f80c81d 100644
--- a/tests/ui/match_single_binding.stderr
+++ b/tests/ui/match_single_binding.stderr
@@ -378,5 +378,38 @@ LL ~     let id!(b) = dbg!(3);
 LL +     let id!(_a) = dbg!(b + 1);
    |
 
-error: aborting due to 27 previous errors
+error: this match could be written as a `let` statement
+  --> tests/ui/match_single_binding.rs:255:21
+   |
+LL |           inner: [(); match 1 {
+   |  _____________________^
+LL | |
+LL | |             _n => 42,
+LL | |         }],
+   | |_________^
+   |
+help: consider using a `let` statement
+   |
+LL ~         inner: [(); {
+LL +             let _n = 1;
+LL +             42
+LL ~         }],
+   |
+
+error: this match could be written as a `let` statement
+  --> tests/ui/match_single_binding.rs:263:13
+   |
+LL | /             match 1 {
+LL | |
+LL | |                 _n => 42,
+LL | |             }
+   | |_____________^
+   |
+help: consider using a `let` statement
+   |
+LL ~             let _n = 1;
+LL +             42
+   |
+
+error: aborting due to 29 previous errors