Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'rust-fixes-6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux

Pull rust fixes from Miguel Ojeda:

- Make CFI_AUTO_DEFAULT depend on !RUST or Rust >= 1.88.0

- Clean Rust (and Clippy) lints for the upcoming Rust 1.87.0 and 1.88.0
releases

- Clean objtool warning for the upcoming Rust 1.87.0 release by adding
one more noreturn function

* tag 'rust-fixes-6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux:
x86/Kconfig: make CFI_AUTO_DEFAULT depend on !RUST or Rust >= 1.88
rust: clean Rust 1.88.0's `clippy::uninlined_format_args` lint
rust: clean Rust 1.88.0's warning about `clippy::disallowed_macros` configuration
rust: clean Rust 1.88.0's `unnecessary_transmutes` lint
rust: allow Rust 1.87.0's `clippy::ptr_eq` lint
objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0

+49 -51
+1 -1
.clippy.toml
··· 7 7 disallowed-macros = [ 8 8 # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate 9 9 # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303. 10 - { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" }, 10 + { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool", allow-invalid = true }, 11 11 ]
+1
arch/x86/Kconfig
··· 2368 2368 config CFI_AUTO_DEFAULT 2369 2369 bool "Attempt to use FineIBT by default at boot time" 2370 2370 depends on FINEIBT 2371 + depends on !RUST || RUSTC_VERSION >= 108800 2371 2372 default y 2372 2373 help 2373 2374 Attempt to use FineIBT by default at boot time. If enabled,
+1 -1
drivers/gpu/nova-core/gpu.rs
··· 93 93 // For now, redirect to fmt::Debug for convenience. 94 94 impl fmt::Display for Chipset { 95 95 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 96 - write!(f, "{:?}", self) 96 + write!(f, "{self:?}") 97 97 } 98 98 } 99 99
+3
init/Kconfig
··· 140 140 config RUSTC_HAS_COERCE_POINTEE 141 141 def_bool RUSTC_VERSION >= 108400 142 142 143 + config RUSTC_HAS_UNNECESSARY_TRANSMUTES 144 + def_bool RUSTC_VERSION >= 108800 145 + 143 146 config PAHOLE_VERSION 144 147 int 145 148 default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
+1
rust/bindings/lib.rs
··· 26 26 27 27 #[allow(dead_code)] 28 28 #[allow(clippy::undocumented_unsafe_blocks)] 29 + #[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))] 29 30 mod bindings_raw { 30 31 // Manual definition for blocklisted types. 31 32 type __kernel_size_t = usize;
+3
rust/kernel/alloc/kvec.rs
··· 2 2 3 3 //! Implementation of [`Vec`]. 4 4 5 + // May not be needed in Rust 1.87.0 (pending beta backport). 6 + #![allow(clippy::ptr_eq)] 7 + 5 8 use super::{ 6 9 allocator::{KVmalloc, Kmalloc, Vmalloc}, 7 10 layout::ArrayLayout,
+3
rust/kernel/list.rs
··· 4 4 5 5 //! A linked list implementation. 6 6 7 + // May not be needed in Rust 1.87.0 (pending beta backport). 8 + #![allow(clippy::ptr_eq)] 9 + 7 10 use crate::sync::ArcBorrow; 8 11 use crate::types::Opaque; 9 12 use core::iter::{DoubleEndedIterator, FusedIterator};
+23 -23
rust/kernel/str.rs
··· 73 73 b'\r' => f.write_str("\\r")?, 74 74 // Printable characters. 75 75 0x20..=0x7e => f.write_char(b as char)?, 76 - _ => write!(f, "\\x{:02x}", b)?, 76 + _ => write!(f, "\\x{b:02x}")?, 77 77 } 78 78 } 79 79 Ok(()) ··· 109 109 b'\\' => f.write_str("\\\\")?, 110 110 // Printable characters. 111 111 0x20..=0x7e => f.write_char(b as char)?, 112 - _ => write!(f, "\\x{:02x}", b)?, 112 + _ => write!(f, "\\x{b:02x}")?, 113 113 } 114 114 } 115 115 f.write_char('"') ··· 447 447 // Printable character. 448 448 f.write_char(c as char)?; 449 449 } else { 450 - write!(f, "\\x{:02x}", c)?; 450 + write!(f, "\\x{c:02x}")?; 451 451 } 452 452 } 453 453 Ok(()) ··· 479 479 // Printable characters. 480 480 b'\"' => f.write_str("\\\"")?, 481 481 0x20..=0x7e => f.write_char(c as char)?, 482 - _ => write!(f, "\\x{:02x}", c)?, 482 + _ => write!(f, "\\x{c:02x}")?, 483 483 } 484 484 } 485 485 f.write_str("\"") ··· 641 641 #[test] 642 642 fn test_cstr_display() { 643 643 let hello_world = CStr::from_bytes_with_nul(b"hello, world!\0").unwrap(); 644 - assert_eq!(format!("{}", hello_world), "hello, world!"); 644 + assert_eq!(format!("{hello_world}"), "hello, world!"); 645 645 let non_printables = CStr::from_bytes_with_nul(b"\x01\x09\x0a\0").unwrap(); 646 - assert_eq!(format!("{}", non_printables), "\\x01\\x09\\x0a"); 646 + assert_eq!(format!("{non_printables}"), "\\x01\\x09\\x0a"); 647 647 let non_ascii = CStr::from_bytes_with_nul(b"d\xe9j\xe0 vu\0").unwrap(); 648 - assert_eq!(format!("{}", non_ascii), "d\\xe9j\\xe0 vu"); 648 + assert_eq!(format!("{non_ascii}"), "d\\xe9j\\xe0 vu"); 649 649 let good_bytes = CStr::from_bytes_with_nul(b"\xf0\x9f\xa6\x80\0").unwrap(); 650 - assert_eq!(format!("{}", good_bytes), "\\xf0\\x9f\\xa6\\x80"); 650 + assert_eq!(format!("{good_bytes}"), "\\xf0\\x9f\\xa6\\x80"); 651 651 } 652 652 653 653 #[test] ··· 658 658 bytes[i as usize] = i.wrapping_add(1); 659 659 } 660 660 let cstr = CStr::from_bytes_with_nul(&bytes).unwrap(); 661 - assert_eq!(format!("{}", cstr), ALL_ASCII_CHARS); 661 + assert_eq!(format!("{cstr}"), ALL_ASCII_CHARS); 662 662 } 663 663 664 664 #[test] 665 665 fn test_cstr_debug() { 666 666 let hello_world = CStr::from_bytes_with_nul(b"hello, world!\0").unwrap(); 667 - assert_eq!(format!("{:?}", hello_world), "\"hello, world!\""); 667 + assert_eq!(format!("{hello_world:?}"), "\"hello, world!\""); 668 668 let non_printables = CStr::from_bytes_with_nul(b"\x01\x09\x0a\0").unwrap(); 669 - assert_eq!(format!("{:?}", non_printables), "\"\\x01\\x09\\x0a\""); 669 + assert_eq!(format!("{non_printables:?}"), "\"\\x01\\x09\\x0a\""); 670 670 let non_ascii = CStr::from_bytes_with_nul(b"d\xe9j\xe0 vu\0").unwrap(); 671 - assert_eq!(format!("{:?}", non_ascii), "\"d\\xe9j\\xe0 vu\""); 671 + assert_eq!(format!("{non_ascii:?}"), "\"d\\xe9j\\xe0 vu\""); 672 672 let good_bytes = CStr::from_bytes_with_nul(b"\xf0\x9f\xa6\x80\0").unwrap(); 673 - assert_eq!(format!("{:?}", good_bytes), "\"\\xf0\\x9f\\xa6\\x80\""); 673 + assert_eq!(format!("{good_bytes:?}"), "\"\\xf0\\x9f\\xa6\\x80\""); 674 674 } 675 675 676 676 #[test] 677 677 fn test_bstr_display() { 678 678 let hello_world = BStr::from_bytes(b"hello, world!"); 679 - assert_eq!(format!("{}", hello_world), "hello, world!"); 679 + assert_eq!(format!("{hello_world}"), "hello, world!"); 680 680 let escapes = BStr::from_bytes(b"_\t_\n_\r_\\_\'_\"_"); 681 - assert_eq!(format!("{}", escapes), "_\\t_\\n_\\r_\\_'_\"_"); 681 + assert_eq!(format!("{escapes}"), "_\\t_\\n_\\r_\\_'_\"_"); 682 682 let others = BStr::from_bytes(b"\x01"); 683 - assert_eq!(format!("{}", others), "\\x01"); 683 + assert_eq!(format!("{others}"), "\\x01"); 684 684 let non_ascii = BStr::from_bytes(b"d\xe9j\xe0 vu"); 685 - assert_eq!(format!("{}", non_ascii), "d\\xe9j\\xe0 vu"); 685 + assert_eq!(format!("{non_ascii}"), "d\\xe9j\\xe0 vu"); 686 686 let good_bytes = BStr::from_bytes(b"\xf0\x9f\xa6\x80"); 687 - assert_eq!(format!("{}", good_bytes), "\\xf0\\x9f\\xa6\\x80"); 687 + assert_eq!(format!("{good_bytes}"), "\\xf0\\x9f\\xa6\\x80"); 688 688 } 689 689 690 690 #[test] 691 691 fn test_bstr_debug() { 692 692 let hello_world = BStr::from_bytes(b"hello, world!"); 693 - assert_eq!(format!("{:?}", hello_world), "\"hello, world!\""); 693 + assert_eq!(format!("{hello_world:?}"), "\"hello, world!\""); 694 694 let escapes = BStr::from_bytes(b"_\t_\n_\r_\\_\'_\"_"); 695 - assert_eq!(format!("{:?}", escapes), "\"_\\t_\\n_\\r_\\\\_'_\\\"_\""); 695 + assert_eq!(format!("{escapes:?}"), "\"_\\t_\\n_\\r_\\\\_'_\\\"_\""); 696 696 let others = BStr::from_bytes(b"\x01"); 697 - assert_eq!(format!("{:?}", others), "\"\\x01\""); 697 + assert_eq!(format!("{others:?}"), "\"\\x01\""); 698 698 let non_ascii = BStr::from_bytes(b"d\xe9j\xe0 vu"); 699 - assert_eq!(format!("{:?}", non_ascii), "\"d\\xe9j\\xe0 vu\""); 699 + assert_eq!(format!("{non_ascii:?}"), "\"d\\xe9j\\xe0 vu\""); 700 700 let good_bytes = BStr::from_bytes(b"\xf0\x9f\xa6\x80"); 701 - assert_eq!(format!("{:?}", good_bytes), "\"\\xf0\\x9f\\xa6\\x80\""); 701 + assert_eq!(format!("{good_bytes:?}"), "\"\\xf0\\x9f\\xa6\\x80\""); 702 702 } 703 703 } 704 704
+4 -9
rust/macros/kunit.rs
··· 15 15 } 16 16 17 17 if attr.len() > 255 { 18 - panic!( 19 - "The test suite name `{}` exceeds the maximum length of 255 bytes", 20 - attr 21 - ) 18 + panic!("The test suite name `{attr}` exceeds the maximum length of 255 bytes") 22 19 } 23 20 24 21 let mut tokens: Vec<_> = ts.into_iter().collect(); ··· 99 102 let mut kunit_macros = "".to_owned(); 100 103 let mut test_cases = "".to_owned(); 101 104 for test in &tests { 102 - let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{}", test); 105 + let kunit_wrapper_fn_name = format!("kunit_rust_wrapper_{test}"); 103 106 let kunit_wrapper = format!( 104 - "unsafe extern \"C\" fn {}(_test: *mut kernel::bindings::kunit) {{ {}(); }}", 105 - kunit_wrapper_fn_name, test 107 + "unsafe extern \"C\" fn {kunit_wrapper_fn_name}(_test: *mut kernel::bindings::kunit) {{ {test}(); }}" 106 108 ); 107 109 writeln!(kunit_macros, "{kunit_wrapper}").unwrap(); 108 110 writeln!( 109 111 test_cases, 110 - " kernel::kunit::kunit_case(kernel::c_str!(\"{}\"), {}),", 111 - test, kunit_wrapper_fn_name 112 + " kernel::kunit::kunit_case(kernel::c_str!(\"{test}\"), {kunit_wrapper_fn_name})," 112 113 ) 113 114 .unwrap(); 114 115 }
+5 -14
rust/macros/module.rs
··· 48 48 ) 49 49 } else { 50 50 // Loadable modules' modinfo strings go as-is. 51 - format!("{field}={content}\0", field = field, content = content) 51 + format!("{field}={content}\0") 52 52 }; 53 53 54 54 write!( ··· 126 126 }; 127 127 128 128 if seen_keys.contains(&key) { 129 - panic!( 130 - "Duplicated key \"{}\". Keys can only be specified once.", 131 - key 132 - ); 129 + panic!("Duplicated key \"{key}\". Keys can only be specified once."); 133 130 } 134 131 135 132 assert_eq!(expect_punct(it), ':'); ··· 140 143 "license" => info.license = expect_string_ascii(it), 141 144 "alias" => info.alias = Some(expect_string_array(it)), 142 145 "firmware" => info.firmware = Some(expect_string_array(it)), 143 - _ => panic!( 144 - "Unknown key \"{}\". Valid keys are: {:?}.", 145 - key, EXPECTED_KEYS 146 - ), 146 + _ => panic!("Unknown key \"{key}\". Valid keys are: {EXPECTED_KEYS:?}."), 147 147 } 148 148 149 149 assert_eq!(expect_punct(it), ','); ··· 152 158 153 159 for key in REQUIRED_KEYS { 154 160 if !seen_keys.iter().any(|e| e == key) { 155 - panic!("Missing required key \"{}\".", key); 161 + panic!("Missing required key \"{key}\"."); 156 162 } 157 163 } 158 164 ··· 164 170 } 165 171 166 172 if seen_keys != ordered_keys { 167 - panic!( 168 - "Keys are not ordered as expected. Order them like: {:?}.", 169 - ordered_keys 170 - ); 173 + panic!("Keys are not ordered as expected. Order them like: {ordered_keys:?}."); 171 174 } 172 175 173 176 info
+1 -1
rust/macros/paste.rs
··· 50 50 let tokens = group.stream().into_iter().collect::<Vec<TokenTree>>(); 51 51 segments.append(&mut concat_helper(tokens.as_slice())); 52 52 } 53 - token => panic!("unexpected token in paste segments: {:?}", token), 53 + token => panic!("unexpected token in paste segments: {token:?}"), 54 54 }; 55 55 } 56 56
+1 -2
rust/pin-init/internal/src/pinned_drop.rs
··· 28 28 // Found the end of the generics, this should be `PinnedDrop`. 29 29 assert!( 30 30 matches!(tt, TokenTree::Ident(i) if i.to_string() == "PinnedDrop"), 31 - "expected 'PinnedDrop', found: '{:?}'", 32 - tt 31 + "expected 'PinnedDrop', found: '{tt:?}'" 33 32 ); 34 33 pinned_drop_idx = Some(i); 35 34 break;
+1
rust/uapi/lib.rs
··· 24 24 unreachable_pub, 25 25 unsafe_op_in_unsafe_fn 26 26 )] 27 + #![cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))] 27 28 28 29 // Manual definition of blocklisted types. 29 30 type __kernel_size_t = usize;
+1
tools/objtool/check.c
··· 227 227 str_ends_with(func->name, "_4core9panicking19assert_failed_inner") || 228 228 str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference") || 229 229 str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") || 230 + str_ends_with(func->name, "_7___rustc17rust_begin_unwind") || 230 231 strstr(func->name, "_4core9panicking13assert_failed") || 231 232 strstr(func->name, "_4core9panicking11panic_const24panic_const_") || 232 233 (strstr(func->name, "_4core5slice5index24slice_") &&