rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)`
@ 2025-07-01  5:35 Onur Özkan
  2025-07-01  5:35 ` [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules Onur Özkan
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

Changes in v4:
  - The first patch from previous versions is now
    broken down into multiple smaller patches.
  - `#![expect(dead_code)]` is reverted from
    `rust/kernel/opp.rs` as it failed on the
    kernel test bot (see [1] for more).


Link: https://lore.kernel.org/all/202506291507.M9eg5kic-lkp@intel.com [1]

Onur Özkan (6):
  rust: switch to `#[expect(...)]` in core modules
  rust: switch to `#[expect(...)]` in init and kunit
  drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs
  rust: switch to `#[expect(...)]` in devres, driver and ioctl
  rust: remove `#[allow(clippy::unnecessary_cast)]`
  rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]`

 drivers/gpu/nova-core/regs.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/types.rs                | 2 +-
 rust/macros/helpers.rs              | 2 +-
 11 files changed, 15 insertions(+), 17 deletions(-)

--
2.50.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
@ 2025-07-01  5:35 ` Onur Özkan
  2025-07-09  2:33   ` Trevor Gross
  2025-07-01  5:35 ` [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit Onur Özkan
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

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.

No functional changes.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/alloc/allocator_test.rs | 2 +-
 rust/kernel/error.rs                | 2 +-
 rust/kernel/types.rs                | 2 +-
 rust/macros/helpers.rs              | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/alloc/allocator_test.rs b/rust/kernel/alloc/allocator_test.rs
index d19c06ef0498..844197d7194e 100644
--- a/rust/kernel/alloc/allocator_test.rs
+++ b/rust/kernel/alloc/allocator_test.rs
@@ -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;
diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 3dee3139fcd4..a59613918d4c 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -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();
 ///
diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
index 22985b6f6982..a5d5a4737a41 100644
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@ -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;
diff --git a/rust/macros/helpers.rs b/rust/macros/helpers.rs
index e2602be402c1..6fd1462ff01a 100644
--- a/rust/macros/helpers.rs
+++ b/rust/macros/helpers.rs
@@ -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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
  2025-07-01  5:35 ` [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules Onur Özkan
@ 2025-07-01  5:35 ` Onur Özkan
  2025-07-02 18:47   ` Benno Lossin
  2025-07-09  2:39   ` Trevor Gross
  2025-07-01  5:35 ` [PATCH v4 3/6] drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs Onur Özkan
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

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.

No functional changes.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/init.rs  | 6 +++---
 rust/kernel/kunit.rs | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 8d228c237954..288b1c2a290d 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -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) {}
diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
index 4b8cdcb21e77..91710a1d7b87 100644
--- a/rust/kernel/kunit.rs
+++ b/rust/kernel/kunit.rs
@@ -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).
--
2.50.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 3/6] drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
  2025-07-01  5:35 ` [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules Onur Özkan
  2025-07-01  5:35 ` [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit Onur Özkan
@ 2025-07-01  5:35 ` Onur Özkan
  2025-07-09  2:42   ` Trevor Gross
  2025-07-01  5:35 ` [PATCH v4 4/6] rust: switch to `#[expect(...)]` in devres, driver and ioctl Onur Özkan
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

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.

No functional changes.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 drivers/gpu/nova-core/regs.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs
index 5a1273230306..87e5963f1ebb 100644
--- a/drivers/gpu/nova-core/regs.rs
+++ b/drivers/gpu/nova-core/regs.rs
@@ -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;
--
2.50.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 4/6] rust: switch to `#[expect(...)]` in devres, driver and ioctl
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
                   ` (2 preceding siblings ...)
  2025-07-01  5:35 ` [PATCH v4 3/6] drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs Onur Özkan
@ 2025-07-01  5:35 ` Onur Özkan
  2025-07-01  5:35 ` [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]` Onur Özkan
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

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.

No functional changes.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/devres.rs    | 2 +-
 rust/kernel/driver.rs    | 2 +-
 rust/kernel/drm/ioctl.rs | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
index 57502534d985..0e9510cf4625 100644
--- a/rust/kernel/devres.rs
+++ b/rust/kernel/devres.rs
@@ -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 = ptr as *mut DevresInner<T>;
         // Devres owned this memory; now that we received the callback, drop the `Arc` and hence the
diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
index ec9166cedfa7..fc7bd65b01f1 100644
--- a/rust/kernel/driver.rs
+++ b/rust/kernel/driver.rs
@@ -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<&'static Self::IdInfo> {
         None
     }
diff --git a/rust/kernel/drm/ioctl.rs b/rust/kernel/drm/ioctl.rs
index 445639404fb7..3ae8d2d8263f 100644
--- a/rust/kernel/drm/ioctl.rs
+++ b/rust/kernel/drm/ioctl.rs
@@ -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)
--
2.50.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]`
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
                   ` (3 preceding siblings ...)
  2025-07-01  5:35 ` [PATCH v4 4/6] rust: switch to `#[expect(...)]` in devres, driver and ioctl Onur Özkan
@ 2025-07-01  5:35 ` Onur Özkan
  2025-07-09  2:37   ` Trevor Gross
  2025-07-01  5:35 ` [PATCH v4 6/6] rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]` Onur Özkan
  2025-07-01  8:43 ` [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Miguel Ojeda
  6 siblings, 1 reply; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

This isn't needed anymore since `kernel::ffi::c_int` type
is always `i32` which differs from `err` (isize).

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/error.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index a59613918d4c..05c6e71c0afb 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 6/6] rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]`
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
                   ` (4 preceding siblings ...)
  2025-07-01  5:35 ` [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]` Onur Özkan
@ 2025-07-01  5:35 ` Onur Özkan
  2025-07-01  8:46   ` Miguel Ojeda
  2025-07-01  8:43 ` [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Miguel Ojeda
  6 siblings, 1 reply; 17+ messages in thread
From: Onur Özkan @ 2025-07-01  5:35 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar,
	gregkh, maarten.lankhorst, mripard, tzimmermann, davidgow, nm,
	Onur Özkan

Just like how we did in [1], we no longer need this lint
as it's no longer part of Clippy's `suspicious` lint group.

Link: https://github.com/torvalds/linux/commit/5e7c9b84ad08cc7a41b2ddbbbaccb60057da3860 [1]

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/cpufreq.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index 11b03e9d7e89..97de9b0573da 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)`
  2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
                   ` (5 preceding siblings ...)
  2025-07-01  5:35 ` [PATCH v4 6/6] rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]` Onur Özkan
@ 2025-07-01  8:43 ` Miguel Ojeda
  2025-07-01 17:27   ` Onur
  6 siblings, 1 reply; 17+ messages in thread
From: Miguel Ojeda @ 2025-07-01  8:43 UTC (permalink / raw)
  To: Onur Özkan
  Cc: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev, airlied, simona, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, rafael,
	viresh.kumar, gregkh, maarten.lankhorst, mripard, tzimmermann,
	davidgow, nm

On Tue, Jul 1, 2025 at 7:36 AM Onur Özkan <work@onurozkan.dev> wrote:
>
> Onur Özkan (6):
>   rust: switch to `#[expect(...)]` in core modules
>   rust: switch to `#[expect(...)]` in init and kunit
>   drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs
>   rust: switch to `#[expect(...)]` in devres, driver and ioctl
>   rust: remove `#[allow(clippy::unnecessary_cast)]`
>   rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]`

Thanks for splitting this, it is very much appreciated.

I think you decided on a split based on similarity (?). In the kernel,
different maintainers/trees take care of different areas/files (the
`MAINTAINERS` file describes this mapping). For instance, in one of
them, KUnit and init is mixed, which are maintained by different
people.

That is why the split I suggested was one that allows maintainers to
pick them independently. With this one, maintainers still have to
coordinate, which isn't a big deal, since the changes are small and
straightforward, but the purpose of the split was to avoid that.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 6/6] rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]`
  2025-07-01  5:35 ` [PATCH v4 6/6] rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]` Onur Özkan
@ 2025-07-01  8:46   ` Miguel Ojeda
  0 siblings, 0 replies; 17+ messages in thread
From: Miguel Ojeda @ 2025-07-01  8:46 UTC (permalink / raw)
  To: Onur Özkan
  Cc: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev, airlied, simona, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, rafael,
	viresh.kumar, gregkh, maarten.lankhorst, mripard, tzimmermann,
	davidgow, nm

On Tue, Jul 1, 2025 at 7:36 AM Onur Özkan <work@onurozkan.dev> wrote:
>
> Just like how we did in [1], we no longer need this lint
> as it's no longer part of Clippy's `suspicious` lint group.
>
> Link: https://github.com/torvalds/linux/commit/5e7c9b84ad08cc7a41b2ddbbbaccb60057da3860 [1]

Normally this format is used:

    ... did in commit 5e7c9b84ad08 ("rust: sync: remove unneeded
`#[allow(clippy::non_send_fields_in_send_ty)]`"), we no longer ...

Maintainers may want to fix this when they apply the patch, so I
wouldn't send a new version just for this (but if you do, then please
reword it).

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)`
  2025-07-01  8:43 ` [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Miguel Ojeda
@ 2025-07-01 17:27   ` Onur
  0 siblings, 0 replies; 17+ messages in thread
From: Onur @ 2025-07-01 17:27 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: rust-for-linux, linux-kernel, linux-pm, linux-kselftest,
	kunit-dev, airlied, simona, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, rafael,
	viresh.kumar, gregkh, maarten.lankhorst, mripard, tzimmermann,
	davidgow, nm

On Tue, 1 Jul 2025 10:43:10 +0200
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Tue, Jul 1, 2025 at 7:36 AM Onur Özkan <work@onurozkan.dev> wrote:
> >
> > Onur Özkan (6):
> >   rust: switch to `#[expect(...)]` in core modules
> >   rust: switch to `#[expect(...)]` in init and kunit
> >   drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs
> >   rust: switch to `#[expect(...)]` in devres, driver and ioctl
> >   rust: remove `#[allow(clippy::unnecessary_cast)]`
> >   rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]`
> 
> Thanks for splitting this, it is very much appreciated.
> 
> I think you decided on a split based on similarity (?). In the kernel,
> different maintainers/trees take care of different areas/files (the
> `MAINTAINERS` file describes this mapping). For instance, in one of
> them, KUnit and init is mixed, which are maintained by different
> people.

I didn't know I could use `MAINTAINERS` file to organize my changes.

> That is why the split I suggested was one that allows maintainers to
> pick them independently. With this one, maintainers still have to
> coordinate, which isn't a big deal, since the changes are small and
> straightforward, but the purpose of the split was to avoid that.


I see, I will make sure to use `MAINTAINERS` file as a ref next
time, thank you. :)

Regards,
Onur

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit
  2025-07-01  5:35 ` [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit Onur Özkan
@ 2025-07-02 18:47   ` Benno Lossin
  2025-07-07 13:02     ` Miguel Ojeda
  2025-07-09  2:39   ` Trevor Gross
  1 sibling, 1 reply; 17+ messages in thread
From: Benno Lossin @ 2025-07-02 18:47 UTC (permalink / raw)
  To: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	a.hindborg, aliceryhl, tmgross, rafael, viresh.kumar, gregkh,
	maarten.lankhorst, mripard, tzimmermann, davidgow, nm

	 
On Tue Jul 1, 2025 at 7:35 AM CEST, Onur Özkan wrote:
> 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.
>
> No functional changes.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
>  rust/kernel/init.rs  | 6 +++---
>  rust/kernel/kunit.rs | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)

@Miguel are you going to pick this eventually, or do you think it should 
have a new version with the right splitting?	

---
Cheers,
Benno





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit
  2025-07-02 18:47   ` Benno Lossin
@ 2025-07-07 13:02     ` Miguel Ojeda
  2025-07-07 15:27       ` Benno Lossin
  0 siblings, 1 reply; 17+ messages in thread
From: Miguel Ojeda @ 2025-07-07 13:02 UTC (permalink / raw)
  To: Benno Lossin
  Cc: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev, airlied, simona, ojeda, alex.gaynor,
	boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl, tmgross,
	rafael, viresh.kumar, gregkh, maarten.lankhorst, mripard,
	tzimmermann, davidgow, nm

On Wed, Jul 2, 2025 at 8:47 PM Benno Lossin <lossin@kernel.org> wrote:
>
> @Miguel are you going to pick this eventually, or do you think it should
> have a new version with the right splitting?

I guess I could take it since the series can only introduce build
failures at worst.

However, I thought we were going to do the proper split (as
independent patches, too) and then let each maintainer pick each on
their own pace.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit
  2025-07-07 13:02     ` Miguel Ojeda
@ 2025-07-07 15:27       ` Benno Lossin
  0 siblings, 0 replies; 17+ messages in thread
From: Benno Lossin @ 2025-07-07 15:27 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev, airlied, simona, ojeda, alex.gaynor,
	boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl, tmgross,
	rafael, viresh.kumar, gregkh, maarten.lankhorst, mripard,
	tzimmermann, davidgow, nm

On Mon Jul 7, 2025 at 3:02 PM CEST, Miguel Ojeda wrote:
> On Wed, Jul 2, 2025 at 8:47 PM Benno Lossin <lossin@kernel.org> wrote:
>>
>> @Miguel are you going to pick this eventually, or do you think it should
>> have a new version with the right splitting?
>
> I guess I could take it since the series can only introduce build
> failures at worst.
>
> However, I thought we were going to do the proper split (as
> independent patches, too) and then let each maintainer pick each on
> their own pace.

I also think it's better to split it correctly.

---
Cheers,
Benno

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules
  2025-07-01  5:35 ` [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules Onur Özkan
@ 2025-07-09  2:33   ` Trevor Gross
  0 siblings, 0 replies; 17+ messages in thread
From: Trevor Gross @ 2025-07-09  2:33 UTC (permalink / raw)
  To: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, rafael, viresh.kumar, gregkh,
	maarten.lankhorst, mripard, tzimmermann, davidgow, nm

On Tue Jul 1, 2025 at 12:35 AM CDT, Onur Özkan wrote:
> 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.
>
> No functional changes.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---

> diff --git a/rust/kernel/alloc/allocator_test.rs b/rust/kernel/alloc/allocator_test.rs
> index d19c06ef0498..844197d7194e 100644
> --- a/rust/kernel/alloc/allocator_test.rs
> +++ b/rust/kernel/alloc/allocator_test.rs
> @@ -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;

If you spin this again, would you mind adding a comment/`reason` about
why there isn't documentation here?

This is preexisting but something to shift the possible meaning from
"this module shouldn't have documentation" to "it's okay that we don't
document unstable test interfaces" would be helpful.

Thanks,
Trevor


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]`
  2025-07-01  5:35 ` [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]` Onur Özkan
@ 2025-07-09  2:37   ` Trevor Gross
  0 siblings, 0 replies; 17+ messages in thread
From: Trevor Gross @ 2025-07-09  2:37 UTC (permalink / raw)
  To: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, rafael, viresh.kumar, gregkh,
	maarten.lankhorst, mripard, tzimmermann, davidgow, nm

On Tue Jul 1, 2025 at 12:35 AM CDT, Onur Özkan wrote:
> This isn't needed anymore since `kernel::ffi::c_int` type
> is always `i32` which differs from `err` (isize).
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
>  rust/kernel/error.rs | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
> index a59613918d4c..05c6e71c0afb 100644
> --- a/rust/kernel/error.rs
> +++ b/rust/kernel/error.rs
> @@ -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

Reviewed-by: Trevor Gross <tmgross@umich.edu>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit
  2025-07-01  5:35 ` [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit Onur Özkan
  2025-07-02 18:47   ` Benno Lossin
@ 2025-07-09  2:39   ` Trevor Gross
  1 sibling, 0 replies; 17+ messages in thread
From: Trevor Gross @ 2025-07-09  2:39 UTC (permalink / raw)
  To: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, rafael, viresh.kumar, gregkh,
	maarten.lankhorst, mripard, tzimmermann, davidgow, nm

On Tue Jul 1, 2025 at 12:35 AM CDT, Onur Özkan wrote:
> 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.
>
> No functional changes.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
>  rust/kernel/init.rs  | 6 +++---
>  rust/kernel/kunit.rs | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
> index 8d228c237954..288b1c2a290d 100644
> --- a/rust/kernel/init.rs
> +++ b/rust/kernel/init.rs
> @@ -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) {}
> diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
> index 4b8cdcb21e77..91710a1d7b87 100644
> --- a/rust/kernel/kunit.rs
> +++ b/rust/kernel/kunit.rs
> @@ -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).
> --
> 2.50.0

Understood that the files may wind up split here, but the changes look
good to me.

Reviewed-by: Trevor Gross <tmgross@umich.edu>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 3/6] drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs
  2025-07-01  5:35 ` [PATCH v4 3/6] drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs Onur Özkan
@ 2025-07-09  2:42   ` Trevor Gross
  0 siblings, 0 replies; 17+ messages in thread
From: Trevor Gross @ 2025-07-09  2:42 UTC (permalink / raw)
  To: Onur Özkan, rust-for-linux, linux-kernel, linux-pm,
	linux-kselftest, kunit-dev
  Cc: airlied, simona, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, rafael, viresh.kumar, gregkh,
	maarten.lankhorst, mripard, tzimmermann, davidgow, nm

On Tue Jul 1, 2025 at 1:35 AM EDT, Onur Özkan wrote:
> 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.
>
> No functional changes.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
>  drivers/gpu/nova-core/regs.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs
> index 5a1273230306..87e5963f1ebb 100644
> --- a/drivers/gpu/nova-core/regs.rs
> +++ b/drivers/gpu/nova-core/regs.rs
> @@ -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;
> --
> 2.50.0

Reviewed-by: Trevor Gross <tmgross@umich.edu>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-07-09  2:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01  5:35 [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Onur Özkan
2025-07-01  5:35 ` [PATCH v4 1/6] rust: switch to `#[expect(...)]` in core modules Onur Özkan
2025-07-09  2:33   ` Trevor Gross
2025-07-01  5:35 ` [PATCH v4 2/6] rust: switch to `#[expect(...)]` in init and kunit Onur Özkan
2025-07-02 18:47   ` Benno Lossin
2025-07-07 13:02     ` Miguel Ojeda
2025-07-07 15:27       ` Benno Lossin
2025-07-09  2:39   ` Trevor Gross
2025-07-01  5:35 ` [PATCH v4 3/6] drivers: gpu: switch to `#[expect(...)]` in nova-core/regs.rs Onur Özkan
2025-07-09  2:42   ` Trevor Gross
2025-07-01  5:35 ` [PATCH v4 4/6] rust: switch to `#[expect(...)]` in devres, driver and ioctl Onur Özkan
2025-07-01  5:35 ` [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]` Onur Özkan
2025-07-09  2:37   ` Trevor Gross
2025-07-01  5:35 ` [PATCH v4 6/6] rust: remove `#[allow(clippy::non_send_fields_in_send_ty)]` Onur Özkan
2025-07-01  8:46   ` Miguel Ojeda
2025-07-01  8:43 ` [PATCH v4 0/6] replace `allow(...)` lints with `expect(...)` Miguel Ojeda
2025-07-01 17:27   ` Onur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).