FAILED: patch "[PATCH] rust: clean Rust 1.88.0's `clippy::uninlined_format_args`" failed to apply to 6.14-stable tree
Subsystems (8)
[email protected]
maintainerThe patch below does not apply to the 6.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.14.y
git checkout FETCH_HEAD
git cherry-pick -x 211dcf77856db64c73e0c3b9ce0c624ec855daca
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025051217-trifle-batboy-aab3@gregkh' --subject-prefix 'PATCH 6.14.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 211dcf77856db64c73e0c3b9ce0c624ec855daca Mon Sep 17 00:00:00 2001
From: Miguel Ojeda <[email protected]>
Date: Fri, 2 May 2025 16:02:37 +0200
Subject: [PATCH] rust: clean Rust 1.88.0's clippy::uninlined_format_args
lint
Starting with Rust 1.88.0 (expected 2025-06-26) [1], rustc may move back the uninlined_format_args to style from pedantic (it was there waiting for rust-analyzer suppotr), and thus we will start to see lints like:
warning: variables can be used directly in the `format!` string
--> rust/macros/kunit.rs:105:37
|
105 | let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{}", test);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
help: change this to
|
105 - let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{}", test);
105 + let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{test}");There is even a case that is a pure removal:
warning: variables can be used directly in the `format!` string
--> rust/macros/module.rs:51:13
|
51 | format!("{field}={content}\0", field = field, content = content)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
help: change this to
|
51 - format!("{field}={content}\0", field = field, content = content)
51 + format!("{field}={content}\0")The lints all seem like nice cleanups, thus just apply them.
We may want to disable allow-mixed-uninlined-format-args in the future.
drivers/gpu/nova-core/gpu.rs +1 -1
@@ -93,7 +93,7 @@ pub(crate) fn arch(&self) -> Architecture {// For now, redirect to fmt::Debug for convenience. impl fmt::Display for Chipset {fn fmt (&self, f: &mut fmt::Formatter <'_>) -> fmt::Result { -write! (f,"{:?}" , self) +write! (f,"{self:?}" ) } }
rust/kernel/str.rs +23 -23
111 lines not on this page · raw message
rust/macros/kunit.rs +4 -9
@@ -15,10 +15,7 @@ pub(crate) fn kunit_tests(attr: TokenStream, ts: TokenStream) -> TokenStream { }if attr.len () >255 { -panic! ( -"The test suite name `{}` exceeds the maximum length of 255 bytes" , - attr - ) +panic! ("The test suite name `{attr}` exceeds the maximum length of 255 bytes" ) }let mut tokens:Vec <_ > = ts.into_iter ().collect ();
@@ -102,16 +99,14 @@ pub(crate) fn kunit_tests(attr: TokenStream, ts: TokenStream) -> TokenStream {let mut kunit_macros ="" .to_owned ();let mut test_cases ="" .to_owned ();for testin &tests { -let kunit_wrapper_fn_name =format! ("kunit_rust_wrapper_{}" , test); +let kunit_wrapper_fn_name =format! ("kunit_rust_wrapper_{test}" );let kunit_wrapper =format! ( -"unsafe extern \"C\" fn {}(_test: *mut kernel::bindings::kunit) {{ {}(); }}" , - kunit_wrapper_fn_name, test +"unsafe extern \"C\" fn {kunit_wrapper_fn_name}(_test: *mut kernel::bindings::kunit) {{ {test}(); }}" );writeln! (kunit_macros,"{kunit_wrapper}" ).unwrap ();writeln! ( test_cases, -" kernel::kunit::kunit_case(kernel::c_str!(\"{}\"), {})," , - test, kunit_wrapper_fn_name +" kernel::kunit::kunit_case(kernel::c_str!(\"{test}\"), {kunit_wrapper_fn_name})," ) .unwrap (); }
rust/macros/module.rs +5 -14
@@ -48,7 +48,7 @@ fn emit_base(&mut self, field: &str, content: &str, builtin: bool) { ) }else {// Loadable modules' modinfo strings go as-is. -format! ("{field}={content}\0" , field = field, content = content) +format! ("{field}={content}\0" ) };write! (
@@ -126,10 +126,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { };if seen_keys.contains (&key) { -panic! ( -"Duplicated key \"{}\". Keys can only be specified once." , - key - ); +panic! ("Duplicated key \"{key}\". Keys can only be specified once." ); }assert_eq! (expect_punct (it),':' );
@@ -143,10 +140,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { "license" => info.license = expect_string_ascii(it), "alias" => info.alias = Some(expect_string_array(it)), "firmware" => info.firmware = Some(expect_string_array(it)), - _ => panic!( -"Unknown key \"{}\". Valid keys are: {:?}." , - key,EXPECTED_KEYS - ), + _ => panic!("Unknown key \"{key}\". Valid keys are: {EXPECTED_KEYS:?}."), }assert_eq! (expect_punct (it),',' );
@@ -158,7 +152,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {for keyin REQUIRED_KEYS {if !seen_keys.iter ().any (|e| e == key) { -panic! ("Missing required key \"{}\"." , key); +panic! ("Missing required key \"{key}\"." ); } }
@@ -170,10 +164,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { }if seen_keys != ordered_keys { -panic! ( -"Keys are not ordered as expected. Order them like: {:?}." , - ordered_keys - ); +panic! ("Keys are not ordered as expected. Order them like: {ordered_keys:?}." ); } info
rust/macros/paste.rs +1 -1
@@ -50,7 +50,7 @@ fn concat_helper(tokens: &[TokenTree]) -> Vec<(String, Span)> {let tokens = group.stream ().into_iter ().collect ::<Vec <TokenTree >>(); segments.append (&mut concat_helper (tokens.as_slice ())); } - token => panic!("unexpected token in paste segments: {:?}", token), + token => panic!("unexpected token in paste segments: {token:?}"), }; }
rust/pin-init/internal/src/pinned_drop.rs +1 -2
@@ -28,8 +28,7 @@ pub(crate) fn pinned_drop(_args: TokenStream, input: TokenStream) -> TokenStream// Found the end of the generics, this should be `PinnedDrop`. assert! (matches! (tt,TokenTree ::Ident (i)if i.to_string () =="PinnedDrop" ), -"expected 'PinnedDrop', found: '{:?}'" , - tt +"expected 'PinnedDrop', found: '{tt:?}'" ); pinned_drop_idx =Some (i);break ;
Miguel Ojeda
maintainerPATCH 1/1 rust: clean Rust 1.88.0's `clippy::uninlined_format_args` lint
Starting with Rust 1.88.0 (expected 2025-06-26) [1], rustc may move back the uninlined_format_args to style from pedantic (it was there waiting for rust-analyzer suppotr), and thus we will start to see lints like:
warning: variables can be used directly in the `format!` string
--> rust/macros/kunit.rs:105:37
|
105 | let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{}", test);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
help: change this to
|
105 - let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{}", test);
105 + let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{test}");There is even a case that is a pure removal:
warning: variables can be used directly in the `format!` string
--> rust/macros/module.rs:51:13
|
51 | format!("{field}={content}\0", field = field, content = content)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
help: change this to
|
51 - format!("{field}={content}\0", field = field, content = content)
51 + format!("{field}={content}\0")The lints all seem like nice cleanups, thus just apply them.
We may want to disable allow-mixed-uninlined-format-args in the future.
--- rust/kernel/str.rs | 46 +++++++++++++++++++------------------- rust/macros/module.rs | 19 +++++----------- rust/macros/paste.rs | 2 +- rust/macros/pinned_drop.rs | 3 +-- 4 files changed, 30 insertions(+), 40 deletions(-)
rust/kernel/str.rs +23 -23
@@ -56,7 +56,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { b'\r' => f.write_str("\\r")?,// Printable characters. 0x20..=0x7e => f.write_char(b as char)?, - _ => write!(f, "\\x{:02x}", b)?, + _ => write!(f, "\\x{b:02x}")?, } }Ok (())
@@ -92,7 +92,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { b'\\' => f.write_str("\\\\")?,// Printable characters. 0x20..=0x7e => f.write_char(b as char)?, - _ => write!(f, "\\x{:02x}", b)?, + _ => write!(f, "\\x{b:02x}")?, } } f.write_char ('"' )
@@ -401,7 +401,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {// Printable character. f.write_char (cas char )?; }else { -write! (f,"\\x{:02x}" , c)?; +write! (f,"\\x{c:02x}" )?; } }Ok (())
@@ -433,7 +433,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {// Printable characters. b'\"' => f.write_str("\\\"")?, 0x20..=0x7e => f.write_char(c as char)?, - _ => write!(f, "\\x{:02x}", c)?, + _ => write!(f, "\\x{c:02x}")?, } } f.write_str ("\"" )
@@ -595,13 +595,13 @@ fn test_cstr_as_str_unchecked() {#[test] fn test_cstr_display () {let hello_world =CStr ::from_bytes_with_nul (b"hello, world!\0" ).unwrap (); -assert_eq! (format! ("{}" , hello_world),"hello, world!" ); +assert_eq! (format! ("{hello_world}" ),"hello, world!" );let non_printables =CStr ::from_bytes_with_nul (b"\x01\x09\x0a\0" ).unwrap (); -assert_eq! (format! ("{}" , non_printables),"\\x01\\x09\\x0a" ); +assert_eq! (format! ("{non_printables}" ),"\\x01\\x09\\x0a" );let non_ascii =CStr ::from_bytes_with_nul (b"d\xe9j\xe0 vu\0" ).unwrap (); -assert_eq! (format! ("{}" , non_ascii),"d\\xe9j\\xe0 vu" ); +assert_eq! (format! ("{non_ascii}" ),"d\\xe9j\\xe0 vu" );let good_bytes =CStr ::from_bytes_with_nul (b"\xf0\x9f\xa6\x80\0" ).unwrap (); -assert_eq! (format! ("{}" , good_bytes),"\\xf0\\x9f\\xa6\\x80" ); +assert_eq! (format! ("{good_bytes}" ),"\\xf0\\x9f\\xa6\\x80" ); }#[test]
@@ -612,47 +612,47 @@ fn test_cstr_display_all_bytes() { bytes[ias usize ] = i.wrapping_add (1 ); }let cstr =CStr ::from_bytes_with_nul (&bytes).unwrap (); -assert_eq! (format! ("{}" , cstr),ALL_ASCII_CHARS ); +assert_eq! (format! ("{cstr}" ),ALL_ASCII_CHARS ); }#[test] fn test_cstr_debug () {let hello_world =CStr ::from_bytes_with_nul (b"hello, world!\0" ).unwrap (); -assert_eq! (format! ("{:?}" , hello_world),"\"hello, world!\"" ); +assert_eq! (format! ("{hello_world:?}" ),"\"hello, world!\"" );let non_printables =CStr ::from_bytes_with_nul (b"\x01\x09\x0a\0" ).unwrap (); -assert_eq! (format! ("{:?}" , non_printables),"\"\\x01\\x09\\x0a\"" ); +assert_eq! (format! ("{non_printables:?}" ),"\"\\x01\\x09\\x0a\"" );let non_ascii =CStr ::from_bytes_with_nul (b"d\xe9j\xe0 vu\0" ).unwrap (); -assert_eq! (format! ("{:?}" , non_ascii),"\"d\\xe9j\\xe0 vu\"" ); +assert_eq! (format! ("{non_ascii:?}" ),"\"d\\xe9j\\xe0 vu\"" );let good_bytes =CStr ::from_bytes_with_nul (b"\xf0\x9f\xa6\x80\0" ).unwrap (); -assert_eq! (format! ("{:?}" , good_bytes),"\"\\xf0\\x9f\\xa6\\x80\"" ); +assert_eq! (format! ("{good_bytes:?}" ),"\"\\xf0\\x9f\\xa6\\x80\"" ); }#[test] fn test_bstr_display () {let hello_world =BStr ::from_bytes (b"hello, world!" ); -assert_eq! (format! ("{}" , hello_world),"hello, world!" ); +assert_eq! (format! ("{hello_world}" ),"hello, world!" );let escapes =BStr ::from_bytes (b"_\t_\n_\r_\\_\'_\"_" ); -assert_eq! (format! ("{}" , escapes),"_\\t_\\n_\\r_\\_'_\"_" ); +assert_eq! (format! ("{escapes}" ),"_\\t_\\n_\\r_\\_'_\"_" );let others =BStr ::from_bytes (b"\x01" ); -assert_eq! (format! ("{}" , others),"\\x01" ); +assert_eq! (format! ("{others}" ),"\\x01" );let non_ascii =BStr ::from_bytes (b"d\xe9j\xe0 vu" ); -assert_eq! (format! ("{}" , non_ascii),"d\\xe9j\\xe0 vu" ); +assert_eq! (format! ("{non_ascii}" ),"d\\xe9j\\xe0 vu" );let good_bytes =BStr ::from_bytes (b"\xf0\x9f\xa6\x80" ); -assert_eq! (format! ("{}" , good_bytes),"\\xf0\\x9f\\xa6\\x80" ); +assert_eq! (format! ("{good_bytes}" ),"\\xf0\\x9f\\xa6\\x80" ); }#[test] fn test_bstr_debug () {let hello_world =BStr ::from_bytes (b"hello, world!" ); -assert_eq! (format! ("{:?}" , hello_world),"\"hello, world!\"" ); +assert_eq! (format! ("{hello_world:?}" ),"\"hello, world!\"" );let escapes =BStr ::from_bytes (b"_\t_\n_\r_\\_\'_\"_" ); -assert_eq! (format! ("{:?}" , escapes),"\"_\\t_\\n_\\r_\\\\_'_\\\"_\"" ); +assert_eq! (format! ("{escapes:?}" ),"\"_\\t_\\n_\\r_\\\\_'_\\\"_\"" );let others =BStr ::from_bytes (b"\x01" ); -assert_eq! (format! ("{:?}" , others),"\"\\x01\"" ); +assert_eq! (format! ("{others:?}" ),"\"\\x01\"" );let non_ascii =BStr ::from_bytes (b"d\xe9j\xe0 vu" ); -assert_eq! (format! ("{:?}" , non_ascii),"\"d\\xe9j\\xe0 vu\"" ); +assert_eq! (format! ("{non_ascii:?}" ),"\"d\\xe9j\\xe0 vu\"" );let good_bytes =BStr ::from_bytes (b"\xf0\x9f\xa6\x80" ); -assert_eq! (format! ("{:?}" , good_bytes),"\"\\xf0\\x9f\\xa6\\x80\"" ); +assert_eq! (format! ("{good_bytes:?}" ),"\"\\xf0\\x9f\\xa6\\x80\"" ); } }
rust/macros/module.rs +5 -14
@@ -48,7 +48,7 @@ fn emit_base(&mut self, field: &str, content: &str, builtin: bool) { ) }else {// Loadable modules' modinfo strings go as-is. -format! ("{field}={content}\0" , field = field, content = content) +format! ("{field}={content}\0" ) };write! (
@@ -124,10 +124,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { };if seen_keys.contains (&key) { -panic! ( -"Duplicated key \"{}\". Keys can only be specified once." , - key - ); +panic! ("Duplicated key \"{key}\". Keys can only be specified once." ); }assert_eq! (expect_punct (it),':' );
@@ -140,10 +137,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { "license" => info.license = expect_string_ascii(it), "alias" => info.alias = Some(expect_string_array(it)), "firmware" => info.firmware = Some(expect_string_array(it)), - _ => panic!( -"Unknown key \"{}\". Valid keys are: {:?}." , - key,EXPECTED_KEYS - ), + _ => panic!("Unknown key \"{key}\". Valid keys are: {EXPECTED_KEYS:?}."), }assert_eq! (expect_punct (it),',' );
@@ -155,7 +149,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {for keyin REQUIRED_KEYS {if !seen_keys.iter ().any (|e| e == key) { -panic! ("Missing required key \"{}\"." , key); +panic! ("Missing required key \"{key}\"." ); } }
@@ -167,10 +161,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { }if seen_keys != ordered_keys { -panic! ( -"Keys are not ordered as expected. Order them like: {:?}." , - ordered_keys - ); +panic! ("Keys are not ordered as expected. Order them like: {ordered_keys:?}." ); } info
rust/macros/paste.rs +1 -1
@@ -50,7 +50,7 @@ fn concat_helper(tokens: &[TokenTree]) -> Vec<(String, Span)> {let tokens = group.stream ().into_iter ().collect ::<Vec <TokenTree >>(); segments.append (&mut concat_helper (tokens.as_slice ())); } - token => panic!("unexpected token in paste segments: {:?}", token), + token => panic!("unexpected token in paste segments: {token:?}"), }; }
rust/macros/pinned_drop.rs +1 -2
@@ -25,8 +25,7 @@ pub(crate) fn pinned_drop(_args: TokenStream, input: TokenStream) -> TokenStream// Found the end of the generics, this should be `PinnedDrop`. assert! (matches! (tt,TokenTree ::Ident (i)if i.to_string () =="PinnedDrop" ), -"expected 'PinnedDrop', found: '{:?}'" , - tt +"expected 'PinnedDrop', found: '{tt:?}'" ); pinned_drop_idx =Some (i);break ;
Signature · 1 line
2.49.0
Re: [PATCH 6.14.y] rust: clean Rust 1.88.0's `clippy::uninlined_format_args` lint
[ Sasha's backport helper bot ]
Hi,
Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it
Found matching upstream commit: 211dcf77856db64c73e0c3b9ce0c624ec855daca
Note: The patch differs from the upstream commit:
---
1: 211dcf77856db ! 1: 3d50fea3c59c6 rust: clean Rust 1.88.0's clippy::uninlined_format_args lint
@@ Commit message
-
- ## drivers/gpu/nova-core/gpu.rs ##
-@@ drivers/gpu/nova-core/gpu.rs: pub(crate) fn arch(&self) -> Architecture {
- // For now, redirect to fmt::Debug for convenience.
- impl fmt::Display for Chipset {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-- write!(f, "{:?}", self)
-+ write!(f, "{self:?}")
- }
- }
-
+ (cherry picked from commit 211dcf77856db64c73e0c3b9ce0c624ec855daca)
+ Signed-off-by: Miguel Ojeda <[email protected]>
## rust/kernel/str.rs ##
@@ rust/kernel/str.rs: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ rust/kernel/str.rs: fn test_cstr_display_all_bytes() {
}
- ## rust/macros/kunit.rs ##
-@@ rust/macros/kunit.rs: pub(crate) fn kunit_tests(attr: TokenStream, ts: TokenStream) -> TokenStream {
- }
-
- if attr.len() > 255 {
-- panic!(
-- "The test suite name {} exceeds the maximum length of 255 bytes",
-- attr
-- )
-+ panic!("The test suite name {attr} exceeds the maximum length of 255 bytes")
- }
-
- let mut tokens: Vec<_> = ts.into_iter().collect();
-@@ rust/macros/kunit.rs: pub(crate) fn kunit_tests(attr: TokenStream, ts: TokenStream) -> TokenStream {
- let mut kunit_macros = "".to_owned();
- let mut test_cases = "".to_owned();
- for test in &tests {
-- let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{}", test);
-+ let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{test}");
- let kunit_wrapper = format!(
-- "unsafe extern \"C\" fn {}(_test: *mut kernel::bindings::kunit) {{ {}(); }}",
-- kunit_wrapper_fn_name, test
-+ "unsafe extern \"C\" fn {kunit_wrapper_fn_name}(_test: *mut kernel::bindings::kunit) {{ {test}(); }}"
- );
- writeln!(kunit_macros, "{kunit_wrapper}").unwrap();
- writeln!(
- test_cases,
-- " kernel::kunit::kunit_case(kernel::c_str!(\"{}\"), {}),",
-- test, kunit_wrapper_fn_name
-+ " kernel::kunit::kunit_case(kernel::c_str!(\"{test}\"), {kunit_wrapper_fn_name}),"
- )
- .unwrap();
- }
-
## rust/macros/module.rs ##
@@ rust/macros/module.rs: fn emit_base(&mut self, field: &str, content: &str, builtin: bool) {
)
@@ rust/macros/paste.rs: fn concat_helper(tokens: &[TokenTree]) -> Vec<(String, Spa
}
- ## rust/pin-init/internal/src/pinned_drop.rs ##
-@@ rust/pin-init/internal/src/pinned_drop.rs: pub(crate) fn pinned_drop(_args: TokenStream, input: TokenStream) -> TokenStream
+ ## rust/macros/pinned_drop.rs ##
+@@ rust/macros/pinned_drop.rs: pub(crate) fn pinned_drop(_args: TokenStream, input: TokenStream) -> TokenStream
// Found the end of the generics, this should be PinnedDrop.
assert!(
matches!(tt, TokenTree::Ident(i) if i.to_string() == "PinnedDrop"),
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.14.y | Success | Success |