Rust-clippy: Make clone_on_copy lint machine applicable

Created on 18 Nov 2019  Â·  3Comments  Â·  Source: rust-lang/rust-clippy

Copy/pasted from https://github.com/rust-lang/rustfix/issues/182:

This gives a warning instead of replacing it with the suggested code:

$ cargo +nightly fix -Z unstable-options --clippy
warning: using `clone` on a `Copy` type
   --> src/parse/mod.rs:258:27
    |
258 |                 location: self.next_location().clone(),
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*self.next_location()`

It would be really nice to have this be done automatically, since I currently have about 20 of these warnings in my code.

$ cargo +nightly --version
cargo 1.40.0-nightly (5da4b4d47 2019-10-28)
$ cargo +nightly clippy -V
clippy 0.0.212 (b4f17697 2019-11-14)
A-suggestion L-enhancement

Most helpful comment

Also write rustfix tests, we should avoid having any fixable lints without
tests

On Mon, Nov 18, 2019, 3:00 PM Philipp Krones notifications@github.com
wrote:

In theory the suggestion is already fixable by rustfix:

https://github.com/rust-lang/rust-clippy/blob/86b8643586aa39f36fb7a02e98c8d64d31415e70/clippy_lints/src/methods/mod.rs#L1721-L1725

Only thing left to do here is to figure out the applicability level. (And
maybe pass it through the snippet_with_applicability function)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/rust-clippy/issues/4826?email_source=notifications&email_token=AAMK6SH7JFBWLXYZ27YQ7GTQUMNADA5CNFSM4JOZMRIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEMHDPA#issuecomment-555250108,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAMK6SF2ABR5YXTALAG3I3TQUMNADANCNFSM4JOZMRIA
.

All 3 comments

cc @Manishearth

In theory the suggestion is already fixable by rustfix:
https://github.com/rust-lang/rust-clippy/blob/86b8643586aa39f36fb7a02e98c8d64d31415e70/clippy_lints/src/methods/mod.rs#L1721-L1725

Only thing left to do here is to figure out the applicability level. (And maybe pass it through the snippet_with_applicability function)

Also write rustfix tests, we should avoid having any fixable lints without
tests

On Mon, Nov 18, 2019, 3:00 PM Philipp Krones notifications@github.com
wrote:

In theory the suggestion is already fixable by rustfix:

https://github.com/rust-lang/rust-clippy/blob/86b8643586aa39f36fb7a02e98c8d64d31415e70/clippy_lints/src/methods/mod.rs#L1721-L1725

Only thing left to do here is to figure out the applicability level. (And
maybe pass it through the snippet_with_applicability function)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/rust-clippy/issues/4826?email_source=notifications&email_token=AAMK6SH7JFBWLXYZ27YQ7GTQUMNADA5CNFSM4JOZMRIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEMHDPA#issuecomment-555250108,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAMK6SF2ABR5YXTALAG3I3TQUMNADANCNFSM4JOZMRIA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nbaksalyar picture nbaksalyar  Â·  3Comments

matthiaskrgr picture matthiaskrgr  Â·  3Comments

spease picture spease  Â·  3Comments

Riateche picture Riateche  Â·  3Comments

0e4ef622 picture 0e4ef622  Â·  3Comments