Skip to contentSkip to conversation

rust: give Clippy the minimum supported Rust version

RFC PATCH Applied Miguel Ojeda 3 participants 3 messages Nov 23, 2024 – Jan 10, 2025 Rust

lore
Share & tools
lore

Miguel Ojeda

author maintainer
#0 lore raw

RFC PATCH 1/1 rust: give Clippy the minimum supported Rust version

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].

---
 .clippy.toml | 2 ++
 1 file changed, 2 insertions(+)
.clippy.toml +2 -0
index e4c4eef10b28..815c94732ed7 100644
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
+msrv = "1.78.0"
+
 check-private-items = true
 
 disallowed-macros = [

base-commit: b2603f8ac8217bc59f5c7f248ac248423b9b99cb

Signature · 1 line
2.47.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Miguel Ojeda

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.

Quoted 6 lines

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

Applied
#2 lore raw
In reply to Miguel Ojeda
Quoted 19 lines · Miguel Ojeda

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.

Quoted 6 lines

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

Applied to rust-next -- thanks!

Cheers,
Miguel