From 929f746b5c19f7bf8e52cc32a3bb868fef0461e6 Mon Sep 17 00:00:00 2001 From: J-ZhengLi Date: Sat, 24 Feb 2024 00:35:48 +0800 Subject: fix the actual bug --- tests/ui/vec.fixed | 4 ++++ tests/ui/vec.rs | 4 ++++ tests/ui/vec.stderr | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'tests') 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 -- cgit 1.4.1-3-g733a5