forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unsafe_vector_initialization lint
- Loading branch information
Showing
6 changed files
with
39 additions
and
98 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
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
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
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
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
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 |
---|---|---|
@@ -1,71 +1,60 @@ | ||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:25:5 | ||
--> $DIR/slow_vector_initialization.rs:22:5 | ||
| | ||
24 | let mut vec1 = Vec::with_capacity(len); | ||
21 | let mut vec1 = Vec::with_capacity(len); | ||
| ----------------------- help: consider replace allocation with: `vec![0; len]` | ||
25 | vec1.extend(repeat(0).take(len)); | ||
22 | vec1.extend(repeat(0).take(len)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::slow-vector-initialization` implied by `-D warnings` | ||
|
||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:29:5 | ||
--> $DIR/slow_vector_initialization.rs:26:5 | ||
| | ||
28 | let mut vec2 = Vec::with_capacity(len - 10); | ||
25 | let mut vec2 = Vec::with_capacity(len - 10); | ||
| ---------------------------- help: consider replace allocation with: `vec![0; len - 10]` | ||
29 | vec2.extend(repeat(0).take(len - 10)); | ||
26 | vec2.extend(repeat(0).take(len - 10)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:43:5 | ||
--> $DIR/slow_vector_initialization.rs:40:5 | ||
| | ||
42 | let mut resized_vec = Vec::with_capacity(30); | ||
39 | let mut resized_vec = Vec::with_capacity(30); | ||
| ---------------------- help: consider replace allocation with: `vec![0; 30]` | ||
43 | resized_vec.resize(30, 0); | ||
40 | resized_vec.resize(30, 0); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:46:5 | ||
--> $DIR/slow_vector_initialization.rs:43:5 | ||
| | ||
45 | let mut extend_vec = Vec::with_capacity(30); | ||
42 | let mut extend_vec = Vec::with_capacity(30); | ||
| ---------------------- help: consider replace allocation with: `vec![0; 30]` | ||
46 | extend_vec.extend(repeat(0).take(30)); | ||
43 | extend_vec.extend(repeat(0).take(30)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:53:5 | ||
--> $DIR/slow_vector_initialization.rs:50:5 | ||
| | ||
52 | let mut vec1 = Vec::with_capacity(len); | ||
49 | let mut vec1 = Vec::with_capacity(len); | ||
| ----------------------- help: consider replace allocation with: `vec![0; len]` | ||
53 | vec1.resize(len, 0); | ||
50 | vec1.resize(len, 0); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:61:5 | ||
--> $DIR/slow_vector_initialization.rs:58:5 | ||
| | ||
60 | let mut vec3 = Vec::with_capacity(len - 10); | ||
57 | let mut vec3 = Vec::with_capacity(len - 10); | ||
| ---------------------------- help: consider replace allocation with: `vec![0; len - 10]` | ||
61 | vec3.resize(len - 10, 0); | ||
58 | vec3.resize(len - 10, 0); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: slow zero-filling initialization | ||
--> $DIR/slow_vector_initialization.rs:65:5 | ||
--> $DIR/slow_vector_initialization.rs:62:5 | ||
| | ||
64 | vec1 = Vec::with_capacity(10); | ||
61 | vec1 = Vec::with_capacity(10); | ||
| ---------------------- help: consider replace allocation with: `vec![0; 10]` | ||
65 | vec1.resize(10, 0); | ||
62 | vec1.resize(10, 0); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: unsafe vector initialization | ||
--> $DIR/slow_vector_initialization.rs:72:9 | ||
| | ||
69 | let mut unsafe_vec: Vec<u8> = Vec::with_capacity(200); | ||
| ----------------------- help: consider replace allocation with: `vec![0; 200]` | ||
... | ||
72 | unsafe_vec.set_len(200); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::unsafe-vector-initialization` implied by `-D warnings` | ||
|
||
error: aborting due to 8 previous errors | ||
error: aborting due to 7 previous errors | ||
|