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-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux

Pull rust fixes from Miguel Ojeda:
"Toolchain and infrastructure:

- Pass '-Zunstable-options' flag required by the future Rust 1.95.0

- Fix 'objtool' warning for Rust 1.84.0

'kernel' crate:

- 'irq' module: add missing bound detected by the future Rust 1.95.0

- 'list' module: add missing 'unsafe' blocks and placeholder safety
comments to macros (an issue for future callers within the crate)

'pin-init' crate:

- Clean Clippy warning that changed behavior in the future Rust
1.95.0"

* tag 'rust-fixes-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux:
rust: list: Add unsafe blocks for container_of and safety comments
rust: pin-init: replace clippy `expect` with `allow`
rust: irq: add `'static` bounds to irq callbacks
objtool/rust: add one more `noreturn` Rust function
rust: kbuild: pass `-Zunstable-options` for Rust 1.95.0

+32 -15
+3
rust/Makefile
··· 570 570 $(obj)/libproc_macro2.rlib $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE 571 571 +$(call if_changed_dep,rustc_procmacro) 572 572 573 + # `rustc` requires `-Zunstable-options` to use custom target specifications 574 + # since Rust 1.95.0 (https://github.com/rust-lang/rust/pull/151534). 573 575 quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@ 574 576 cmd_rustc_library = \ 575 577 OBJTREE=$(abspath $(objtree)) \ ··· 582 580 --crate-type rlib -L$(objtree)/$(obj) \ 583 581 --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ 584 582 --sysroot=/dev/null \ 583 + -Zunstable-options \ 585 584 $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \ 586 585 $(cmd_objtool) 587 586
+9 -3
rust/kernel/irq/request.rs
··· 260 260 /// # Safety 261 261 /// 262 262 /// This function should be only used as the callback in `request_irq`. 263 - unsafe extern "C" fn handle_irq_callback<T: Handler>(_irq: i32, ptr: *mut c_void) -> c_uint { 263 + unsafe extern "C" fn handle_irq_callback<T: Handler + 'static>( 264 + _irq: i32, 265 + ptr: *mut c_void, 266 + ) -> c_uint { 264 267 // SAFETY: `ptr` is a pointer to `Registration<T>` set in `Registration::new` 265 268 let registration = unsafe { &*(ptr as *const Registration<T>) }; 266 269 // SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq ··· 481 478 /// # Safety 482 479 /// 483 480 /// This function should be only used as the callback in `request_threaded_irq`. 484 - unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler>( 481 + unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler + 'static>( 485 482 _irq: i32, 486 483 ptr: *mut c_void, 487 484 ) -> c_uint { ··· 497 494 /// # Safety 498 495 /// 499 496 /// This function should be only used as the callback in `request_threaded_irq`. 500 - unsafe extern "C" fn thread_fn_callback<T: ThreadedHandler>(_irq: i32, ptr: *mut c_void) -> c_uint { 497 + unsafe extern "C" fn thread_fn_callback<T: ThreadedHandler + 'static>( 498 + _irq: i32, 499 + ptr: *mut c_void, 500 + ) -> c_uint { 501 501 // SAFETY: `ptr` is a pointer to `ThreadedRegistration<T>` set in `ThreadedRegistration::new` 502 502 let registration = unsafe { &*(ptr as *const ThreadedRegistration<T>) }; 503 503 // SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq
+16 -9
rust/kernel/list/impl_list_item_mod.rs
··· 84 84 // right type. 85 85 unsafe impl$(<$($generics)*>)? $crate::list::HasSelfPtr<$item_type $(, $id)?> for $self {} 86 86 87 + // SAFETY: TODO. 87 88 unsafe impl$(<$($generics)*>)? $crate::list::HasListLinks$(<$id>)? for $self { 88 89 #[inline] 89 90 unsafe fn raw_get_list_links(ptr: *mut Self) -> *mut $crate::list::ListLinks$(<$id>)? { 90 - // SAFETY: The caller promises that the pointer is not dangling. 91 91 let ptr: *mut $crate::list::ListLinksSelfPtr<$item_type $(, $id)?> = 92 + // SAFETY: The caller promises that the pointer is not dangling. 92 93 unsafe { ::core::ptr::addr_of_mut!((*ptr)$(.$field)*) }; 93 94 ptr.cast() 94 95 } ··· 218 217 // SAFETY: `me` originates from the most recent call to `prepare_to_insert`, so it 219 218 // points at the field `$field` in a value of type `Self`. Thus, reversing that 220 219 // operation is still in-bounds of the allocation. 221 - $crate::container_of!(me, Self, $($field).*) 220 + unsafe { $crate::container_of!(me, Self, $($field).*) } 222 221 } 223 222 224 223 // GUARANTEES: ··· 243 242 // SAFETY: `me` originates from the most recent call to `prepare_to_insert`, so it 244 243 // points at the field `$field` in a value of type `Self`. Thus, reversing that 245 244 // operation is still in-bounds of the allocation. 246 - $crate::container_of!(me, Self, $($field).*) 245 + unsafe { $crate::container_of!(me, Self, $($field).*) } 247 246 } 248 247 } 249 248 )*}; ··· 271 270 // SAFETY: The caller promises that `me` points at a valid value of type `Self`. 272 271 let links_field = unsafe { <Self as $crate::list::ListItem<$num>>::view_links(me) }; 273 272 274 - let container = $crate::container_of!( 275 - links_field, $crate::list::ListLinksSelfPtr<Self, $num>, inner 276 - ); 273 + // SAFETY: TODO. 274 + let container = unsafe { 275 + $crate::container_of!( 276 + links_field, $crate::list::ListLinksSelfPtr<Self, $num>, inner 277 + ) 278 + }; 277 279 278 280 // SAFETY: By the same reasoning above, `links_field` is a valid pointer. 279 281 let self_ptr = unsafe { ··· 323 319 // `ListArc` containing `Self` until the next call to `post_remove`. The value cannot 324 320 // be destroyed while a `ListArc` reference exists. 325 321 unsafe fn view_value(links_field: *mut $crate::list::ListLinks<$num>) -> *const Self { 326 - let container = $crate::container_of!( 327 - links_field, $crate::list::ListLinksSelfPtr<Self, $num>, inner 328 - ); 322 + // SAFETY: TODO. 323 + let container = unsafe { 324 + $crate::container_of!( 325 + links_field, $crate::list::ListLinksSelfPtr<Self, $num>, inner 326 + ) 327 + }; 329 328 330 329 // SAFETY: By the same reasoning above, `links_field` is a valid pointer. 331 330 let self_ptr = unsafe {
+2 -2
rust/pin-init/src/lib.rs
··· 1143 1143 /// 1144 1144 /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a 1145 1145 /// pointer must result in a valid `U`. 1146 - #[expect(clippy::let_and_return)] 1147 1146 pub const unsafe fn cast_pin_init<T, U, E>(init: impl PinInit<T, E>) -> impl PinInit<U, E> { 1148 1147 // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety 1149 1148 // requirements. 1150 1149 let res = unsafe { pin_init_from_closure(|ptr: *mut U| init.__pinned_init(ptr.cast::<T>())) }; 1151 1150 // FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a 1152 1151 // cycle when computing the type returned by this function) 1152 + #[allow(clippy::let_and_return)] 1153 1153 res 1154 1154 } 1155 1155 ··· 1159 1159 /// 1160 1160 /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a 1161 1161 /// pointer must result in a valid `U`. 1162 - #[expect(clippy::let_and_return)] 1163 1162 pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> { 1164 1163 // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety 1165 1164 // requirements. 1166 1165 let res = unsafe { init_from_closure(|ptr: *mut U| init.__init(ptr.cast::<T>())) }; 1167 1166 // FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a 1168 1167 // cycle when computing the type returned by this function) 1168 + #[allow(clippy::let_and_return)] 1169 1169 res 1170 1170 } 1171 1171
+2 -1
tools/objtool/check.c
··· 197 197 * as well as changes to the source code itself between versions (since 198 198 * these come from the Rust standard library). 199 199 */ 200 - return str_ends_with(func->name, "_4core3num22from_ascii_radix_panic") || 200 + return str_ends_with(func->name, "_4core3num20from_str_radix_panic") || 201 + str_ends_with(func->name, "_4core3num22from_ascii_radix_panic") || 201 202 str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail") || 202 203 str_ends_with(func->name, "_4core6option13expect_failed") || 203 204 str_ends_with(func->name, "_4core6option13unwrap_failed") ||