-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for
useless_vec
with code comments
- Loading branch information
1 parent
1b85ae3
commit b76e042
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|