mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeIncorrect
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 <https://github.com/rust-lang/rust/issues/53934>.
This commit is contained in:
parent
ad14a226c0
commit
4d386d9f04
@ -1543,7 +1543,8 @@ pub enum AmbiguousWidePointerComparisons<'a> {
|
||||
#[multipart_suggestion(
|
||||
lint_addr_metadata_suggestion,
|
||||
style = "verbose",
|
||||
applicability = "machine-applicable"
|
||||
// FIXME(#53934): make machine-applicable again
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
pub struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
|
||||
pub ne: &'a str,
|
||||
@ -1562,7 +1563,8 @@ pub enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
|
||||
#[multipart_suggestion(
|
||||
lint_addr_suggestion,
|
||||
style = "verbose",
|
||||
applicability = "machine-applicable"
|
||||
// FIXME(#53934): make machine-applicable again
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
AddrEq {
|
||||
ne: &'a str,
|
||||
@ -1578,7 +1580,8 @@ pub enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
|
||||
#[multipart_suggestion(
|
||||
lint_addr_suggestion,
|
||||
style = "verbose",
|
||||
applicability = "machine-applicable"
|
||||
// FIXME(#53934): make machine-applicable again
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
Cast {
|
||||
deref_left: &'a str,
|
||||
|
@ -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() {}
|
@ -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() {}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user