summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/ptr_eq.fixed
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-09 20:37:37 +0000
committerbors <bors@rust-lang.org>2025-05-09 20:37:37 +0000
commit17067e9ac6d7ecb70e50f92c1944e545188d2359 (patch)
tree10cdfd82bfa6bb95d7e99b7ab53d8121fc7a8913 /src/tools/clippy/tests/ui/ptr_eq.fixed
parentaf91af44eb85ceac634afa72cc73be4af358b350 (diff)
parent908c30b3e1b758d46501de460163e9761c65534f (diff)
downloadrust-1.87.0.tar.gz
rust-1.87.0.zip
Auto merge of #140859 - pietroalbini:pa-stable, r=pietroalbini 1.87.0
[stable] Prepare the 1.87.0 release

Preparing the stable artifacts as described in the release process.

This PR also includes the following last minute backports:

* https://github.com/rust-lang/rust/pull/140810
* https://github.com/rust-lang/rust/pull/140601
* https://github.com/rust-lang/rust/pull/140684

r? `@ghost`
Diffstat (limited to 'src/tools/clippy/tests/ui/ptr_eq.fixed')
-rw-r--r--src/tools/clippy/tests/ui/ptr_eq.fixed31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/tools/clippy/tests/ui/ptr_eq.fixed b/src/tools/clippy/tests/ui/ptr_eq.fixed
index df6305ed497..f0150e6784b 100644
--- a/src/tools/clippy/tests/ui/ptr_eq.fixed
+++ b/src/tools/clippy/tests/ui/ptr_eq.fixed
@@ -4,6 +4,9 @@ macro_rules! mac {
     ($a:expr, $b:expr) => {
         $a as *const _ as usize == $b as *const _ as usize
     };
+    (cast $a:expr) => {
+        $a as *const [i32; 3]
+    };
 }
 
 macro_rules! another_mac {
@@ -20,23 +23,25 @@ fn main() {
     //~^ ptr_eq
     let _ = std::ptr::eq(a, b);
     //~^ ptr_eq
-    let _ = std::ptr::eq(a.as_ptr(), b as *const _);
-    //~^ ptr_eq
-    let _ = std::ptr::eq(a.as_ptr(), b.as_ptr());
-    //~^ ptr_eq
 
-    // Do not lint
+    // Do not lint: the rhs conversion is needed
+    let _ = a.as_ptr() == b as *const _;
+
+    // Do not lint: we have two raw pointers already
+    let _ = a.as_ptr() == b.as_ptr();
 
+    // Do not lint
     let _ = mac!(a, b);
     let _ = another_mac!(a, b);
 
     let a = &mut [1, 2, 3];
     let b = &mut [1, 2, 3];
 
-    let _ = std::ptr::eq(a.as_mut_ptr(), b as *mut [i32] as *mut _);
-    //~^ ptr_eq
-    let _ = std::ptr::eq(a.as_mut_ptr(), b.as_mut_ptr());
-    //~^ ptr_eq
+    // Do not lint: the rhs conversion is needed
+    let _ = a.as_mut_ptr() == b as *mut [i32] as *mut _;
+
+    // Do not lint: we have two raw pointers already
+    let _ = a.as_mut_ptr() == b.as_mut_ptr();
 
     let _ = a == b;
     let _ = core::ptr::eq(a, b);
@@ -48,7 +53,11 @@ fn main() {
     let _ = !std::ptr::eq(x, y);
     //~^ ptr_eq
 
-    #[allow(clippy::eq_op)]
-    let _issue14337 = std::ptr::eq(main as *const (), main as *const ());
+    #[expect(clippy::eq_op)]
+    // Do not lint: casts are needed to not change type
+    let _issue14337 = main as *const () == main as *const ();
+
+    // Do not peel the content of macros
+    let _ = std::ptr::eq(mac!(cast a), mac!(cast b));
     //~^ ptr_eq
 }