replace `allow(...)` lints with `expect(...)`
Subsystems (11)
Onur Özkan
reviewerv2 cover replace `allow(...)` lints with `expect(...)`
Changes in v2:
- Removed lints are not replaced with expect in the first diff.
- Removals are done in separate diffs for each.
The #[allow(clippy::non_send_fields_in_send_ty)] removal was tested on 1.81 and clippy was still happy with it. I couldn't test it on 1.78 because when I go below 1.81 menuconfig no longer shows the Rust option. And any manual changes I make to .config are immediately reverted on make invocations.
Onur Özkan (3):
replace #[allow(...)] with #[expect(...)]
rust: remove #[allow(clippy::unnecessary_cast)]
rust: remove #[allow(clippy::non_send_fields_in_send_ty)]
drivers/gpu/nova-core/regs.rs | 2 +- rust/compiler_builtins.rs | 2 +- rust/kernel/alloc/allocator_test.rs | 2 +- rust/kernel/cpufreq.rs | 1 - rust/kernel/devres.rs | 2 +- rust/kernel/driver.rs | 2 +- rust/kernel/drm/ioctl.rs | 8 ++++---- rust/kernel/error.rs | 3 +-- rust/kernel/init.rs | 6 +++--- rust/kernel/kunit.rs | 2 +- rust/kernel/opp.rs | 4 ++-- rust/kernel/types.rs | 2 +- rust/macros/helpers.rs | 2 +- 13 files changed, 18 insertions(+), 20 deletions(-)
--
2.50.0
Onur Özkan
reviewerPATCH v2 1/3 replace `#[allow(...)]` with `#[expect(...)]`
This makes it clear that the warning is expected not just ignored, so we don't end up having various unnecessary linting rules in the codebase.
Some parts of the codebase already use this approach, this patch just applies it more broadly.
--- drivers/gpu/nova-core/regs.rs | 2 +- rust/compiler_builtins.rs | 2 +- rust/kernel/alloc/allocator_test.rs | 2 +- rust/kernel/devres.rs | 2 +- rust/kernel/driver.rs | 2 +- rust/kernel/drm/ioctl.rs | 8 ++++---- rust/kernel/error.rs | 2 +- rust/kernel/init.rs | 6 +++--- rust/kernel/kunit.rs | 2 +- rust/kernel/opp.rs | 4 ++-- rust/kernel/types.rs | 2 +- rust/macros/helpers.rs | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/nova-core/regs.rs +1 -1
@@ -2,7 +2,7 @@// Required to retain the original register names used by OpenRM, which are all capital snake case // but are mapped to types. -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] #[macro_use] mod macros;
rust/compiler_builtins.rs +1 -1
@@ -19,7 +19,7 @@//! [`compiler_builtins`]: https://github.com/rust-lang/compiler-builtins //! [`compiler-rt`]: https://compiler-rt.llvm.org/ -#![allow(internal_features)] +#![expect(internal_features)] #![feature(compiler_builtins)] #![compiler_builtins] #![no_builtins]
rust/kernel/alloc/allocator_test.rs +1 -1
@@ -7,7 +7,7 @@//! `Cmalloc` allocator within the `allocator_test` module and type alias all kernel allocators to //! `Cmalloc`. The `Cmalloc` allocator uses libc's `realloc()` function as allocator backend. -#![allow(missing_docs)] +#![expect(missing_docs)] use super ::{flags::*,AllocError ,Allocator ,Flags };use core::alloc::Layout ;
rust/kernel/devres.rs +1 -1
@@ -157,7 +157,7 @@ fn remove_action(this: &Arc<Self>) -> bool { success } -#[allow(clippy::missing_safety_doc)] +#[expect(clippy::missing_safety_doc)] unsafe extern "C" fn devres_callback (ptr: *mut kernel::ffi::c_void ) {let ptr = ptras *mut DevresInner <T >;// Devres owned this memory; now that we received the callback, drop the `Arc` and hence the
rust/kernel/driver.rs +1 -1
@@ -168,7 +168,7 @@ fn of_id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> { }#[cfg(not( CONFIG_OF ))] -#[allow(missing_docs)] +#[expect(missing_docs)] fn of_id_info (_dev: &device::Device ) ->Option <&'staticSelf ::IdInfo > {None }
rust/kernel/drm/ioctl.rs +4 -4
@@ -9,28 +9,28 @@const BASE :u32 = uapi::DRM_IOCTL_BASE as u32 ;/// Construct a DRM ioctl number with no argument. -#[allow(non_snake_case)] +#[expect(non_snake_case)] #[inline(always)] pub const fn IO (nr:u32 ) ->u32 { ioctl::_IO (BASE , nr) }/// Construct a DRM ioctl number with a read-only argument. -#[allow(non_snake_case)] +#[expect(non_snake_case)] #[inline(always)] pub const fn IOR <T >(nr:u32 ) ->u32 { ioctl::_IOR ::<T >(BASE , nr) }/// Construct a DRM ioctl number with a write-only argument. -#[allow(non_snake_case)] +#[expect(non_snake_case)] #[inline(always)] pub const fn IOW <T >(nr:u32 ) ->u32 { ioctl::_IOW ::<T >(BASE , nr) }/// Construct a DRM ioctl number with a read-write argument. -#[allow(non_snake_case)] +#[expect(non_snake_case)] #[inline(always)] pub const fn IOWR <T >(nr:u32 ) ->u32 { ioctl::_IOWR ::<T >(BASE , nr)
rust/kernel/error.rs +1 -1
@@ -263,7 +263,7 @@ fn from(e: core::convert::Infallible) -> Error {/// [`samples/rust/rust_minimal.rs`]): /// /// ``` -/// # #[allow(clippy::single_match)] +/// # #[expect(clippy::single_match)] /// fn example() -> Result { /// let mut numbers = KVec::new(); ///
rust/kernel/init.rs +3 -3
@@ -30,7 +30,7 @@//! ## General Examples //! //! ```rust,ignore -//! # #![allow(clippy::disallowed_names)] +//! # #![expect(clippy::disallowed_names)] //! use kernel::types::Opaque; //! use pin_init::pin_init_from_closure; //!
@@ -67,11 +67,11 @@//! ``` //! //! ```rust,ignore -//! # #![allow(unreachable_pub, clippy::disallowed_names)] +//! # #![expect(unreachable_pub, clippy::disallowed_names)] //! use kernel::{prelude::*, types::Opaque}; //! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin}; //! # mod bindings { -//! # #![allow(non_camel_case_types)] +//! # #![expect(non_camel_case_types)] //! # pub struct foo; //! # pub unsafe fn init_foo(_ptr: *mut foo) {} //! # pub unsafe fn destroy_foo(_ptr: *mut foo) {}
rust/kernel/kunit.rs +1 -1
@@ -280,7 +280,7 @@ macro_rules! kunit_unsafe_test_suite {static mut KUNIT_TEST_SUITE : ::kernel::bindings::kunit_suite = ::kernel::bindings::kunit_suite { name:KUNIT_TEST_SUITE_NAME , - #[allow(unused_unsafe)] + #[expect(unused_unsafe)] // SAFETY: `$test_cases` is passed in by the user, and // (as documented) must be valid for the lifetime of // the suite (i.e., static).
rust/kernel/opp.rs +2 -2
@@ -600,9 +600,9 @@ extern "C" fn config_regulators(pub struct Table { ptr: *mut bindings::opp_table , dev:ARef <Device >, -#[allow(dead_code)] +#[expect(dead_code)] em:bool , -#[allow(dead_code)] +#[expect(dead_code)] of:bool , cpus:Option <CpumaskVar >, }
rust/kernel/types.rs +1 -1
@@ -600,5 +600,5 @@ pub enum Either<L, R> {/// constructed. /// /// [`NotThreadSafe`]: type@NotThreadSafe -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub const NotThreadSafe :NotThreadSafe =PhantomData ;
rust/macros/helpers.rs +1 -1
@@ -98,7 +98,7 @@ pub(crate) fn file() -> String { }#[cfg( CONFIG_RUSTC_HAS_SPAN_FILE )] -#[allow(clippy::incompatible_msrv)] +#[expect(clippy::incompatible_msrv)] { proc_macro::Span ::call_site ().file () }
--
2.50.0
Onur Özkan
reviewerPATCH v2 2/3 rust: remove `#[allow(clippy::unnecessary_cast)]`
In reply to Onur ÖzkanThis isn't needed anymore since kernel::ffi::c_int type is always i32 which differs from err (isize).
--- rust/kernel/error.rs | 1 - 1 file changed, 1 deletion(-)
rust/kernel/error.rs +0 -1
@@ -413,7 +413,6 @@ pub fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {// SAFETY: The FFI function does not deref the pointer. let err =unsafe { bindings::PTR_ERR (const_ptr) }; -#[allow(clippy::unnecessary_cast)] // CAST: If `IS_ERR()` returns `true`, // then `PTR_ERR()` is guaranteed to return a // negative value greater-or-equal to `-bindings::MAX_ERRNO`,
--
2.50.0
Onur Özkan
reviewerPATCH v2 3/3 rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]`
In reply to Onur ÖzkanClippy no longer complains about this lint.
--- rust/kernel/cpufreq.rs | 1 - 1 file changed, 1 deletion(-)
rust/kernel/cpufreq.rs +0 -1
@@ -907,7 +907,6 @@ fn register_em(_policy: &mut Policy) {/// or CPUs, so it is safe to share it. unsafe impl <T :Driver >Sync for Registration <T > {} -#[allow(clippy::non_send_fields_in_send_ty)] /// SAFETY: Registration with and unregistration from the cpufreq subsystem can happen from any /// thread. unsafe impl <T :Driver >Send for Registration <T > {}
--
2.50.0
Quoted 6 lines · Onur Özkan
The
#[allow(clippy::non_send_fields_in_send_ty)]removal was tested on 1.81 and clippy was still happy with it. I couldn't test it on 1.78 because when I go below 1.81menuconfigno longer shows the Rust option. And any manual changes I make to.configare immediately reverted onmakeinvocations.
For that, I recommend using the / command inside menuconfig -- it allows you to see the dependencies of a given symbol, and whether they are met or not. That way, it allows one to understand what else may be missing to enable a symbol.
I hope that helps.
Cheers,
Miguel
Onur
reviewerQuoted 13 lines · On Fri, 27 Jun 2025 17:55:41 +0200 Miguel Ojeda…
Quoted 6 lines · Onur Özkan
The
#[allow(clippy::non_send_fields_in_send_ty)]removal was tested on 1.81 and clippy was still happy with it. I couldn't test it on 1.78 because when I go below 1.81menuconfigno longer shows the Rust option. And any manual changes I make to.configare immediately reverted onmakeinvocations.For that, I recommend using the
/command insidemenuconfig-- it allows you to see the dependencies of a given symbol, and whether they are met or not. That way, it allows one to understand what else may be missing to enable a symbol.
Quoted 4 lines
I hope that helps.
Cheers,
Miguel
I already tried that but it didn't helped. I was able to make it work with manually hacking the init/Kconfig file.
Removal of #[allow(clippy::non_send_fields_in_send_ty)] still works as expected, but using #![expect(internal_features)] (which was done in the first diff) doesn't work on 1.78. I will revert that and send v3 patch in a short.
Regards,
Onur
Quoted 3 lines · Onur
I already tried that but it didn't helped. I was able to make it work with manually hacking the
init/Kconfigfile.
That should not be needed -- the / command should tell you what you are missing.
Cheers,
Miguel