public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kbuild: rust: allow `clippy::uninlined_format_args`
@ 2026-03-31 20:58 Miguel Ojeda
  2026-03-31 20:58 ` [PATCH 2/2] rust: macros: simplify `format!` arguments Miguel Ojeda
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Miguel Ojeda @ 2026-03-31 20:58 UTC (permalink / raw)
  To: Miguel Ojeda, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
	Sami Tolvanen, Nathan Chancellor, Nicolas Schier
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	rust-for-linux, Aaron Tomlin, linux-modules, linux-kernel,
	linux-kbuild, stable

Clippy in Rust 1.88.0 (only) reports [1]:

    warning: variables can be used directly in the `format!` string
       --> rust/macros/module.rs:112:23
        |
    112 |         let content = format!("{param}:{content}", param = param, content = content);
        |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        = note: `-W clippy::uninlined-format-args` implied by `-W clippy::all`
        = help: to override `-W clippy::all` add `#[allow(clippy::uninlined_format_args)]`
    help: change this to
        |
    112 -         let content = format!("{param}:{content}", param = param, content = content);
    112 +         let content = format!("{param}:{content}");

    warning: variables can be used directly in the `format!` string
       --> rust/macros/module.rs:198:14
        |
    198 |         t => panic!("Unsupported parameter type {}", t),
        |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
        = note: `-W clippy::uninlined-format-args` implied by `-W clippy::all`
        = help: to override `-W clippy::all` add `#[allow(clippy::uninlined_format_args)]`
    help: change this to
        |
    198 -         t => panic!("Unsupported parameter type {}", t),
    198 +         t => panic!("Unsupported parameter type {t}"),
        |

The reason it only triggers in that version is that the lint was moved
from `pedantic` to `style` in Rust 1.88.0 and then back to `pedantic`
in Rust 1.89.0 [2][3].

In the first case, the suggestion is fair and a pure simplification, thus
we will clean it up separately.

To keep the behavior the same across all versions, and since the lint
does not work for all macros (e.g. custom ones like `pr_info!`), disable
it globally.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: https://lore.kernel.org/rust-for-linux/CANiq72=drAtf3y_DZ-2o4jb6Az9J3Yj4QYwWnbRui4sm4AJD3Q@mail.gmail.com/ [1]
Link: https://github.com/rust-lang/rust-clippy/pull/15287 [2]
Link: https://github.com/rust-lang/rust-clippy/issues/15151 [3]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 1a219bf1c771..a63684c36d60 100644
--- a/Makefile
+++ b/Makefile
@@ -494,6 +494,7 @@ export rust_common_flags := --edition=2021 \
 			    -Wclippy::ptr_cast_constness \
 			    -Wclippy::ref_as_ptr \
 			    -Wclippy::undocumented_unsafe_blocks \
+			    -Aclippy::uninlined_format_args \
 			    -Wclippy::unnecessary_safety_comment \
 			    -Wclippy::unnecessary_safety_doc \
 			    -Wrustdoc::missing_crate_level_docs \
-- 
2.53.0


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

end of thread, other threads:[~2026-04-03 21:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 20:58 [PATCH 1/2] kbuild: rust: allow `clippy::uninlined_format_args` Miguel Ojeda
2026-03-31 20:58 ` [PATCH 2/2] rust: macros: simplify `format!` arguments Miguel Ojeda
2026-03-31 21:07   ` Gary Guo
2026-04-03  4:53   ` Miguel Ojeda
2026-04-03 15:52     ` Sami Tolvanen
2026-04-03 21:23       ` Miguel Ojeda
2026-03-31 21:07 ` [PATCH 1/2] kbuild: rust: allow `clippy::uninlined_format_args` Gary Guo
2026-03-31 21:14   ` Miguel Ojeda
2026-03-31 21:43     ` Gary Guo
2026-03-31 21:53       ` Miguel Ojeda
2026-04-01 15:36         ` Gary Guo
2026-04-03 10:06 ` Miguel Ojeda
2026-04-03 10:24 ` Tamir Duberstein
2026-04-03 13:07   ` Miguel Ojeda

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