]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: give Clippy the minimum supported Rust version
authorMiguel Ojeda <ojeda@kernel.org>
Sat, 23 Nov 2024 22:23:45 +0000 (23:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2025 08:48:44 +0000 (09:48 +0100)
commit f0915acd1fc6060a35e3f18673072671583ff0be upstream.

Clippy's lints may avoid emitting a suggestion to use a language or
library feature that is not supported by the minimum supported version,
if given by the `msrv` field in the configuration file.

For instance, Clippy should not suggest using `let ... else` in a lint
if the MSRV did not implement that syntax.

If the MSRV is not provided, Clippy will assume all features are available.

Thus enable it with the minimum Rust version the kernel supports.

Note that there is currently a small disadvantage in doing so: since
we still use unstable features that nevertheless work in the range
of versions we support (e.g. `#[expect(...)]`), we lose suggestions
for those. However, over time we will stop using unstable features
(especially language and library ones) as it is our goal, thus, in the
end, we will want to have the `msrv` set.

Rust is also considering adding a similar feature in `rustc` too, which
we should probably enable if it becomes available [2].

Link: https://github.com/rust-lang/rust-clippy/blob/8298da72e7b81fa30c515631b40fc4c0845948cb/clippy_utils/src/msrvs.rs#L20
Link: https://github.com/rust-lang/compiler-team/issues/772
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20241123222345.346976-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
.clippy.toml

index 5d99a317f7d6fcbcf753c0731eaf9457d792609e..137f41d203de377aacbbe237086f05d6a7ac3bab 100644 (file)
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
+msrv = "1.78.0"
+
 check-private-items = true
 
 disallowed-macros = [