Open
Description
Using the following flags
--force-warn clippy::borrow-as-ptr
this code:
//@ check-pass
use std::rc::Rc;
use std::sync::Arc;
use std::cmp::PartialEq;
use std::ptr::NonNull;
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
let _ = a.cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.partial_cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.le(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.lt(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.ge(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.gt(&b);
//~^ WARN ambiguous wide pointer comparison
{
let a = NonNull::<dyn T>::new(a as *mut _).unwrap();
let b = NonNull::<dyn T>::new(b as *mut _).unwrap();
let _ = a == b;
//~^ WARN ambiguous wide pointer comparison
let _ = a >= b;
//~^ WARN ambiguous wide pointer comparison
let _ = &a == &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 _ = a.cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.partial_cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.le(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.lt(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.ge(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.gt(&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:tt, $b:tt) => { $a == $b }
}
// FIXME: This lint uses some custom span combination logic.
// Rewrite it to adapt to the new metavariable span rules.
cmp!(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);
}
caused the following diagnostics:
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Checking _wide_pointer_comparisons v0.1.0 (/tmp/icemaker_global_tempdir.hTWDZB3NcvpG/icemaker_clippyfix_tempdir.yz4vtMmuNgYK/_wide_pointer_comparisons)
warning: borrow as raw pointer
--> src/main.rs:17:13
|
17 | let a = &ab.0 as *const dyn T;
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `&raw const ab.0`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
= note: requested on the command line with `--force-warn clippy::borrow-as-ptr`
warning: borrow as raw pointer
--> src/main.rs:18:13
|
18 | let b = &ab.1 as *const dyn T;
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `&raw const ab.1`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
warning: `_wide_pointer_comparisons` (bin "_wide_pointer_comparisons") generated 2 warnings (run `cargo clippy --fix --bin "_wide_pointer_comparisons"` to apply 2 suggestions)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.93s
However after applying these diagnostics, the resulting code:
//@ check-pass
use std::rc::Rc;
use std::sync::Arc;
use std::cmp::PartialEq;
use std::ptr::NonNull;
struct A;
struct B;
trait T {}
impl T for A {}
impl T for B {}
fn main() {
let ab = (A, B);
let a = &raw const ab.0;
let b = &raw const ab.1;
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.cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.partial_cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.le(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.lt(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.ge(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.gt(&b);
//~^ WARN ambiguous wide pointer comparison
{
let a = NonNull::<dyn T>::new(a as *mut _).unwrap();
let b = NonNull::<dyn T>::new(b as *mut _).unwrap();
let _ = a == b;
//~^ WARN ambiguous wide pointer comparison
let _ = a >= b;
//~^ WARN ambiguous wide pointer comparison
let _ = &a == &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 _ = a.cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.partial_cmp(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.le(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.lt(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.ge(&b);
//~^ WARN ambiguous wide pointer comparison
let _ = a.gt(&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:tt, $b:tt) => { $a == $b }
}
// FIXME: This lint uses some custom span combination logic.
// Rewrite it to adapt to the new metavariable span rules.
cmp!(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);
}
no longer compiled:
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Checking _wide_pointer_comparisons v0.1.0 (/tmp/icemaker_global_tempdir.hTWDZB3NcvpG/icemaker_clippyfix_tempdir.yz4vtMmuNgYK/_wide_pointer_comparisons)
error[E0308]: mismatched types
--> src/main.rs:20:18
|
20 | let _ = a == b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:22:18
|
22 | let _ = a != b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:24:17
|
24 | let _ = a < b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:26:18
|
26 | let _ = a <= b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:28:17
|
28 | let _ = a > b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:30:18
|
30 | let _ = a >= b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:33:31
|
33 | let _ = PartialEq::eq(&a, &b);
| ------------- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this function are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:257:8
|
257 | fn eq(&self, other: &Rhs) -> bool;
| ^^
error[E0308]: mismatched types
--> src/main.rs:35:31
|
35 | let _ = PartialEq::ne(&a, &b);
| ------------- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this function are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:265:8
|
265 | fn ne(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:37:18
|
37 | let _ = a.eq(&b);
| -- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:257:8
|
257 | fn eq(&self, other: &Rhs) -> bool;
| ^^
error[E0308]: mismatched types
--> src/main.rs:39:18
|
39 | let _ = a.ne(&b);
| -- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:265:8
|
265 | fn ne(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:41:19
|
41 | let _ = a.cmp(&b);
| --- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:978:8
|
978 | fn cmp(&self, other: &Self) -> Ordering;
| ^^^
error[E0308]: mismatched types
--> src/main.rs:43:27
|
43 | let _ = a.partial_cmp(&b);
| ----------- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1371:8
|
1371 | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
| ^^^^^^^^^^^
error[E0308]: mismatched types
--> src/main.rs:45:18
|
45 | let _ = a.le(&b);
| -- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1404:8
|
1404 | fn le(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:47:18
|
47 | let _ = a.lt(&b);
| -- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1386:8
|
1386 | fn lt(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:49:18
|
49 | let _ = a.ge(&b);
| -- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1440:8
|
1440 | fn ge(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:51:18
|
51 | let _ = a.gt(&b);
| -- ^^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1422:8
|
1422 | fn gt(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:70:22
|
70 | let _ = a == b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0277]: can't compare `*const A` with `*const B`
--> src/main.rs:70:19
|
70 | let _ = a == b;
| ^^ no implementation for `*const A == *const B`
|
= help: the trait `std::cmp::PartialEq<*const B>` is not implemented for `*const A`
= note: required for `&*const A` to implement `std::cmp::PartialEq<&*const B>`
error[E0308]: mismatched types
--> src/main.rs:72:22
|
72 | let _ = a != b;
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0277]: can't compare `*const A` with `*const B`
--> src/main.rs:72:19
|
72 | let _ = a != b;
| ^^ no implementation for `*const A == *const B`
|
= help: the trait `std::cmp::PartialEq<*const B>` is not implemented for `*const A`
= note: required for `&*const A` to implement `std::cmp::PartialEq<&*const B>`
error[E0308]: mismatched types
--> src/main.rs:74:21
|
74 | let _ = a < b;
| ^ expected `&*const A`, found `&*const B`
|
= note: expected reference `&*const A`
found reference `&*const B`
error[E0308]: mismatched types
--> src/main.rs:76:22
|
76 | let _ = a <= b;
| ^ expected `&*const A`, found `&*const B`
|
= note: expected reference `&*const A`
found reference `&*const B`
error[E0308]: mismatched types
--> src/main.rs:78:21
|
78 | let _ = a > b;
| ^ expected `&*const A`, found `&*const B`
|
= note: expected reference `&*const A`
found reference `&*const B`
error[E0308]: mismatched types
--> src/main.rs:80:22
|
80 | let _ = a >= b;
| ^ expected `&*const A`, found `&*const B`
|
= note: expected reference `&*const A`
found reference `&*const B`
error[E0308]: mismatched types
--> src/main.rs:83:34
|
83 | let _ = PartialEq::eq(a, b);
| ------------- ^ expected `&*const A`, found `&*const B`
| |
| arguments to this function are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:257:8
|
257 | fn eq(&self, other: &Rhs) -> bool;
| ^^
error[E0308]: mismatched types
--> src/main.rs:85:34
|
85 | let _ = PartialEq::ne(a, b);
| ------------- ^ expected `&*const A`, found `&*const B`
| |
| arguments to this function are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:265:8
|
265 | fn ne(&self, other: &Rhs) -> bool {
| ^^
error[E0277]: can't compare `*const A` with `*const B`
--> src/main.rs:87:36
|
87 | let _ = PartialEq::eq(&a, &b);
| ------------- ^ no implementation for `*const A == *const B`
| |
| required by a bound introduced by this call
|
= help: the trait `std::cmp::PartialEq<*const B>` is not implemented for `*const A`
= note: required for `&*const A` to implement `std::cmp::PartialEq<&*const B>`
error[E0277]: can't compare `*const A` with `*const B`
--> src/main.rs:89:36
|
89 | let _ = PartialEq::ne(&a, &b);
| ------------- ^ no implementation for `*const A == *const B`
| |
| required by a bound introduced by this call
|
= help: the trait `std::cmp::PartialEq<*const B>` is not implemented for `*const A`
= note: required for `&*const A` to implement `std::cmp::PartialEq<&*const B>`
error[E0308]: mismatched types
--> src/main.rs:91:22
|
91 | let _ = a.eq(b);
| -- ^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:257:8
|
257 | fn eq(&self, other: &Rhs) -> bool;
| ^^
error[E0308]: mismatched types
--> src/main.rs:93:22
|
93 | let _ = a.ne(b);
| -- ^ expected `&*const A`, found `&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:265:8
|
265 | fn ne(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:95:23
|
95 | let _ = a.cmp(&b);
| --- ^^ expected `&*const A`, found `&&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:978:8
|
978 | fn cmp(&self, other: &Self) -> Ordering;
| ^^^
error[E0308]: mismatched types
--> src/main.rs:97:31
|
97 | let _ = a.partial_cmp(&b);
| ----------- ^^ expected `&*const A`, found `&&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1371:8
|
1371 | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
| ^^^^^^^^^^^
error[E0308]: mismatched types
--> src/main.rs:99:22
|
99 | let _ = a.le(&b);
| -- ^^ expected `&*const A`, found `&&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1404:8
|
1404 | fn le(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:101:22
|
101 | let _ = a.lt(&b);
| -- ^^ expected `&*const A`, found `&&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1386:8
|
1386 | fn lt(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:103:22
|
103 | let _ = a.ge(&b);
| -- ^^ expected `&*const A`, found `&&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1440:8
|
1440 | fn ge(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:105:22
|
105 | let _ = a.gt(&b);
| -- ^^ expected `&*const A`, found `&&*const B`
| |
| arguments to this method are incorrect
|
= note: expected reference `&*const A`
found reference `&&*const B`
note: method defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/cmp.rs:1422:8
|
1422 | fn gt(&self, other: &Rhs) -> bool {
| ^^
error[E0308]: mismatched types
--> src/main.rs:153:17
|
153 | cmp!(a, b);
| ^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0308]: mismatched types
--> src/main.rs:159:45
|
159 | ($a:ident, $b:ident) => { $a == $b }
| ^^ expected `*const A`, found `*const B`
...
163 | cmp!(a, b);
| ---------- in this macro invocation
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
= note: this error originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> src/main.rs:173:18
|
173 | cmp!(&a, &b);
| ^^ expected `*const A`, found `*const B`
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
error[E0277]: can't compare `*const A` with `*const B`
--> src/main.rs:169:40
|
169 | ($a:expr, $b:expr) => { $a == $b }
| ^^ no implementation for `*const A == *const B`
...
173 | cmp!(&a, &b);
| ------------ in this macro invocation
|
= help: the trait `std::cmp::PartialEq<*const B>` is not implemented for `*const A`
= note: required for `&*const A` to implement `std::cmp::PartialEq<&*const B>`
= note: this error originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> src/main.rs:176:29
|
176 | let _ = std::ptr::eq(a, b);
| ------------ ^ expected `*const A`, found `*const B`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const A`
found raw pointer `*const B`
note: function defined here
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:2422:8
|
2422 | pub fn eq<T: PointeeSized>(a: *const T, b: *const T) -> bool {
| ^^
error[E0607]: cannot cast thin pointer `*const A` to wide pointer `*mut dyn T`
--> src/main.rs:55:39
|
55 | let a = NonNull::<dyn T>::new(a as *mut _).unwrap();
| ^^^^^^^^^^^
error[E0607]: cannot cast thin pointer `*const B` to wide pointer `*mut dyn T`
--> src/main.rs:56:39
|
56 | let b = NonNull::<dyn T>::new(b as *mut _).unwrap();
| ^^^^^^^^^^^
Some errors have detailed explanations: E0277, E0308, E0607.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `_wide_pointer_comparisons` (bin "_wide_pointer_comparisons" test) due to 43 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `_wide_pointer_comparisons` (bin "_wide_pointer_comparisons") due to 43 previous errors
Version:
rustc 1.90.0-nightly (8cf5fad73 2025-06-25)
binary: rustc
commit-hash: 8cf5fad73d4e8f41863ecc3bcfa114eabc951faa
commit-date: 2025-06-25
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7