Thread (19 messages) 19 messages, 6 authors, 2026-03-16

Re: [PATCH] rust: cpufreq: fix clippy::double_parens warning in Policy doctest

From: John Hubbard <jhubbard@nvidia.com>
Date: 2026-03-04 21:13:50
Also in: linux-pm, lkml
Subsystem: kernel unit testing framework (kunit), rust, the rest · Maintainers: Brendan Higgins, David Gow, Miguel Ojeda, Linus Torvalds

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 [off-list ref]
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 [off-list ref]
    Signed-off-by: John Hubbard [off-list ref]
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help