Skip to content

Commit

Permalink
updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentine-Mario committed Jun 8, 2021
1 parent c1dd158 commit aa0dd65
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ impl_lint_pass!(Methods => [
INSPECT_FOR_EACH,
IMPLICIT_CLONE,
SUSPICIOUS_SPLITN,
MANUAL_STR_REPEAT
MANUAL_STR_REPEAT,
APPEND_INSTEAD_OF_EXTEND
]);

Expand Down
6 changes: 2 additions & 4 deletions tests/ui/append_instead_of_extend.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ fn main() {

vec4.append(&mut vec3);

let mut vec10 = return_vector();
let mut vec11: std::vec::Vec<u8> = Vec::new();

vec11.append(&mut vec10);
vec11.append(&mut return_vector());

//won't get linted it dosen't move the entire content of a vec into another
let mut test1 = vec![0u8, 10];
Expand All @@ -34,10 +33,9 @@ fn main() {

vec5.extend(vec6.drain(..4));

let mut vec8 = return_vector();
let mut vec9: std::vec::Vec<u8> = Vec::new();

vec8.append(&mut vec9);
return_vector().append(&mut vec9);

//won't get linted because it is not a vec

Expand Down
6 changes: 2 additions & 4 deletions tests/ui/append_instead_of_extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ fn main() {

vec4.extend(vec3.drain(..));

let mut vec10 = return_vector();
let mut vec11: std::vec::Vec<u8> = Vec::new();

vec11.extend(vec10.drain(..));
vec11.extend(return_vector().drain(..));

//won't get linted it dosen't move the entire content of a vec into another
let mut test1 = vec![0u8, 10];
Expand All @@ -34,10 +33,9 @@ fn main() {

vec5.extend(vec6.drain(..4));

let mut vec8 = return_vector();
let mut vec9: std::vec::Vec<u8> = Vec::new();

vec8.append(&mut vec9);
return_vector().append(&mut vec9);

//won't get linted because it is not a vec

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/append_instead_of_extend.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ LL | vec4.extend(vec3.drain(..));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec4.append(&mut vec3)`

error: use of `extend` instead of `append` for adding the full range of a second vector
--> $DIR/append_instead_of_extend.rs:19:5
--> $DIR/append_instead_of_extend.rs:18:5
|
LL | vec11.extend(vec10.drain(..));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec11.append(&mut vec10)`
LL | vec11.extend(return_vector().drain(..));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec11.append(&mut return_vector())`

error: aborting due to 3 previous errors

0 comments on commit aa0dd65

Please sign in to comment.