about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/cmp_owned
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2022-05-21 13:24:00 +0200
committerxFrednet <xFrednet@gmail.com>2022-05-21 13:24:00 +0200
commit13cc27b4450d99a2e85a656de3936af65332a716 (patch)
treefe1071b1e3b0ad0b99725db209099c1186ff7914 /src/tools/clippy/tests/ui/cmp_owned
parent4f372b14dea58cbff1dd76bb651f9c035d3f6e7b (diff)
parentb312ad7d0cf0f30be2bd4658b71a3520a2e76709 (diff)
downloadrust-13cc27b4450d99a2e85a656de3936af65332a716.tar.gz
rust-13cc27b4450d99a2e85a656de3936af65332a716.zip
Merge 'rust-clippy/master' into clippyup
Diffstat (limited to 'src/tools/clippy/tests/ui/cmp_owned')
-rw-r--r--src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.fixed2
-rw-r--r--src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.rs2
-rw-r--r--src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed4
-rw-r--r--src/tools/clippy/tests/ui/cmp_owned/with_suggestion.rs4
-rw-r--r--src/tools/clippy/tests/ui/cmp_owned/without_suggestion.rs26
-rw-r--r--src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr2
6 files changed, 31 insertions, 9 deletions
diff --git a/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.fixed b/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.fixed
index 3305ac9bf8b..abd059c2308 100644
--- a/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.fixed
+++ b/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.fixed
@@ -1,5 +1,5 @@
 // run-rustfix
-#![allow(unused, clippy::redundant_clone)] // See #5700
+#![allow(unused, clippy::redundant_clone, clippy::derive_partial_eq_without_eq)] // See #5700
 
 // Define the types in each module to avoid trait impls leaking between modules.
 macro_rules! impl_types {
diff --git a/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.rs b/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.rs
index 88bc2f51dd6..020ef5f840b 100644
--- a/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.rs
+++ b/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.rs
@@ -1,5 +1,5 @@
 // run-rustfix
-#![allow(unused, clippy::redundant_clone)] // See #5700
+#![allow(unused, clippy::redundant_clone, clippy::derive_partial_eq_without_eq)] // See #5700
 
 // Define the types in each module to avoid trait impls leaking between modules.
 macro_rules! impl_types {
diff --git a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed
index 05fb96339e3..b28c4378e33 100644
--- a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed
+++ b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed
@@ -45,7 +45,7 @@ impl ToOwned for Foo {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 struct Bar;
 
 impl PartialEq<Foo> for Bar {
@@ -61,7 +61,7 @@ impl std::borrow::Borrow<Foo> for Bar {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 struct Baz;
 
 impl ToOwned for Baz {
diff --git a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.rs b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.rs
index 0a02825ed82..c1089010fe1 100644
--- a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.rs
+++ b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.rs
@@ -45,7 +45,7 @@ impl ToOwned for Foo {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 struct Bar;
 
 impl PartialEq<Foo> for Bar {
@@ -61,7 +61,7 @@ impl std::borrow::Borrow<Foo> for Bar {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 struct Baz;
 
 impl ToOwned for Baz {
diff --git a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.rs b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.rs
index f44a3901fb4..d8a202cb6a1 100644
--- a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.rs
+++ b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.rs
@@ -9,6 +9,10 @@ fn main() {
     let x = &&Baz;
     let y = &Baz;
     y.to_owned() == **x;
+
+    let x = 0u32;
+    let y = U32Wrapper(x);
+    let _ = U32Wrapper::from(x) == y;
 }
 
 struct Foo;
@@ -26,7 +30,7 @@ impl ToOwned for Foo {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 struct Baz;
 
 impl ToOwned for Baz {
@@ -36,7 +40,7 @@ impl ToOwned for Baz {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 struct Bar;
 
 impl PartialEq<Foo> for Bar {
@@ -51,3 +55,21 @@ impl std::borrow::Borrow<Foo> for Bar {
         &FOO
     }
 }
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+struct U32Wrapper(u32);
+impl From<u32> for U32Wrapper {
+    fn from(x: u32) -> Self {
+        Self(x)
+    }
+}
+impl PartialEq<u32> for U32Wrapper {
+    fn eq(&self, other: &u32) -> bool {
+        self.0 == *other
+    }
+}
+impl PartialEq<U32Wrapper> for u32 {
+    fn eq(&self, other: &U32Wrapper) -> bool {
+        *self == other.0
+    }
+}
diff --git a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr
index 2ea3d8fac0d..d2dd14d8edb 100644
--- a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr
+++ b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr
@@ -13,7 +13,7 @@ LL |     y.to_owned() == **x;
    |     ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
 
 error: this creates an owned instance just for comparison
-  --> $DIR/without_suggestion.rs:18:9
+  --> $DIR/without_suggestion.rs:22:9
    |
 LL |         self.to_owned() == *other
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating