rust: cpufreq: suppress clippy::double_parens in Policy doctest
Subsystems (2)
v2 cover rust: cpufreq: suppress clippy::double_parens in Policy doctest
The kernel fmt! proc macro wraps each format argument as &(arg). Passing a tuple like (a, b) produces &((a, b)) after expansion, which Clippy flags as double_parens. This is a false positive, fixed in Clippy 1.92 (rust-lang/rust-clippy#15939), but the minimum toolchain (1.78) still triggers it.
Add a local #[allow] with a reason attribute on the affected doctest function so it can be removed once the minimum toolchain moves past 1.92.
Changes in v2:
* Drop the v1 approach of splitting format arguments.
* Drop the rustdoc_test_gen.rs blanket suppress (was posted inline during discussion, never sent as a formal patch).
* Instead, add a local #[allow(clippy::double_parens)] with a reason attribute on the specific doctest, per Gary and Miguel's suggestions.
v1 is here:
https://lore.kernel.org/[email protected]
John Hubbard (1):
rust: cpufreq: suppress clippy::double_parens in Policy doctest
rust/kernel/cpufreq.rs | 1 + 1 file changed, 1 insertion(+)
base-commit: 80234b5ab240f52fa45d201e899e207b9265ef91
Signature · 1 line
2.53.0
PATCH v2 1/1 rust: cpufreq: suppress clippy::double_parens in Policy doctest
The kernel fmt! proc macro wraps each format argument as &(arg). Passing a tuple such as (a, b) produces &((a, b)) after expansion. Clippy flags that as double_parens, but it is a false positive fixed in Clippy 1.92 (rust-lang/rust-clippy#15939).
Suppress the warning on the affected doctest function with a reason attribute so it can be removed once the minimum toolchain moves past 1.92.
--- rust/kernel/cpufreq.rs | 1 + 1 file changed, 1 insertion(+)
rust/kernel/cpufreq.rs +1 -0
@@ -401,6 +401,7 @@ pub fn to_table(mut self) -> Result<TableBox> {/// ``` /// use kernel::cpufreq::{DEFAULT_TRANSITION_LATENCY_NS, Policy}; /// +/// #[allow(clippy::double_parens, reason = "false positive before 1.92")] /// fn update_policy(policy: &mut Policy) { /// policy /// .set_dvfs_possible_from_any_cpu(true)
Signature · 1 line
2.53.0
Quoted 10 lines · John Hubbard
The kernel fmt! proc macro wraps each format argument as &(arg). Passing a tuple like (a, b) produces &((a, b)) after expansion, which Clippy flags as
double_parens. This is a false positive, fixed in Clippy 1.92 (rust-lang/rust-clippy#15939), but the minimum toolchain (1.78) still triggers it.Add a local #[allow] with a reason attribute on the affected doctest function so it can be removed once the minimum toolchain moves past 1.92.
Cc'ing Rafael and Viresh -- do you want me to take this via rust-fixes to clean the build log? I am planning to send a PR to Linus for this -rc.
Thanks!
Cheers,
Miguel
Quoted 8 lines · Miguel Ojeda
Quoted 7 lines · John Hubbard
The kernel fmt! proc macro wraps each format argument as &(arg). Passing a tuple like (a, b) produces &((a, b)) after expansion, which Clippy flags as
double_parens. This is a false positive, fixed in Clippy 1.92 (rust-lang/rust-clippy#15939), but the minimum toolchain (1.78) still triggers it.
Quoted 6 lines
Quoted 3 lines
Add a local #[allow] with a reason attribute on the affected doctest function so it can be removed once the minimum toolchain moves past 1.92.
Cc'ing Rafael and Viresh -- do you want me to take this via rust-fixes to clean the build log? I am planning to send a PR to Linus for this
Thanks for cc'ing us. Yeah, please take it.
Signature · 1 line
viresh
Quoted 4 lines · Viresh Kumar
Thanks for cc'ing us. Yeah, please take it.
Acked-by Viresh Kumar <[email protected]>
Thanks for the very quick reply! Will do.
Cheers,
Miguel
Miguel Ojeda
AppliedQuoted 10 lines · John Hubbard
The kernel fmt! proc macro wraps each format argument as &(arg). Passing a tuple like (a, b) produces &((a, b)) after expansion, which Clippy flags as
double_parens. This is a false positive, fixed in Clippy 1.92 (rust-lang/rust-clippy#15939), but the minimum toolchain (1.78) still triggers it.Add a local #[allow] with a reason attribute on the affected doctest function so it can be removed once the minimum toolchain moves past 1.92.
Applied to rust-fixes -- thanks everyone!
[ We may end up deciding to support per-version Clippy lints, in which
case we will need [3].
In the future, if [4] gets fixed, we may be able to use Delimiter::None as Gary suggested in [5].
Link: https://github.com/rust-lang/rust/issues/67062 [4] Link: https://lore.kernel.org/rust-for-linux/[email protected]/
[5]
- Miguel ]
[ Reworded to replace GitHub-like short link with full URLs in Link tags.
Reworded reason string to match the style of a couple others we have elsewhere. - Miguel ]
The lint doesn't trigger in stable from what I can see -- it seems to appear with the merge of our tag that contained the syn rewrite merged in 7.0, so I didn't add:
but we could if needed (e.g. if we happen to backport the syn rewrite).
Cheers,
Miguel