Ignoring lints added after a given Rust version · Issue #11227 · rust-lang/rust-clippy (original) (raw)

It would be nice to have a way to make Clippy ignore all lints that were added starting with a certain Rust version.

This would be useful to minimize the chance of breaking the build in projects that use -D for particular lint groups (or -W with -Dwarnings): once a new Rust version is released, and somebody builds the project, new lints may get added to the group, which would make the build fail. It can also be used to keep builds warning-free for everybody until the new lints are cleaned up.

A workaround for those projects is listing every single lint to enable by hand. As an example, in the Linux kernel, when we unpinned the compiler version and started supporting a minimum Rust version, we needed to move all our Clippy lint groups to -W, including -Wclippy::all, to avoid unexpected warnings and thus breaking Clippy-enabled builds with upcoming Rust versions.

The already-existing versioning information ("Added in: 1.x.y" rendered in the docs) could be used to drive this.

(Also, since it got mentioned at some point, Clippy's msrv does not currently solve this: that one is meant to disable lints pertaining to language/library/... features introduced in newer versions (e.g. a lint that suggests using let else that wouldn't be able to be used in an old version), rather than disabling lints introduced in newer versions.)

From: #11162 (comment).
Cc @tgross35 @flip1995 (and @jonhoo since Philipp said Jon mentioned it too).