about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorJ-ZhengLi <lizheng135@huawei.com>2024-02-24 00:35:48 +0800
committerJ-ZhengLi <lizheng135@huawei.com>2024-02-24 00:35:48 +0800
commit929f746b5c19f7bf8e52cc32a3bb868fef0461e6 (patch)
treef3981560f39105806601ec30132934ff2b8c4a7e /tests
parent0d83a3a18b0efb047fdf04d3ed906154b08e58d6 (diff)
downloadrust-929f746b5c19f7bf8e52cc32a3bb868fef0461e6.tar.gz
rust-929f746b5c19f7bf8e52cc32a3bb868fef0461e6.zip
fix the actual bug
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/vec.fixed4
-rw-r--r--tests/ui/vec.rs4
-rw-r--r--tests/ui/vec.stderr8
3 files changed, 15 insertions, 1 deletions
diff --git a/tests/ui/vec.fixed b/tests/ui/vec.fixed
index b318fd42f7c..9e755a82af4 100644
--- a/tests/ui/vec.fixed
+++ b/tests/ui/vec.fixed
@@ -217,3 +217,7 @@ fn issue_11958() {
     // should not lint, `String` is not `Copy`
     f(&vec!["test".to_owned(); 2]);
 }
+
+fn issue_12101() {
+    for a in &[1, 2] {}
+}
diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs
index 08ad6efa37f..c483271438b 100644
--- a/tests/ui/vec.rs
+++ b/tests/ui/vec.rs
@@ -217,3 +217,7 @@ fn issue_11958() {
     // should not lint, `String` is not `Copy`
     f(&vec!["test".to_owned(); 2]);
 }
+
+fn issue_12101() {
+    for a in &(vec![1, 2]) {}
+}
diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr
index 6fd4748fff3..3faea8033fe 100644
--- a/tests/ui/vec.stderr
+++ b/tests/ui/vec.stderr
@@ -121,5 +121,11 @@ error: useless use of `vec!`
 LL |     this_macro_doesnt_need_vec!(vec![1]);
    |                                 ^^^^^^^ help: you can use an array directly: `[1]`
 
-error: aborting due to 20 previous errors
+error: useless use of `vec!`
+  --> tests/ui/vec.rs:222:14
+   |
+LL |     for a in &(vec![1, 2]) {}
+   |              ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]`
+
+error: aborting due to 21 previous errors