about summary refs log tree commit diff
path: root/library/alloc/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 /library/alloc/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 'library/alloc/tests')
-rw-r--r--library/alloc/tests/vec.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index 9e5910bf126..364dc920187 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -1980,7 +1980,7 @@ fn vec_macro_repeating_null_raw_fat_pointer() {
 
     let vec = vec![null_raw_dyn; 1];
     dbg!(ptr_metadata(vec[0]));
-    assert!(vec[0] == null_raw_dyn);
+    assert!(std::ptr::eq(vec[0], null_raw_dyn));
 
     // Polyfill for https://github.com/rust-lang/rfcs/pull/2580