about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAda Alakbarova <ada.alakbarova@proton.me>2025-08-02 09:13:16 +0200
committerAda Alakbarova <ada.alakbarova@proton.me>2025-08-02 09:48:12 +0200
commit0f98da7c5ccb5e873ddc08aef7508213a98b6aaa (patch)
tree3d1d31ba7d8e9e3d8a4428a530b3c531c4ca536a /tests
parent94b703588e1da6b7492375575da92c2859a3c39b (diff)
downloadrust-0f98da7c5ccb5e873ddc08aef7508213a98b6aaa.tar.gz
rust-0f98da7c5ccb5e873ddc08aef7508213a98b6aaa.zip
fix: let_with_type_underscore don't eat closing paren in let (i): _ = 0;
add failing tests

fix

also remove whitespace before `:`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/let_with_type_underscore.fixed12
-rw-r--r--tests/ui/let_with_type_underscore.rs12
-rw-r--r--tests/ui/let_with_type_underscore.stderr50
3 files changed, 73 insertions, 1 deletions
diff --git a/tests/ui/let_with_type_underscore.fixed b/tests/ui/let_with_type_underscore.fixed
index 7a4af4e3d1e..6339fe595c2 100644
--- a/tests/ui/let_with_type_underscore.fixed
+++ b/tests/ui/let_with_type_underscore.fixed
@@ -45,3 +45,15 @@ fn main() {
         x = ();
     };
 }
+
+fn issue15377() {
+    let (a) = 0;
+    //~^ let_with_type_underscore
+    let ((a)) = 0;
+    //~^ let_with_type_underscore
+    let ((a,)) = (0,);
+    //~^ let_with_type_underscore
+    #[rustfmt::skip]
+    let (   (a   )   ) = 0;
+    //~^ let_with_type_underscore
+}
diff --git a/tests/ui/let_with_type_underscore.rs b/tests/ui/let_with_type_underscore.rs
index a7c2f598b56..bd85346cf01 100644
--- a/tests/ui/let_with_type_underscore.rs
+++ b/tests/ui/let_with_type_underscore.rs
@@ -45,3 +45,15 @@ fn main() {
         x = ();
     };
 }
+
+fn issue15377() {
+    let (a): _ = 0;
+    //~^ let_with_type_underscore
+    let ((a)): _ = 0;
+    //~^ let_with_type_underscore
+    let ((a,)): _ = (0,);
+    //~^ let_with_type_underscore
+    #[rustfmt::skip]
+    let (   (a   )   ):  _ = 0;
+    //~^ let_with_type_underscore
+}
diff --git a/tests/ui/let_with_type_underscore.stderr b/tests/ui/let_with_type_underscore.stderr
index 9179f992207..c3f6c82397b 100644
--- a/tests/ui/let_with_type_underscore.stderr
+++ b/tests/ui/let_with_type_underscore.stderr
@@ -60,5 +60,53 @@ LL -     let x : _ = 1;
 LL +     let x = 1;
    |
 
-error: aborting due to 5 previous errors
+error: variable declared with type underscore
+  --> tests/ui/let_with_type_underscore.rs:50:5
+   |
+LL |     let (a): _ = 0;
+   |     ^^^^^^^^^^^^^^^
+   |
+help: remove the explicit type `_` declaration
+   |
+LL -     let (a): _ = 0;
+LL +     let (a) = 0;
+   |
+
+error: variable declared with type underscore
+  --> tests/ui/let_with_type_underscore.rs:52:5
+   |
+LL |     let ((a)): _ = 0;
+   |     ^^^^^^^^^^^^^^^^^
+   |
+help: remove the explicit type `_` declaration
+   |
+LL -     let ((a)): _ = 0;
+LL +     let ((a)) = 0;
+   |
+
+error: variable declared with type underscore
+  --> tests/ui/let_with_type_underscore.rs:54:5
+   |
+LL |     let ((a,)): _ = (0,);
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the explicit type `_` declaration
+   |
+LL -     let ((a,)): _ = (0,);
+LL +     let ((a,)) = (0,);
+   |
+
+error: variable declared with type underscore
+  --> tests/ui/let_with_type_underscore.rs:57:5
+   |
+LL |     let (   (a   )   ):  _ = 0;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: remove the explicit type `_` declaration
+   |
+LL -     let (   (a   )   ):  _ = 0;
+LL +     let (   (a   )   ) = 0;
+   |
+
+error: aborting due to 9 previous errors