public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] rust: give Clippy the minimum supported Rust version
@ 2024-11-23 22:23 Miguel Ojeda
  2024-11-25  9:09 ` Alice Ryhl
  2025-01-10 10:44 ` Miguel Ojeda
  0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2024-11-23 22:23 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
	linux-kernel, patches

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 [1]
Link: https://github.com/rust-lang/compiler-team/issues/772 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 .clippy.toml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.clippy.toml b/.clippy.toml
index e4c4eef10b28..815c94732ed7 100644
--- a/.clippy.toml
+++ b/.clippy.toml
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
+msrv = "1.78.0"
+
 check-private-items = true
 
 disallowed-macros = [

base-commit: b2603f8ac8217bc59f5c7f248ac248423b9b99cb
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-10 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-23 22:23 [RFC PATCH] rust: give Clippy the minimum supported Rust version Miguel Ojeda
2024-11-25  9:09 ` Alice Ryhl
2025-01-10 10:44 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox