RS.CLIPPY.PTR_EQ
Use `std::ptr::eq` when comparing raw pointers
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: ptr_eq. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Use std::ptr::eq when applicable
Why is this bad?
ptr::eq can be used to compare &T references
(which coerce to *const T implicitly) by their address rather than
comparing the values they point to.
Example
let a = &[1, 2, 3];
let b = &[1, 2, 3];
assert!(a as *const _ as usize == b as *const _ as usize);
Use instead:
let a = &[1, 2, 3];
let b = &[1, 2, 3];
assert!(std::ptr::eq(a, b));