Skip to content

Commit add2c6c

Browse files
committed
Auto merge of #4744 - phansch:split_up_some_derive_test, r=flip1995
UI test cleanup: Extract derive_hash_xor_eq tests changelog: none cc #2038
2 parents c8e3cfb + 05aac0d commit add2c6c

File tree

4 files changed

+95
-92
lines changed

4 files changed

+95
-92
lines changed

tests/ui/derive.rs

-36
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,6 @@
22
#![allow(dead_code)]
33
#![warn(clippy::expl_impl_clone_on_copy)]
44

5-
use std::hash::{Hash, Hasher};
6-
7-
#[derive(PartialEq, Hash)]
8-
struct Foo;
9-
10-
impl PartialEq<u64> for Foo {
11-
fn eq(&self, _: &u64) -> bool {
12-
true
13-
}
14-
}
15-
16-
#[derive(Hash)]
17-
struct Bar;
18-
19-
impl PartialEq for Bar {
20-
fn eq(&self, _: &Bar) -> bool {
21-
true
22-
}
23-
}
24-
25-
#[derive(Hash)]
26-
struct Baz;
27-
28-
impl PartialEq<Baz> for Baz {
29-
fn eq(&self, _: &Baz) -> bool {
30-
true
31-
}
32-
}
33-
34-
#[derive(PartialEq)]
35-
struct Bah;
36-
37-
impl Hash for Bah {
38-
fn hash<H: Hasher>(&self, _: &mut H) {}
39-
}
40-
415
#[derive(Copy)]
426
struct Qux;
437

tests/ui/derive.stderr

+9-56
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,5 @@
1-
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
2-
--> $DIR/derive.rs:16:10
3-
|
4-
LL | #[derive(Hash)]
5-
| ^^^^
6-
|
7-
= note: `#[deny(clippy::derive_hash_xor_eq)]` on by default
8-
note: `PartialEq` implemented here
9-
--> $DIR/derive.rs:19:1
10-
|
11-
LL | / impl PartialEq for Bar {
12-
LL | | fn eq(&self, _: &Bar) -> bool {
13-
LL | | true
14-
LL | | }
15-
LL | | }
16-
| |_^
17-
18-
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
19-
--> $DIR/derive.rs:25:10
20-
|
21-
LL | #[derive(Hash)]
22-
| ^^^^
23-
|
24-
note: `PartialEq` implemented here
25-
--> $DIR/derive.rs:28:1
26-
|
27-
LL | / impl PartialEq<Baz> for Baz {
28-
LL | | fn eq(&self, _: &Baz) -> bool {
29-
LL | | true
30-
LL | | }
31-
LL | | }
32-
| |_^
33-
34-
error: you are implementing `Hash` explicitly but have derived `PartialEq`
35-
--> $DIR/derive.rs:37:1
36-
|
37-
LL | / impl Hash for Bah {
38-
LL | | fn hash<H: Hasher>(&self, _: &mut H) {}
39-
LL | | }
40-
| |_^
41-
|
42-
note: `PartialEq` implemented here
43-
--> $DIR/derive.rs:34:10
44-
|
45-
LL | #[derive(PartialEq)]
46-
| ^^^^^^^^^
47-
481
error: you are implementing `Clone` explicitly on a `Copy` type
49-
--> $DIR/derive.rs:44:1
2+
--> $DIR/derive.rs:8:1
503
|
514
LL | / impl Clone for Qux {
525
LL | | fn clone(&self) -> Self {
@@ -57,7 +10,7 @@ LL | | }
5710
|
5811
= note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings`
5912
note: consider deriving `Clone` or removing `Copy`
60-
--> $DIR/derive.rs:44:1
13+
--> $DIR/derive.rs:8:1
6114
|
6215
LL | / impl Clone for Qux {
6316
LL | | fn clone(&self) -> Self {
@@ -67,7 +20,7 @@ LL | | }
6720
| |_^
6821

6922
error: you are implementing `Clone` explicitly on a `Copy` type
70-
--> $DIR/derive.rs:68:1
23+
--> $DIR/derive.rs:32:1
7124
|
7225
LL | / impl<'a> Clone for Lt<'a> {
7326
LL | | fn clone(&self) -> Self {
@@ -77,7 +30,7 @@ LL | | }
7730
| |_^
7831
|
7932
note: consider deriving `Clone` or removing `Copy`
80-
--> $DIR/derive.rs:68:1
33+
--> $DIR/derive.rs:32:1
8134
|
8235
LL | / impl<'a> Clone for Lt<'a> {
8336
LL | | fn clone(&self) -> Self {
@@ -87,7 +40,7 @@ LL | | }
8740
| |_^
8841

8942
error: you are implementing `Clone` explicitly on a `Copy` type
90-
--> $DIR/derive.rs:80:1
43+
--> $DIR/derive.rs:44:1
9144
|
9245
LL | / impl Clone for BigArray {
9346
LL | | fn clone(&self) -> Self {
@@ -97,7 +50,7 @@ LL | | }
9750
| |_^
9851
|
9952
note: consider deriving `Clone` or removing `Copy`
100-
--> $DIR/derive.rs:80:1
53+
--> $DIR/derive.rs:44:1
10154
|
10255
LL | / impl Clone for BigArray {
10356
LL | | fn clone(&self) -> Self {
@@ -107,7 +60,7 @@ LL | | }
10760
| |_^
10861

10962
error: you are implementing `Clone` explicitly on a `Copy` type
110-
--> $DIR/derive.rs:92:1
63+
--> $DIR/derive.rs:56:1
11164
|
11265
LL | / impl Clone for FnPtr {
11366
LL | | fn clone(&self) -> Self {
@@ -117,7 +70,7 @@ LL | | }
11770
| |_^
11871
|
11972
note: consider deriving `Clone` or removing `Copy`
120-
--> $DIR/derive.rs:92:1
73+
--> $DIR/derive.rs:56:1
12174
|
12275
LL | / impl Clone for FnPtr {
12376
LL | | fn clone(&self) -> Self {
@@ -126,5 +79,5 @@ LL | | }
12679
LL | | }
12780
| |_^
12881

129-
error: aborting due to 7 previous errors
82+
error: aborting due to 4 previous errors
13083

tests/ui/derive_hash_xor_eq.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use std::hash::{Hash, Hasher};
2+
3+
#[derive(PartialEq, Hash)]
4+
struct Foo;
5+
6+
impl PartialEq<u64> for Foo {
7+
fn eq(&self, _: &u64) -> bool {
8+
true
9+
}
10+
}
11+
12+
#[derive(Hash)]
13+
struct Bar;
14+
15+
impl PartialEq for Bar {
16+
fn eq(&self, _: &Bar) -> bool {
17+
true
18+
}
19+
}
20+
21+
#[derive(Hash)]
22+
struct Baz;
23+
24+
impl PartialEq<Baz> for Baz {
25+
fn eq(&self, _: &Baz) -> bool {
26+
true
27+
}
28+
}
29+
30+
#[derive(PartialEq)]
31+
struct Bah;
32+
33+
impl Hash for Bah {
34+
fn hash<H: Hasher>(&self, _: &mut H) {}
35+
}
36+
37+
fn main() {}

tests/ui/derive_hash_xor_eq.stderr

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
2+
--> $DIR/derive_hash_xor_eq.rs:12:10
3+
|
4+
LL | #[derive(Hash)]
5+
| ^^^^
6+
|
7+
= note: `#[deny(clippy::derive_hash_xor_eq)]` on by default
8+
note: `PartialEq` implemented here
9+
--> $DIR/derive_hash_xor_eq.rs:15:1
10+
|
11+
LL | / impl PartialEq for Bar {
12+
LL | | fn eq(&self, _: &Bar) -> bool {
13+
LL | | true
14+
LL | | }
15+
LL | | }
16+
| |_^
17+
18+
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
19+
--> $DIR/derive_hash_xor_eq.rs:21:10
20+
|
21+
LL | #[derive(Hash)]
22+
| ^^^^
23+
|
24+
note: `PartialEq` implemented here
25+
--> $DIR/derive_hash_xor_eq.rs:24:1
26+
|
27+
LL | / impl PartialEq<Baz> for Baz {
28+
LL | | fn eq(&self, _: &Baz) -> bool {
29+
LL | | true
30+
LL | | }
31+
LL | | }
32+
| |_^
33+
34+
error: you are implementing `Hash` explicitly but have derived `PartialEq`
35+
--> $DIR/derive_hash_xor_eq.rs:33:1
36+
|
37+
LL | / impl Hash for Bah {
38+
LL | | fn hash<H: Hasher>(&self, _: &mut H) {}
39+
LL | | }
40+
| |_^
41+
|
42+
note: `PartialEq` implemented here
43+
--> $DIR/derive_hash_xor_eq.rs:30:10
44+
|
45+
LL | #[derive(PartialEq)]
46+
| ^^^^^^^^^
47+
48+
error: aborting due to 3 previous errors
49+

0 commit comments

Comments
 (0)