forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeInco…
…rrect It is possible to have more than one valid suggestion, which when applied together via rustfix causes the code to no longer compile. This is a temporary workaround; the real long term solution to these issues is to solve <rust-lang#53934>.
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//@ run-rustfix | ||
//@ rustfix-only-machine-applicable | ||
//@ check-pass | ||
|
||
// See <https://github.com/rust-lang/rust/issues/121330>. | ||
|
||
fn cmp<T: ?Sized>(a: *mut T, b: *mut T) -> bool { | ||
let _ = a == b; | ||
//~^ WARN ambiguous wide pointer comparison | ||
panic!(); | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//@ run-rustfix | ||
//@ rustfix-only-machine-applicable | ||
//@ check-pass | ||
|
||
// See <https://github.com/rust-lang/rust/issues/121330>. | ||
|
||
fn cmp<T: ?Sized>(a: *mut T, b: *mut T) -> bool { | ||
let _ = a == b; | ||
//~^ WARN ambiguous wide pointer comparison | ||
panic!(); | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected | ||
--> $DIR/ambiguous_wide_pointer_comparisons_suggestions.rs:8: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); | ||
| ++++++++++++++++++ ~ + | ||
help: use explicit `std::ptr::eq` method to compare metadata and addresses | ||
| | ||
LL | let _ = std::ptr::eq(a, b); | ||
| +++++++++++++ ~ + | ||
|
||
warning: 1 warning emitted | ||
|