`ptr_eq` was recently enhanced to lint on more cases of raw pointers comparison: - lint on all raw pointer comparison, by proposing to use `[core|std]::ptr::eq(lhs, rhs)` instead of `lhs == rhs`; - removing one symetric `as usize` on each size if needed - peeling any level of `as *[const|mut] _` if the remaining expression can still be coerced into the original one (i.e., is a ref or raw pointer to the same type as before) The current change restricts the lint to the cases where at least one level of symetric `as usize`, or any conversion to a raw pointer, could be removed. For example, a direct comparaison of two raw pointers will not trigger the lint anymore.
17 lines
665 B
Text
17 lines
665 B
Text
error: use `core::ptr::eq` when comparing raw pointers
|
|
--> tests/ui/ptr_eq_no_std.rs:31:13
|
|
|
|
|
LL | let _ = a as *const _ as usize == b as *const _ as usize;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(a, b)`
|
|
|
|
|
= note: `-D clippy::ptr-eq` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]`
|
|
|
|
error: use `core::ptr::eq` when comparing raw pointers
|
|
--> tests/ui/ptr_eq_no_std.rs:33:13
|
|
|
|
|
LL | let _ = a as *const _ == b as *const _;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(a, b)`
|
|
|
|
error: aborting due to 2 previous errors
|
|
|