-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #7000 - Jarcho:clone_on_copy_fp, r=llogiq
Improve `clone_on_copy` This also removes the `clone_on_copy_mut` test as the same thing is covered in the `clone_on_copy` test. changelog: `copy_on_clone` lint on chained method calls taking self by value changelog: `copy_on_clone` only lint when using the `Clone` trait changelog: `copy_on_clone` correct suggestion when the cloned value is a macro call.
- Loading branch information
Showing
5 changed files
with
156 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,52 @@ | ||
error: using `clone` on type `i32` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:23:5 | ||
--> $DIR/clone_on_copy.rs:24:5 | ||
| | ||
LL | 42.clone(); | ||
| ^^^^^^^^^^ help: try removing the `clone` call: `42` | ||
| | ||
= note: `-D clippy::clone-on-copy` implied by `-D warnings` | ||
|
||
error: using `clone` on type `i32` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:27:5 | ||
--> $DIR/clone_on_copy.rs:28:5 | ||
| | ||
LL | (&42).clone(); | ||
| ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` | ||
|
||
error: using `clone` on type `i32` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:30:5 | ||
--> $DIR/clone_on_copy.rs:31:5 | ||
| | ||
LL | rc.borrow().clone(); | ||
| ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` | ||
|
||
error: using `clone` on type `u32` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:34:5 | ||
| | ||
LL | x.clone().rotate_left(1); | ||
| ^^^^^^^^^ help: try removing the `clone` call: `x` | ||
|
||
error: using `clone` on type `i32` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:48:5 | ||
| | ||
LL | m!(42).clone(); | ||
| ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)` | ||
|
||
error: using `clone` on type `[u32; 2]` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:58:5 | ||
| | ||
LL | x.clone()[0]; | ||
| ^^^^^^^^^ help: try dereferencing it: `(*x)` | ||
|
||
error: using `clone` on type `char` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:36:14 | ||
--> $DIR/clone_on_copy.rs:68:14 | ||
| | ||
LL | is_ascii('z'.clone()); | ||
| ^^^^^^^^^^^ help: try removing the `clone` call: `'z'` | ||
|
||
error: using `clone` on type `i32` which implements the `Copy` trait | ||
--> $DIR/clone_on_copy.rs:40:14 | ||
--> $DIR/clone_on_copy.rs:72:14 | ||
| | ||
LL | vec.push(42.clone()); | ||
| ^^^^^^^^^^ help: try removing the `clone` call: `42` | ||
|
||
error: aborting due to 5 previous errors | ||
error: aborting due to 8 previous errors | ||
|
This file was deleted.
Oops, something went wrong.