Skip to content

Commit b76e042

Browse files
Add regression test for useless_vec with code comments
1 parent 1b85ae3 commit b76e042

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/ui/useless_vec.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@no-rustfix: no suggestions
2+
3+
#![warn(clippy::useless_vec)]
4+
5+
// Regression test for <https://github.com/rust-lang/rust-clippy/issues/13692>.
6+
fn foo() {
7+
// There should be no suggestion in this case.
8+
let _some_variable = vec![
9+
//~^ useless_vec
10+
1, 2, // i'm here to stay
11+
3, 4, // but this one going away ;-;
12+
]; // that is life anyways
13+
}
14+
15+
fn main() {}

tests/ui/useless_vec.stderr

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: useless use of `vec!`
2+
--> tests/ui/useless_vec.rs:8:26
3+
|
4+
LL | let _some_variable = vec![
5+
| __________________________^
6+
LL | |
7+
LL | | 1, 2, // i'm here to stay
8+
LL | | 3, 4, // but this one going away ;-;
9+
LL | | ]; // that is life anyways
10+
| |_____^
11+
|
12+
= note: `-D clippy::useless-vec` implied by `-D warnings`
13+
= help: to override `-D warnings` add `#[allow(clippy::useless_vec)]`
14+
help: you can use an array directly
15+
|
16+
LL ~ let _some_variable = [1, 2, // i'm here to stay
17+
LL ~ 3, 4]; // that is life anyways
18+
|
19+
20+
error: aborting due to 1 previous error
21+

0 commit comments

Comments
 (0)