rust: allow Rust 1.87.0's `clippy::ptr_eq` lint
authorMiguel Ojeda <ojeda@kernel.org>
Fri, 2 May 2025 14:02:34 +0000 (16:02 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 6 May 2025 22:11:02 +0000 (00:11 +0200)
Starting with Rust 1.87.0 (expected 2025-05-15) [1], Clippy may expand
the `ptr_eq` lint, e.g.:

    error: use `core::ptr::eq` when comparing raw pointers
       --> rust/kernel/list.rs:438:12
        |
    438 |         if self.first == item {
        |            ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(self.first, item)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
        = note: `-D clippy::ptr-eq` implied by `-D warnings`
        = help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]`

It is expected that a PR to relax the lint will be backported [2] by
the time Rust 1.87.0 releases, since the lint was considered too eager
(at least by default) [3].

Thus allow the lint temporarily just in case.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: https://github.com/rust-lang/rust-clippy/pull/14339
Link: https://github.com/rust-lang/rust-clippy/pull/14526
Link: https://github.com/rust-lang/rust-clippy/issues/14525
Link: https://lore.kernel.org/r/20250502140237.1659624-3-ojeda@kernel.org
[ Converted to `allow`s since backport was confirmed. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/alloc/kvec.rs
rust/kernel/list.rs

index ae9d072741cedbb34bed0be0c20cc75472aa53be..87a71fd40c3cad18781ffaf2c758bb88922f640f 100644 (file)
@@ -2,6 +2,9 @@
 
 //! Implementation of [`Vec`].
 
+// May not be needed in Rust 1.87.0 (pending beta backport).
+#![allow(clippy::ptr_eq)]
+
 use super::{
     allocator::{KVmalloc, Kmalloc, Vmalloc},
     layout::ArrayLayout,
index a335c3b1ff5e48c246d3a771a2c3c750a4138419..2054682c5724ce4d7fd1aed039bf838c9a2be2e2 100644 (file)
@@ -4,6 +4,9 @@
 
 //! A linked list implementation.
 
+// May not be needed in Rust 1.87.0 (pending beta backport).
+#![allow(clippy::ptr_eq)]
+
 use crate::sync::ArcBorrow;
 use crate::types::Opaque;
 use core::iter::{DoubleEndedIterator, FusedIterator};