Skip to content

Run clippy::pedantic on clippy codebase #3172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phansch opened this issue Sep 13, 2018 · 5 comments · Fixed by #3402
Closed

Run clippy::pedantic on clippy codebase #3172

phansch opened this issue Sep 13, 2018 · 5 comments · Fixed by #3402
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-help-wanted Call for participation: Help is requested to fix this issue.

Comments

@phansch
Copy link
Member

phansch commented Sep 13, 2018

As discovered by @mikerite, we currently don't run the pedantic lints over the clippy codebase.
There were about 70 warnings on Travis when it was enabled.

@phansch phansch added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Sep 13, 2018
@flip1995

This comment has been minimized.

@devonhollowood
Copy link
Contributor

So I was taking a look at fixing the various casting warnings, and I was wondering what the "right" way to address them is. For cast_possible_truncation, the casts can be replaced with a try_into().expect(...), which is easy enough. But for cast_sign_loss / cast_possible_wrap, the situation is a little trickier, because often we are doing something clever with the bits and it's fine for it to wrap. So what's the right way to express that it's okay to e.g. cast a i128 to a u128 and back in utils::{sext, unsext}? Should I just #[allow] these lints in these cases?

@Manishearth
Copy link
Member

Yeah, pedantic lints typically have a healthy helping of allow. If the "fix" isn't really improving things, just allow it.

@flip1995
Copy link
Member

Just tried again running clippy with -W clippy::pedantic on the clippy code base. Now it produces new warnings:

  • warning: called filter(p).map(q) on an Iterator. This is more succinctly expressed by calling .filter_map(..) instead.
    --> clippy_dev/src/lib.rs:78:5
  • warning: binding's name is too similar to existing binding
    --> clippy_lints/src/redundant_pattern_matching.rs:86:48
  • warning: binding's name is too similar to existing binding
    --> clippy_lints/src/redundant_pattern_matching.rs:138:57
  • warning: binding's name is too similar to existing binding
    --> clippy_lints/src/redundant_pattern_matching.rs:139:58
  • warning: it is more concise to loop over references to containers instead of using explicit iteration methods
    --> clippy_lints/src/methods/mod.rs:943:34
  • warning: casting usize to u32 may truncate the value on targets with 64-bit wide pointers
    --> clippy_lints/src/returns.rs:203:64

@matthiaskrgr
Copy link
Member

I have a wip branch for some of these, should get PR done soonish.

matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Nov 2, 2018
…odebase.

Turn on pedantic lints in dogfood and base tests.

needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap

Fixes rust-lang#3172

Squashed commit of the following:

commit 04575e5a29c0f1522d9b6d8b7786322432d028b8
Author: Matthias Krüger <[email protected]>
Date:   Fri Nov 2 11:25:05 2018 +0100

    turn on pedantic on ci

commit a3322d21e599c0a477eef499d9f7d830c9879de3
Author: Matthias Krüger <[email protected]>
Date:   Fri Nov 2 10:36:54 2018 +0100

    ! fix 3

    clippy::items-after-statements in  clippy_lints/src/needless_bool.rs

commit 6e690e07722d12b4bc16c04d2af49dca2d99fc3e
Author: Matthias Krüger <[email protected]>
Date:   Fri Nov 2 10:10:17 2018 +0100

    fix2

commit 33bc958c01499483ec1afb88e82b86d616e30284
Author: Matthias Krüger <[email protected]>
Date:   Fri Nov 2 10:09:18 2018 +0100

    fix

commit 3b38b01ba13eded0df67d53c36f0d1d9a87b70e6
Author: Matthias Krüger <[email protected]>
Date:   Wed Oct 31 13:45:58 2018 +0100

    WIP: enable pedantic on ci

commit 8b66fe31fee4c28e8919526a930b66016fd0c402
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 26 21:42:41 2018 +0200

    redundant pattern matching: fix clippy::similar-names pedantic lint warnings.
    mods.rs: fix clippy::explicit-iter-loop pedantic lint warning
    returns.rs: allow clippy::cast_possible_truncation
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Nov 2, 2018
…odebase.

Turn on pedantic lints in dogfood and base tests.

needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap

Fixes rust-lang#3172
bors bot added a commit that referenced this issue Nov 2, 2018
3402: clippy: fix pedantic warnings and run clippy::pedantic lints on the codebase r=oli-obk a=matthiaskrgr

Turn on pedantic lints in dogfood and base tests.

needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap

Fixes #3172

Co-authored-by: Matthias Krüger <[email protected]>
@bors bors bot closed this as completed in #3402 Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-help-wanted Call for participation: Help is requested to fix this issue.
Projects
None yet
5 participants