[PATCH 2/2] rust: drop unnecessary lints caught by `#[expect(...)]`

Onur Özkan posted 2 patches 3 months, 2 weeks ago
[PATCH 2/2] rust: drop unnecessary lints caught by `#[expect(...)]`
Posted by Onur Özkan 3 months, 2 weeks ago
From: onur-ozkan <work@onurozkan.dev>

They are no longer needed.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 rust/kernel/cpufreq.rs | 1 -
 rust/kernel/error.rs   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index 7b20dff23a68..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> {}
 
-#[expect(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> {}
diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 1ff2d57c2f14..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) };
 
-        #[expect(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
Re: [PATCH 2/2] rust: drop unnecessary lints caught by `#[expect(...)]`
Posted by Miguel Ojeda 3 months, 2 weeks ago
On Thu, Jun 26, 2025 at 12:06 PM Onur Özkan <work@onurozkan.dev> wrote:
>
> -        #[expect(clippy::unnecessary_cast)]

We should avoid converting them into `expect` in the previous patch,
because then it would break the build between the commits (it is not
too critical if it is a Clippy one, but we still aim to keep builds
Clippy clean).

In addition, the reasoning for each of these not being needed may not
be immediately obvious (unlike other lint patches that follow all a
pattern). So it would be best to split the patches into cases to
explain each. For instance, this one is because with the new custom
FFI mappings `c_long` is always `isize` now, which is always different
from `c_int` (`i32`).

By the way, please Cc the rust-for-linux list too.

Thanks!

Cheers,
Miguel
Re: [PATCH 2/2] rust: drop unnecessary lints caught by `#[expect(...)]`
Posted by Onur 3 months, 2 weeks ago
On Thu, 26 Jun 2025 13:04:48 +0300
Onur Özkan <work@onurozkan.dev> wrote:

> From: onur-ozkan <work@onurozkan.dev>
> 
> They are no longer needed.
> 
> Signed-off-by: onur-ozkan <work@onurozkan.dev>

Oh crap... This should be "Onur Özkan" not "onur-ozkan".
I forgot to update that in my 2nd computer, which was used
to send this patch.