Skip to content

Commit 438700e

Browse files
committed
rust: macros: simplify format! arguments
Clippy in Rust 1.88.0 (only) reported [1] up to the previous commit: 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}"); 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 this case, the suggestion is fair and a pure simplification, thus just apply it. In addition, do the same for another place in the file that Clippy does not report because it is multi-line. Link: https://lore.kernel.org/rust-for-linux/CANiq72=drAtf3y_DZ-2o4jb6Az9J3Yj4QYwWnbRui4sm4AJD3Q@mail.gmail.com/ [1] Link: rust-lang/rust-clippy#15287 [2] Link: rust-lang/rust-clippy#15151 [3] Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Sami Tolvanen <samitolvanen@google.com> Link: https://patch.msgid.link/20260331205849.498295-2-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 10eea3c commit 438700e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

rust/macros/module.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ impl<'a> ModInfoBuilder<'a> {
5252
fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
5353
let string = if builtin {
5454
// Built-in modules prefix their modinfo strings by `module.`.
55-
format!(
56-
"{module}.{field}={content}\0",
57-
module = self.module,
58-
field = field,
59-
content = content
60-
)
55+
format!("{module}.{field}={content}\0", module = self.module)
6156
} else {
6257
// Loadable modules' modinfo strings go as-is.
6358
format!("{field}={content}\0")
@@ -109,7 +104,7 @@ impl<'a> ModInfoBuilder<'a> {
109104
}
110105

111106
fn emit_param(&mut self, field: &str, param: &str, content: &str) {
112-
let content = format!("{param}:{content}", param = param, content = content);
107+
let content = format!("{param}:{content}");
113108
self.emit_internal(field, &content, true);
114109
}
115110

0 commit comments

Comments
 (0)