* [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest
@ 2026-03-04 19:53 John Hubbard
2026-03-04 20:06 ` Gary Guo
2026-03-04 20:30 ` [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest Gary Guo
0 siblings, 2 replies; 19+ messages in thread
From: John Hubbard @ 2026-03-04 19:53 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar
Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, linux-pm, rust-for-linux, LKML, John Hubbard
Clippy reports:
warning: consider removing unnecessary double parentheses
--> rust/kernel/cpufreq.rs:410:60
|
410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fix this by using separate format arguments.
Fixes: 6ebdd7c93177 ("rust: cpufreq: Extend abstractions for policy and driver ops")
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
rust/kernel/cpufreq.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index 76faa1ac8501..e94a17731557 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -407,7 +407,7 @@ pub fn to_table(mut self) -> Result<TableBox> {
/// .set_fast_switch_possible(true)
/// .set_transition_latency_ns(DEFAULT_TRANSITION_LATENCY_NS);
///
-/// pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur()));
+/// pr_info!("The policy details are: cpu={:?}, cur={:?}\n", policy.cpu(), policy.cur());
/// }
/// ```
#[repr(transparent)]
base-commit: ecc64d2dc9ff9738d2a896beb68e02c2feaf9a02
--
2.53.0
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 19:53 [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest John Hubbard @ 2026-03-04 20:06 ` Gary Guo 2026-03-04 20:07 ` John Hubbard 2026-03-04 20:30 ` [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest Gary Guo 1 sibling, 1 reply; 19+ messages in thread From: Gary Guo @ 2026-03-04 20:06 UTC (permalink / raw) To: John Hubbard, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: > Clippy reports: > warning: consider removing unnecessary double parentheses > --> rust/kernel/cpufreq.rs:410:60 > | > 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This looks like a false positive, probably due to how our fmt macro works? Best, Gary > > Fix this by using separate format arguments. > > Fixes: 6ebdd7c93177 ("rust: cpufreq: Extend abstractions for policy and driver ops") > Signed-off-by: John Hubbard <jhubbard@nvidia.com> > --- > rust/kernel/cpufreq.rs | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs > index 76faa1ac8501..e94a17731557 100644 > --- a/rust/kernel/cpufreq.rs > +++ b/rust/kernel/cpufreq.rs > @@ -407,7 +407,7 @@ pub fn to_table(mut self) -> Result<TableBox> { > /// .set_fast_switch_possible(true) > /// .set_transition_latency_ns(DEFAULT_TRANSITION_LATENCY_NS); > /// > -/// pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); > +/// pr_info!("The policy details are: cpu={:?}, cur={:?}\n", policy.cpu(), policy.cur()); > /// } > /// ``` > #[repr(transparent)] > > base-commit: ecc64d2dc9ff9738d2a896beb68e02c2feaf9a02 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 20:06 ` Gary Guo @ 2026-03-04 20:07 ` John Hubbard 2026-03-04 20:28 ` Gary Guo 0 siblings, 1 reply; 19+ messages in thread From: John Hubbard @ 2026-03-04 20:07 UTC (permalink / raw) To: Gary Guo, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On 3/4/26 12:06 PM, Gary Guo wrote: > On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: >> Clippy reports: >> warning: consider removing unnecessary double parentheses >> --> rust/kernel/cpufreq.rs:410:60 >> | >> 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); >> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > This looks like a false positive, probably due to how our fmt macro works? Probably, but in any case we need to remain clippy clean, so this work-around seems about right, yes? thanks, -- John Hubbard ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 20:07 ` John Hubbard @ 2026-03-04 20:28 ` Gary Guo 2026-03-04 20:32 ` John Hubbard 2026-03-04 20:39 ` Gary Guo 0 siblings, 2 replies; 19+ messages in thread From: Gary Guo @ 2026-03-04 20:28 UTC (permalink / raw) To: John Hubbard, Gary Guo, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On Wed Mar 4, 2026 at 8:07 PM GMT, John Hubbard wrote: > On 3/4/26 12:06 PM, Gary Guo wrote: >> On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: >>> Clippy reports: >>> warning: consider removing unnecessary double parentheses >>> --> rust/kernel/cpufreq.rs:410:60 >>> | >>> 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); >>> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> >> This looks like a false positive, probably due to how our fmt macro works? > > Probably, but in any case we need to remain clippy clean, so this > work-around seems about right, yes? > > > thanks, Can you try this? Best, Gary -- >8 -- diff --git a/rust/macros/fmt.rs b/rust/macros/fmt.rs index ce6c7249305a..51988a69af21 100644 --- a/rust/macros/fmt.rs +++ b/rust/macros/fmt.rs @@ -2,7 +2,7 @@ use std::collections::BTreeSet; -use proc_macro2::{Ident, TokenStream, TokenTree}; +use proc_macro2::{Group, Ident, TokenStream, TokenTree}; use quote::quote_spanned; /// Please see [`crate::fmt`] for documentation. @@ -69,7 +69,8 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream { } (None, acc) })(); - args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs)))); + let rhs = Group::new(proc_macro2::Delimiter::None, rhs); + args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs))); } }; ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 20:28 ` Gary Guo @ 2026-03-04 20:32 ` John Hubbard 2026-03-04 20:39 ` Gary Guo 1 sibling, 0 replies; 19+ messages in thread From: John Hubbard @ 2026-03-04 20:32 UTC (permalink / raw) To: Gary Guo, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On 3/4/26 12:28 PM, Gary Guo wrote: > On Wed Mar 4, 2026 at 8:07 PM GMT, John Hubbard wrote: >> On 3/4/26 12:06 PM, Gary Guo wrote: >>> On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: >>>> Clippy reports: >>>> warning: consider removing unnecessary double parentheses >>>> --> rust/kernel/cpufreq.rs:410:60 >>>> | >>>> 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); >>>> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >>> >>> This looks like a false positive, probably due to how our fmt macro works? >> >> Probably, but in any case we need to remain clippy clean, so this >> work-around seems about right, yes? >> >> >> thanks, > > Can you try this? > > Best, > Gary > > -- >8 -- > > diff --git a/rust/macros/fmt.rs b/rust/macros/fmt.rs > index ce6c7249305a..51988a69af21 100644 > --- a/rust/macros/fmt.rs > +++ b/rust/macros/fmt.rs > @@ -2,7 +2,7 @@ > > use std::collections::BTreeSet; > > -use proc_macro2::{Ident, TokenStream, TokenTree}; > +use proc_macro2::{Group, Ident, TokenStream, TokenTree}; > use quote::quote_spanned; > > /// Please see [`crate::fmt`] for documentation. > @@ -69,7 +69,8 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream { > } > (None, acc) > })(); > - args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs)))); > + let rhs = Group::new(proc_macro2::Delimiter::None, rhs); > + args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs))); > } > }; That works nicely. thanks, -- John Hubbard ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 20:28 ` Gary Guo 2026-03-04 20:32 ` John Hubbard @ 2026-03-04 20:39 ` Gary Guo 2026-03-04 21:13 ` John Hubbard 1 sibling, 1 reply; 19+ messages in thread From: Gary Guo @ 2026-03-04 20:39 UTC (permalink / raw) To: Gary Guo, John Hubbard, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On Wed Mar 4, 2026 at 8:28 PM GMT, Gary Guo wrote: > On Wed Mar 4, 2026 at 8:07 PM GMT, John Hubbard wrote: >> On 3/4/26 12:06 PM, Gary Guo wrote: >>> On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: >>>> Clippy reports: >>>> warning: consider removing unnecessary double parentheses >>>> --> rust/kernel/cpufreq.rs:410:60 >>>> | >>>> 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); >>>> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >>> >>> This looks like a false positive, probably due to how our fmt macro works? >> >> Probably, but in any case we need to remain clippy clean, so this >> work-around seems about right, yes? >> >> >> thanks, > > Can you try this? > > Best, > Gary > > -- >8 -- > > diff --git a/rust/macros/fmt.rs b/rust/macros/fmt.rs > index ce6c7249305a..51988a69af21 100644 > --- a/rust/macros/fmt.rs > +++ b/rust/macros/fmt.rs > @@ -2,7 +2,7 @@ > > use std::collections::BTreeSet; > > -use proc_macro2::{Ident, TokenStream, TokenTree}; > +use proc_macro2::{Group, Ident, TokenStream, TokenTree}; > use quote::quote_spanned; > > /// Please see [`crate::fmt`] for documentation. > @@ -69,7 +69,8 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream { > } > (None, acc) > })(); > - args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs)))); > + let rhs = Group::new(proc_macro2::Delimiter::None, rhs); > + args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs))); Actually `Delimiter::None` isn't fully fixed [1], so perhaps let's done use this approach. Injecting a `#[allow(clippy::double_parens)]` would probably a better approach today. Best, Gary Link: https://github.com/rust-lang/rust/issues/67062 [1] > } > }; ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 20:39 ` Gary Guo @ 2026-03-04 21:13 ` John Hubbard 2026-03-05 12:31 ` Gary Guo 0 siblings, 1 reply; 19+ messages in thread From: John Hubbard @ 2026-03-04 21:13 UTC (permalink / raw) To: Gary Guo, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On 3/4/26 12:39 PM, Gary Guo wrote: ... > Actually `Delimiter::None` isn't fully fixed [1], so perhaps let's done use this > approach. > > Injecting a `#[allow(clippy::double_parens)]` would probably a better approach > today. > OK, so that gets us here: commit 924f411d6cd0cc4d702f197566f5e701915d5760 (HEAD -> fix-clippy-double-parens-v2) Author: John Hubbard <jhubbard@nvidia.com> Date: Wed Mar 4 13:07:43 2026 -0800 scripts/rustdoc_test_gen.rs: suppress clippy::double_parens in doctests The fmt! proc macro wraps each format argument like &(arg). Writing a tuple argument such as (a, b) produces &((a, b)) after expansion. Clippy flags that as double parens, but the user has no way to avoid it because the outer parens come from the macro template. Add clippy::double_parens to the existing #![allow(...)] in the generated doctest wrapper block. This only covers doctests, but no non-doctest code in the tree currently passes a tuple to a printing macro. Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: John Hubbard <jhubbard@nvidia.com> diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs index d61a77219a8c..e9ca56a3b73d 100644 --- a/scripts/rustdoc_test_gen.rs +++ b/scripts/rustdoc_test_gen.rs @@ -208,7 +208,7 @@ macro_rules! assert_eq {{ #[allow(unused)] static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 2; {{ - #![allow(unreachable_pub, clippy::disallowed_names)] + #![allow(unreachable_pub, clippy::disallowed_names, clippy::double_parens)] {body} main(); }} thanks, -- John Hubbard ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 21:13 ` John Hubbard @ 2026-03-05 12:31 ` Gary Guo 2026-03-06 12:36 ` Miguel Ojeda 0 siblings, 1 reply; 19+ messages in thread From: Gary Guo @ 2026-03-05 12:31 UTC (permalink / raw) To: John Hubbard, Gary Guo, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On Wed Mar 4, 2026 at 9:13 PM GMT, John Hubbard wrote: > On 3/4/26 12:39 PM, Gary Guo wrote: > ... >> Actually `Delimiter::None` isn't fully fixed [1], so perhaps let's done use this >> approach. >> >> Injecting a `#[allow(clippy::double_parens)]` would probably a better approach >> today. >> > > OK, so that gets us here: > > commit 924f411d6cd0cc4d702f197566f5e701915d5760 (HEAD -> fix-clippy-double-parens-v2) > Author: John Hubbard <jhubbard@nvidia.com> > Date: Wed Mar 4 13:07:43 2026 -0800 > > scripts/rustdoc_test_gen.rs: suppress clippy::double_parens in doctests > > The fmt! proc macro wraps each format argument like &(arg). Writing a > tuple argument such as (a, b) produces &((a, b)) after expansion. > Clippy flags that as double parens, but the user has no way to avoid > it because the outer parens come from the macro template. > > Add clippy::double_parens to the existing #![allow(...)] in the > generated doctest wrapper block. This only covers doctests, but no > non-doctest code in the tree currently passes a tuple to a printing > macro. I think we should either disable with #[allow(clippy::double_parens, reason = "false positive before 1.92")] fn update_policy(policy: &mut Policy) { or disable it globally for all Rust code before 1.92. Miguel, which one do you think is better? Best, Gary > > Suggested-by: Gary Guo <gary@garyguo.net> > Signed-off-by: John Hubbard <jhubbard@nvidia.com> > > diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs > index d61a77219a8c..e9ca56a3b73d 100644 > --- a/scripts/rustdoc_test_gen.rs > +++ b/scripts/rustdoc_test_gen.rs > @@ -208,7 +208,7 @@ macro_rules! assert_eq {{ > #[allow(unused)] > static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 2; > {{ > - #![allow(unreachable_pub, clippy::disallowed_names)] > + #![allow(unreachable_pub, clippy::disallowed_names, clippy::double_parens)] > {body} > main(); > }} > > > thanks, ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-05 12:31 ` Gary Guo @ 2026-03-06 12:36 ` Miguel Ojeda 2026-03-07 17:09 ` [RFC PATCH] rust: kbuild: support global per-version flags Miguel Ojeda 0 siblings, 1 reply; 19+ messages in thread From: Miguel Ojeda @ 2026-03-06 12:36 UTC (permalink / raw) To: Gary Guo Cc: John Hubbard, Rafael J . Wysocki, Viresh Kumar, Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On Thu, Mar 5, 2026 at 1:32 PM Gary Guo <gary@garyguo.net> wrote: > > I think we should either disable with > > #[allow(clippy::double_parens, reason = "false positive before 1.92")] > fn update_policy(policy: &mut Policy) { > > or disable it globally for all Rust code before 1.92. > > Miguel, which one do you think is better? Hmm... Disabling globally for all versions could also be an option -- not having this lint doesn't sound like a big deal, I think. I guess it depends on how prevalent it is, i.e. how much we expect to hit it for the 1.5 years or so (since we will eventually bump above it anyway). Or do you think the lint is very valuable? Doing it globally for certain versions (i.e. `rust_common_flags`, not just `KBUILD_RUSTFLAGS`) requires a bit of reorganization, so for simplicity here in this series I would suggest a local `allow`, and then we can see later on how prevalent it is to decide whether to do it locally (whether per version or not). I hope that helps. Cheers, Miguel ^ permalink raw reply [flat|nested] 19+ messages in thread
* [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-06 12:36 ` Miguel Ojeda @ 2026-03-07 17:09 ` Miguel Ojeda 2026-03-15 21:21 ` Miguel Ojeda 0 siblings, 1 reply; 19+ messages in thread From: Miguel Ojeda @ 2026-03-07 17:09 UTC (permalink / raw) To: miguel.ojeda.sandonis Cc: a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, jhubbard, linux-kernel, linux-pm, lossin, ojeda, rafael, rust-for-linux, tmgross, viresh.kumar Sometimes it is useful to gate global Rust flags per compiler version. For instance, we may want to disable a lint that has false positives in a single version [1]. We already had helpers like `rustc-min-version` for that, which we use elsewhere, but we cannot currently use them for `rust_common_flags`, which contains the global flags for all Rust code (kernel and host), because `rustc-min-version` depends on `CONFIG_RUSTC_VERSION`, which does not exist when `rust_common_flags` is defined. Thus, to support that, introduce `rust_common_flags_per_version`, defined after the `include/config/auto.conf` inclusion (where `CONFIG_RUSTC_VERSION` becomes available), and append it to `rust_common_flags`, `KBUILD_HOSTRUSTFLAGS` and `KBUILD_RUSTFLAGS`. An alternative is moving all those three down, but that would mean separating them from the other `KBUILD_*` variables. Link: https://lore.kernel.org/rust-for-linux/CANiq72mWdFU11GcCZRchzhy0Gi1QZShvZtyRkHV2O+WA2uTdVQ@mail.gmail.com/ [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org> --- > Doing it globally for certain versions (i.e. `rust_common_flags`, not > just `KBUILD_RUSTFLAGS`) requires a bit of reorganization, If we wanted to go for a per-version global one, we we would need something like this patch -- sending it here so that it gets archived in case we need it. Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 2446085983f7..a49cddb0599b 100644 --- a/Makefile +++ b/Makefile @@ -833,6 +833,14 @@ endif # CONFIG_TRACEPOINTS export WARN_ON_UNUSED_TRACEPOINTS +# Per-version Rust flags. These are like `rust_common_flags`, but may +# depend on the Rust compiler version (e.g. using `rustc-min-version`). +rust_common_flags_per_version := + +rust_common_flags += $(rust_common_flags_per_version) +KBUILD_HOSTRUSTFLAGS += $(rust_common_flags_per_version) +KBUILD_RUSTFLAGS += $(rust_common_flags_per_version) + include $(srctree)/arch/$(SRCARCH)/Makefile ifdef need-config base-commit: 11439c4635edd669ae435eec308f4ab8a0804808 -- 2.53.0 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-07 17:09 ` [RFC PATCH] rust: kbuild: support global per-version flags Miguel Ojeda @ 2026-03-15 21:21 ` Miguel Ojeda 2026-03-15 21:22 ` Miguel Ojeda 2026-03-16 0:04 ` Mark Brown 0 siblings, 2 replies; 19+ messages in thread From: Miguel Ojeda @ 2026-03-15 21:21 UTC (permalink / raw) To: Miguel Ojeda Cc: a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar, Mark Brown On Sat, Mar 7, 2026 at 6:09 PM Miguel Ojeda <ojeda@kernel.org> wrote: > > Sometimes it is useful to gate global Rust flags per compiler version. > For instance, we may want to disable a lint that has false positives in > a single version [1]. Regarding this, we currently have a warning on 1.85.1 for `clippy::precedence` and a few in 1.88.0 for `clippy::uninlined_format_args`, so we could use this to sort those out (plus `clippy::double_parens` for 1.92.0). (We will see how hard it is to keep all these versions clean in the medium-term future when more Rust is in the kernel: we have the MSRV bump cadence now with Debian Stable, so it may be doable, but worst case we could consider relaxing the policy to just the latest stable release and whatever linux-next runs). Cheers, Miguel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-15 21:21 ` Miguel Ojeda @ 2026-03-15 21:22 ` Miguel Ojeda 2026-03-16 0:04 ` Mark Brown 1 sibling, 0 replies; 19+ messages in thread From: Miguel Ojeda @ 2026-03-15 21:22 UTC (permalink / raw) To: Miguel Ojeda Cc: a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar, Mark Brown On Sun, Mar 15, 2026 at 10:21 PM Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > > plus `clippy::double_parens` for 1.92.0). I mean < 1.92.0. Cheers, Miguel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-15 21:21 ` Miguel Ojeda 2026-03-15 21:22 ` Miguel Ojeda @ 2026-03-16 0:04 ` Mark Brown 2026-03-16 4:49 ` Miguel Ojeda 1 sibling, 1 reply; 19+ messages in thread From: Mark Brown @ 2026-03-16 0:04 UTC (permalink / raw) To: Miguel Ojeda Cc: Miguel Ojeda, a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar [-- Attachment #1: Type: text/plain, Size: 457 bytes --] On Sun, Mar 15, 2026 at 10:21:04PM +0100, Miguel Ojeda wrote: > (We will see how hard it is to keep all these versions clean in the > medium-term future when more Rust is in the kernel: we have the MSRV > bump cadence now with Debian Stable, so it may be doable, but worst > case we could consider relaxing the policy to just the latest stable > release and whatever linux-next runs). At the minute whatever linux-next runs is whatever Debian stable has! [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-16 0:04 ` Mark Brown @ 2026-03-16 4:49 ` Miguel Ojeda 2026-03-16 12:50 ` Mark Brown 0 siblings, 1 reply; 19+ messages in thread From: Miguel Ojeda @ 2026-03-16 4:49 UTC (permalink / raw) To: Mark Brown Cc: Miguel Ojeda, a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar On Mon, Mar 16, 2026 at 1:04 AM Mark Brown <broonie@kernel.org> wrote: > > At the minute whatever linux-next runs is whatever Debian stable has! Great, that would mean we are effectively keeping the minimum one clean, which is in a way the best we can do (apart from the maximum) if we don't try to keep every single version clean between them. It is also what we have asked patch submitters to do so far, i.e. to keep things clean for both the minimum and the maximum: https://rust-for-linux.com/contributing#submit-checklist-addendum Thanks for confirming! Cheers, Miguel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-16 4:49 ` Miguel Ojeda @ 2026-03-16 12:50 ` Mark Brown 2026-03-16 12:31 ` Danilo Krummrich 2026-03-16 13:42 ` Miguel Ojeda 0 siblings, 2 replies; 19+ messages in thread From: Mark Brown @ 2026-03-16 12:50 UTC (permalink / raw) To: Miguel Ojeda Cc: Miguel Ojeda, a.hindborg, aliceryhl, bjorn3_gh, boqun, dakr, gary, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar [-- Attachment #1: Type: text/plain, Size: 2208 bytes --] On Mon, Mar 16, 2026 at 05:49:02AM +0100, Miguel Ojeda wrote: > On Mon, Mar 16, 2026 at 1:04 AM Mark Brown <broonie@kernel.org> wrote: > > At the minute whatever linux-next runs is whatever Debian stable has! > Great, that would mean we are effectively keeping the minimum one > clean, which is in a way the best we can do (apart from the maximum) > if we don't try to keep every single version clean between them. Note that I've not started running with clippy yet, currently due to Linus' tree having: error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0` --> /tmp/next/build/rust/kernel/ptr/projection.rs:79:26 | 79 | if self >= slice.len() { | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv = note: `-D clippy::incompatible-msrv` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]` error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0` --> /tmp/next/build/rust/kernel/ptr/projection.rs:95:29 | 95 | if self.end > slice.len() { | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0` --> /tmp/next/build/rust/kernel/ptr/projection.rs:121:28 | 121 | (self.start..slice.len()).get(slice) | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0` --> /tmp/next/build/rust/kernel/ptr.rs:253:11 | 253 | p.len() * size_of::<T>() | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv error: aborting due to 4 previous errors [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-16 12:50 ` Mark Brown @ 2026-03-16 12:31 ` Danilo Krummrich 2026-03-16 13:42 ` Miguel Ojeda 1 sibling, 0 replies; 19+ messages in thread From: Danilo Krummrich @ 2026-03-16 12:31 UTC (permalink / raw) To: Mark Brown Cc: Miguel Ojeda, Miguel Ojeda, a.hindborg, aliceryhl, bjorn3_gh, boqun, gary, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar On Mon Mar 16, 2026 at 1:50 PM CET, Mark Brown wrote: > On Mon, Mar 16, 2026 at 05:49:02AM +0100, Miguel Ojeda wrote: >> On Mon, Mar 16, 2026 at 1:04 AM Mark Brown <broonie@kernel.org> wrote: > >> > At the minute whatever linux-next runs is whatever Debian stable has! > >> Great, that would mean we are effectively keeping the minimum one >> clean, which is in a way the best we can do (apart from the maximum) >> if we don't try to keep every single version clean between them. > > Note that I've not started running with clippy yet, currently due to > Linus' tree having: > > error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0` > --> /tmp/next/build/rust/kernel/ptr/projection.rs:79:26 > | > 79 | if self >= slice.len() { > | ^^^^^ > | > = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv > = note: `-D clippy::incompatible-msrv` implied by `-D warnings` > = help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]` Interesting, I neither see this with 1.78.0 nor 1.94.0, but I can indeed reproduce this with 1.85.1. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RFC PATCH] rust: kbuild: support global per-version flags 2026-03-16 12:50 ` Mark Brown 2026-03-16 12:31 ` Danilo Krummrich @ 2026-03-16 13:42 ` Miguel Ojeda 1 sibling, 0 replies; 19+ messages in thread From: Miguel Ojeda @ 2026-03-16 13:42 UTC (permalink / raw) To: Mark Brown, Tamir Duberstein Cc: Miguel Ojeda, a.hindborg, aliceryhl, bjorn3_gh, boqun, gary, dakr, jhubbard, linux-kernel, linux-pm, lossin, rafael, rust-for-linux, tmgross, viresh.kumar On Mon, Mar 16, 2026 at 1:50 PM Mark Brown <broonie@kernel.org> wrote: > > Note that I've not started running with clippy yet, currently due to > Linus' tree having: > > error: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0` This was fixed in upstream Clippy in Rust 1.90.0 due to a request we made (thanks to Tamir): https://github.com/rust-lang/rust-clippy/issues/14425 I would suggest to allow the lint locally (perhaps once at the top of the file). This will go away this cycle since I am going to bump the minimum version to Debian Trixie's. Alternatively, we could use the patch above to add `clippy::incompatible_msrv`, but that is more involved, and allowing it locally is what we did elsewhere too. Cheers, Miguel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 19:53 [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest John Hubbard 2026-03-04 20:06 ` Gary Guo @ 2026-03-04 20:30 ` Gary Guo 2026-03-04 20:34 ` John Hubbard 1 sibling, 1 reply; 19+ messages in thread From: Gary Guo @ 2026-03-04 20:30 UTC (permalink / raw) To: John Hubbard, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: > Clippy reports: > warning: consider removing unnecessary double parentheses > --> rust/kernel/cpufreq.rs:410:60 > | > 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This looks like a Clippy bug that's fixed in latest Clippy: https://github.com/rust-lang/rust-clippy/pull/15939 Best, Gary > Fix this by using separate format arguments. > > Fixes: 6ebdd7c93177 ("rust: cpufreq: Extend abstractions for policy and driver ops") > Signed-off-by: John Hubbard <jhubbard@nvidia.com> > --- > rust/kernel/cpufreq.rs | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs > index 76faa1ac8501..e94a17731557 100644 > --- a/rust/kernel/cpufreq.rs > +++ b/rust/kernel/cpufreq.rs > @@ -407,7 +407,7 @@ pub fn to_table(mut self) -> Result<TableBox> { > /// .set_fast_switch_possible(true) > /// .set_transition_latency_ns(DEFAULT_TRANSITION_LATENCY_NS); > /// > -/// pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); > +/// pr_info!("The policy details are: cpu={:?}, cur={:?}\n", policy.cpu(), policy.cur()); > /// } > /// ``` > #[repr(transparent)] > > base-commit: ecc64d2dc9ff9738d2a896beb68e02c2feaf9a02 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest 2026-03-04 20:30 ` [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest Gary Guo @ 2026-03-04 20:34 ` John Hubbard 0 siblings, 0 replies; 19+ messages in thread From: John Hubbard @ 2026-03-04 20:34 UTC (permalink / raw) To: Gary Guo, Rafael J . Wysocki, Viresh Kumar Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux, LKML On 3/4/26 12:30 PM, Gary Guo wrote: > On Wed Mar 4, 2026 at 7:53 PM GMT, John Hubbard wrote: >> Clippy reports: >> warning: consider removing unnecessary double parentheses >> --> rust/kernel/cpufreq.rs:410:60 >> | >> 410 | pr_info!("The policy details are: {:?}\n", (policy.cpu(), policy.cur())); >> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> > > This looks like a Clippy bug that's fixed in latest Clippy: > > https://github.com/rust-lang/rust-clippy/pull/15939 > Looks like it, yes. I'm using the 1.78 toolchain because it is the oldest and we are supposed to verify that builds work with the oldest: <blueforge> linux-github (fix-clippy-double-parens-v2)$ clippy-driver --version clippy 0.1.78 (9b00956 2024-04-29) <blueforge> linux-github (fix-clippy-double-parens-v2)$ rustup which clippy-driver /home/jhubbard/.rustup/toolchains/1.78.0-x86_64-unknown-linux-gnu/bin/clippy-driver I'm not sure if this means we should workaround the problem or not. thanks, -- John Hubbard ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-03-16 13:42 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-04 19:53 [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest John Hubbard 2026-03-04 20:06 ` Gary Guo 2026-03-04 20:07 ` John Hubbard 2026-03-04 20:28 ` Gary Guo 2026-03-04 20:32 ` John Hubbard 2026-03-04 20:39 ` Gary Guo 2026-03-04 21:13 ` John Hubbard 2026-03-05 12:31 ` Gary Guo 2026-03-06 12:36 ` Miguel Ojeda 2026-03-07 17:09 ` [RFC PATCH] rust: kbuild: support global per-version flags Miguel Ojeda 2026-03-15 21:21 ` Miguel Ojeda 2026-03-15 21:22 ` Miguel Ojeda 2026-03-16 0:04 ` Mark Brown 2026-03-16 4:49 ` Miguel Ojeda 2026-03-16 12:50 ` Mark Brown 2026-03-16 12:31 ` Danilo Krummrich 2026-03-16 13:42 ` Miguel Ojeda 2026-03-04 20:30 ` [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest Gary Guo 2026-03-04 20:34 ` John Hubbard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox