Skip to content

Commit

Permalink
Add regression test for useless_vec with code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 3, 2025
1 parent 1b85ae3 commit b76e042
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ui/useless_vec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@no-rustfix: no suggestions

#![warn(clippy::useless_vec)]

// Regression test for <https://github.com/rust-lang/rust-clippy/issues/13692>.
fn foo() {
// There should be no suggestion in this case.
let _some_variable = vec![
//~^ useless_vec
1, 2, // i'm here to stay
3, 4, // but this one going away ;-;
]; // that is life anyways
}

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/useless_vec.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error: useless use of `vec!`
--> tests/ui/useless_vec.rs:8:26
|
LL | let _some_variable = vec![
| __________________________^
LL | |
LL | | 1, 2, // i'm here to stay
LL | | 3, 4, // but this one going away ;-;
LL | | ]; // that is life anyways
| |_____^
|
= note: `-D clippy::useless-vec` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::useless_vec)]`
help: you can use an array directly
|
LL ~ let _some_variable = [1, 2, // i'm here to stay
LL ~ 3, 4]; // that is life anyways
|

error: aborting due to 1 previous error

0 comments on commit b76e042

Please sign in to comment.