Skip to content

Commit

Permalink
Auto merge of rust-lang#117758 - Urgau:lint_pointer_trait_comparisons…
Browse files Browse the repository at this point in the history
…, r=davidtwco

Add lint against ambiguous wide pointer comparisons

This PR is the resolution of rust-lang#106447 decided in rust-lang#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#117717
  • Loading branch information
bors committed Dec 11, 2023
2 parents e637663 + 9d9459a commit b5c0dd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
thread_local
)]
#![no_core]
#![allow(dead_code, internal_features)]
#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]

#[lang = "sized"]
pub trait Sized {}
Expand Down

0 comments on commit b5c0dd6

Please sign in to comment.