Discoverability of rustc's allow-by-default lints

[note: I have no idea if I've posted this in the right category, of if it should have gone to users.rust-lang.org. Happy to move this elsewhere if I've gotten it wrong.]

Clippy has a lot of useful lints, and several ways to discover them:

  • Most of them are on by default if I just run clippy.
  • I can turn on #[warn(clippy:pedantic, clippy::nursery)] (or even clippy::restriction) and turn off any lints that don't seem useful (or turn it in temporarily then enable specific lints I discover I want)
  • I can read through ALL the Clippy lints, or use its search if I'm looking for something specific

rustc, too, has some useful lints that aren't on by default (for example, unsafe_code, missing_docs, and missing_debug_implementations, to name a few), but they're much harder to find:

  • They don't show up in the Clippy listing, so anyone looking there won't find them—they'd have to know about Rustc's list, which I imagine is lesser-known due to the small number of off-by-default rustc lints
  • Rustc's allow-by-default listing is hard to peruse, as it contains many very specific restrictions and lints from the 2018 Edition transition that aren't relevant today
  • There's no equivalent to #[warn(clippy::pedantic)] to allow me to opt into lots of warnings
    • In particular, this means that even if I did find some useful rustc lints to use, I would have to verbosely list them in every crate

I think some of these lints are actually useful enough that I imagine Clippy would enable them by default, and certainly with #[warn(clippy::pedantic)]. But because they're disabled by default in rustc, they don't get included in clippy and (I imagine) very few people find them and get the benefits.

Some ideas for how we could improve this—not saying we should necessarily do any or all of these, but hopefully they at least start a conversation:

  • Extend the excellent ALL the Clippy lints to include rustc lints as well
  • Add some rustc lints to Clippy's existing lint categories, where appropriate
  • Create new lint categories (something like rustc::pedantic or rustc::style) for potentially-useful but off-by-default rustc lints
5 Likes

I run from time to time:

cargo clippy -- -W clippy::pedantic

but admittedly this is an obscure syntax. It's made even more obscure by the fact that a simpler argument is an error (due to rules Cargo uses for integration with subcommands, which IMHO users shouldn't need to know about):

cargo clippy -W clippy::pedantic

It'd be nice if it supported something like:

cargo clippy --all-lints
1 Like