about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-11 14:33:16 +0000
committerbors <bors@rust-lang.org>2023-12-11 14:33:16 +0000
commit8a3765582cb83733f8c344062729df0175409488 (patch)
tree8d12a60e5cd08152acc1800ccbb39652b8d28c35 /tests
parentff2c56344c764af598ad33027e9c7a48881808ef (diff)
parent5e1bfb538f195eeac02034c0779f42d34b0e869e (diff)
downloadrust-8a3765582cb83733f8c344062729df0175409488.tar.gz
rust-8a3765582cb83733f8c344062729df0175409488.zip
Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
Add lint against ambiguous wide pointer comparisons

This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang.

## `ambiguous_wide_pointer_comparisons`

*warn-by-default*

The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands.

### Example

```rust
let ab = (A, B);
let a = &ab.0 as *const dyn T;
let b = &ab.1 as *const dyn T;

let _ = a == b;
```

### Explanation

The comparison includes metadata which may not be expected.

-------

This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one.

~~One thing: is the current naming right? `invalid` seems a bit too much.~~

Fixes https://github.com/rust-lang/rust/issues/117717
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/issues/issue-17336.rs3
-rw-r--r--tests/ui/lint/wide_pointer_comparisons.rs138
-rw-r--r--tests/ui/lint/wide_pointer_comparisons.stderr452
-rw-r--r--tests/ui/mir/mir_raw_fat_ptr.rs2
4 files changed, 595 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-17336.rs b/tests/ui/issues/issue-17336.rs
index 89ce59b11f2..97782ff9f0e 100644
--- a/tests/ui/issues/issue-17336.rs
+++ b/tests/ui/issues/issue-17336.rs
@@ -1,5 +1,8 @@
 // build-pass
+
 #![allow(unused_must_use)]
+#![allow(ambiguous_wide_pointer_comparisons)]
+
 #[allow(dead_code)]
 fn check(a: &str) {
     let x = a as *const str;
diff --git a/tests/ui/lint/wide_pointer_comparisons.rs b/tests/ui/lint/wide_pointer_comparisons.rs
new file mode 100644
index 00000000000..8334575cf52
--- /dev/null
+++ b/tests/ui/lint/wide_pointer_comparisons.rs
@@ -0,0 +1,138 @@
+// check-pass
+
+use std::rc::Rc;
+use std::sync::Arc;
+use std::cmp::PartialEq;
+
+struct A;
+struct B;
+
+trait T {}
+impl T for A {}
+impl T for B {}
+
+fn main() {
+    let ab = (A, B);
+    let a = &ab.0 as *const dyn T;
+    let b = &ab.1 as *const dyn T;
+
+    let _ = a == b;
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a != b;
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a < b;
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a <= b;
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a > b;
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a >= b;
+    //~^ WARN ambiguous wide pointer comparison
+
+    let _ = PartialEq::eq(&a, &b);
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = PartialEq::ne(&a, &b);
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a.eq(&b);
+    //~^ WARN ambiguous wide pointer comparison
+    let _ = a.ne(&b);
+    //~^ WARN ambiguous wide pointer comparison
+
+    {
+        // &*const ?Sized
+        let a = &a;
+        let b = &b;
+
+        let _ = a == b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a != b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a < b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a <= b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a > b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a >= b;
+        //~^ WARN ambiguous wide pointer comparison
+
+        let _ = PartialEq::eq(a, b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = PartialEq::ne(a, b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = PartialEq::eq(&a, &b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = PartialEq::ne(&a, &b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a.eq(b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a.ne(b);
+        //~^ WARN ambiguous wide pointer comparison
+    }
+
+    let s = "" as *const str;
+    let _ = s == s;
+    //~^ WARN ambiguous wide pointer comparison
+
+    let s = &[8, 7][..] as *const [i32];
+    let _ = s == s;
+    //~^ WARN ambiguous wide pointer comparison
+
+    fn cmp<T: ?Sized>(a: *mut T, b: *mut T) -> bool {
+        let _ = a == b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a != b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a < b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a <= b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a > b;
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a >= b;
+        //~^ WARN ambiguous wide pointer comparison
+
+        let _ = PartialEq::eq(&a, &b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = PartialEq::ne(&a, &b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a.eq(&b);
+        //~^ WARN ambiguous wide pointer comparison
+        let _ = a.ne(&b);
+        //~^ WARN ambiguous wide pointer comparison
+
+        let a = &a;
+        let b = &b;
+        &*a == &*b
+        //~^ WARN ambiguous wide pointer comparison
+    }
+
+    {
+        macro_rules! cmp {
+            ($a:ident, $b:ident) => { $a == $b }
+            //~^ WARN ambiguous wide pointer comparison
+        }
+
+        cmp!(a, b);
+    }
+
+    {
+        // this produce weird diagnostics
+        macro_rules! cmp {
+            ($a:expr, $b:expr) => { $a == $b }
+            //~^ WARN ambiguous wide pointer comparison
+        }
+
+        cmp!(&a, &b);
+    }
+
+    let _ = std::ptr::eq(a, b);
+    let _ = std::ptr::addr_eq(a, b);
+    let _ = a as *const () == b as *const ();
+
+    let a: Rc<dyn std::fmt::Debug> = Rc::new(1);
+    Rc::ptr_eq(&a, &a);
+
+    let a: Arc<dyn std::fmt::Debug> = Arc::new(1);
+    Arc::ptr_eq(&a, &a);
+}
diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr
new file mode 100644
index 00000000000..926b8775902
--- /dev/null
+++ b/tests/ui/lint/wide_pointer_comparisons.stderr
@@ -0,0 +1,452 @@
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:19:13
+   |
+LL |     let _ = a == b;
+   |             ^^^^^^
+   |
+   = note: `#[warn(ambiguous_wide_pointer_comparisons)]` on by default
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = std::ptr::addr_eq(a, b);
+   |             ++++++++++++++++++ ~  +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:21:13
+   |
+LL |     let _ = a != b;
+   |             ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = !std::ptr::addr_eq(a, b);
+   |             +++++++++++++++++++ ~  +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:23:13
+   |
+LL |     let _ = a < b;
+   |             ^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = a as *const () < b as *const ();
+   |               ++++++++++++     ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:25:13
+   |
+LL |     let _ = a <= b;
+   |             ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = a as *const () <= b as *const ();
+   |               ++++++++++++      ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:27:13
+   |
+LL |     let _ = a > b;
+   |             ^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = a as *const () > b as *const ();
+   |               ++++++++++++     ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:29:13
+   |
+LL |     let _ = a >= b;
+   |             ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = a as *const () >= b as *const ();
+   |               ++++++++++++      ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:32:13
+   |
+LL |     let _ = PartialEq::eq(&a, &b);
+   |             ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = std::ptr::addr_eq(a, b);
+   |             ~~~~~~~~~~~~~~~~~~ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:34:13
+   |
+LL |     let _ = PartialEq::ne(&a, &b);
+   |             ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = !std::ptr::addr_eq(a, b);
+   |             ~~~~~~~~~~~~~~~~~~~ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:36:13
+   |
+LL |     let _ = a.eq(&b);
+   |             ^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = std::ptr::addr_eq(a, b);
+   |             ++++++++++++++++++ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:38:13
+   |
+LL |     let _ = a.ne(&b);
+   |             ^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = !std::ptr::addr_eq(a, b);
+   |             +++++++++++++++++++ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:46:17
+   |
+LL |         let _ = a == b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(*a, *b);
+   |                 +++++++++++++++++++ ~~~ +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:48:17
+   |
+LL |         let _ = a != b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(*a, *b);
+   |                 ++++++++++++++++++++ ~~~ +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:50:17
+   |
+LL |         let _ = a < b;
+   |                 ^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = *a as *const () < *b as *const ();
+   |                 +  ++++++++++++   +  ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:52:17
+   |
+LL |         let _ = a <= b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = *a as *const () <= *b as *const ();
+   |                 +  ++++++++++++    +  ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:54:17
+   |
+LL |         let _ = a > b;
+   |                 ^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = *a as *const () > *b as *const ();
+   |                 +  ++++++++++++   +  ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:56:17
+   |
+LL |         let _ = a >= b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = *a as *const () >= *b as *const ();
+   |                 +  ++++++++++++    +  ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:59:17
+   |
+LL |         let _ = PartialEq::eq(a, b);
+   |                 ^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(*a, *b);
+   |                 ~~~~~~~~~~~~~~~~~~~ ~~~ ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:61:17
+   |
+LL |         let _ = PartialEq::ne(a, b);
+   |                 ^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(*a, *b);
+   |                 ~~~~~~~~~~~~~~~~~~~~ ~~~ ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:63:17
+   |
+LL |         let _ = PartialEq::eq(&a, &b);
+   |                 ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(*a, *b);
+   |                 ~~~~~~~~~~~~~~~~~~~ ~~~ ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:65:17
+   |
+LL |         let _ = PartialEq::ne(&a, &b);
+   |                 ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(*a, *b);
+   |                 ~~~~~~~~~~~~~~~~~~~~ ~~~ ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:67:17
+   |
+LL |         let _ = a.eq(b);
+   |                 ^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(*a, *b);
+   |                 +++++++++++++++++++ ~~~ ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:69:17
+   |
+LL |         let _ = a.ne(b);
+   |                 ^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(*a, *b);
+   |                 ++++++++++++++++++++ ~~~ ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:74:13
+   |
+LL |     let _ = s == s;
+   |             ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = std::ptr::addr_eq(s, s);
+   |             ++++++++++++++++++ ~  +
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |     let _ = std::ptr::eq(s, s);
+   |             +++++++++++++ ~  +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:78:13
+   |
+LL |     let _ = s == s;
+   |             ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |     let _ = std::ptr::addr_eq(s, s);
+   |             ++++++++++++++++++ ~  +
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |     let _ = std::ptr::eq(s, s);
+   |             +++++++++++++ ~  +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:82:17
+   |
+LL |         let _ = a == b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(a, b);
+   |                 ++++++++++++++++++ ~  +
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         let _ = std::ptr::eq(a, b);
+   |                 +++++++++++++ ~  +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:84:17
+   |
+LL |         let _ = a != b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(a, b);
+   |                 +++++++++++++++++++ ~  +
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         let _ = !std::ptr::eq(a, b);
+   |                 ++++++++++++++ ~  +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:86:17
+   |
+LL |         let _ = a < b;
+   |                 ^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = a as *const () < b as *const ();
+   |                   ++++++++++++     ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:88:17
+   |
+LL |         let _ = a <= b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = a as *const () <= b as *const ();
+   |                   ++++++++++++      ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:90:17
+   |
+LL |         let _ = a > b;
+   |                 ^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = a as *const () > b as *const ();
+   |                   ++++++++++++     ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:92:17
+   |
+LL |         let _ = a >= b;
+   |                 ^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = a as *const () >= b as *const ();
+   |                   ++++++++++++      ++++++++++++
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:95:17
+   |
+LL |         let _ = PartialEq::eq(&a, &b);
+   |                 ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(a, b);
+   |                 ~~~~~~~~~~~~~~~~~~ ~  ~
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         let _ = std::ptr::eq(a, b);
+   |                 ~~~~~~~~~~~~~ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:97:17
+   |
+LL |         let _ = PartialEq::ne(&a, &b);
+   |                 ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(a, b);
+   |                 ~~~~~~~~~~~~~~~~~~~ ~  ~
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         let _ = !std::ptr::eq(a, b);
+   |                 ~~~~~~~~~~~~~~ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:99:17
+   |
+LL |         let _ = a.eq(&b);
+   |                 ^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = std::ptr::addr_eq(a, b);
+   |                 ++++++++++++++++++ ~  ~
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         let _ = std::ptr::eq(a, b);
+   |                 +++++++++++++ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:101:17
+   |
+LL |         let _ = a.ne(&b);
+   |                 ^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         let _ = !std::ptr::addr_eq(a, b);
+   |                 +++++++++++++++++++ ~  ~
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         let _ = !std::ptr::eq(a, b);
+   |                 ++++++++++++++ ~  ~
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:106:9
+   |
+LL |         &*a == &*b
+   |         ^^^^^^^^^^
+   |
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |         std::ptr::addr_eq(*a, *b)
+   |         ~~~~~~~~~~~~~~~~~~  ~   +
+help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   |
+LL |         std::ptr::eq(*a, *b)
+   |         ~~~~~~~~~~~~~  ~   +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:112:39
+   |
+LL |             ($a:ident, $b:ident) => { $a == $b }
+   |                                       ^^^^^^^^
+...
+LL |         cmp!(a, b);
+   |         ---------- in this macro invocation
+   |
+   = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   |
+LL |             ($a:ident, $b:ident) => { std::ptr::addr_eq($a, $b) }
+   |                                       ++++++++++++++++++  ~   +
+
+warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
+  --> $DIR/wide_pointer_comparisons.rs:122:37
+   |
+LL |             ($a:expr, $b:expr) => { $a == $b }
+   |                                     ^^
+...
+LL |         cmp!(&a, &b);
+   |         ------------ in this macro invocation
+   |
+   = help: use explicit `std::ptr::eq` method to compare metadata and addresses
+   = help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+   = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+warning: 37 warnings emitted
+
diff --git a/tests/ui/mir/mir_raw_fat_ptr.rs b/tests/ui/mir/mir_raw_fat_ptr.rs
index 6aceefbe715..f4a9afd2308 100644
--- a/tests/ui/mir/mir_raw_fat_ptr.rs
+++ b/tests/ui/mir/mir_raw_fat_ptr.rs
@@ -1,7 +1,9 @@
 // run-pass
 // check raw fat pointer ops in mir
 // FIXME: please improve this when we get monomorphization support
+
 #![feature(raw_ref_op)]
+#![allow(ambiguous_wide_pointer_comparisons)]
 
 use std::mem;