Skip to content

Commit 2a8296d

Browse files
committed
Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
Add lint against ambiguous wide pointer comparisons This PR is the resolution of rust-lang/rust#106447 decided in rust-lang/rust#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 rust-lang/rust#117717
2 parents b57f3b0 + 157fe71 commit 2a8296d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

tests/pass/pointers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
//@compile-flags: -Zmiri-permissive-provenance
44
#![feature(ptr_metadata, const_raw_ptr_comparison)]
5+
#![allow(ambiguous_wide_pointer_comparisons)]
56

67
use std::mem::{self, transmute};
78
use std::ptr;

tests/pass/rc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//@compile-flags: -Zmiri-strict-provenance
44
#![feature(new_uninit)]
55
#![feature(get_mut_unchecked)]
6+
#![allow(ambiguous_wide_pointer_comparisons)]
67

78
use std::cell::{Cell, RefCell};
89
use std::fmt::Debug;

0 commit comments

Comments
 (0)