Skip to content

Commit af3a29b

Browse files
committed
collateral damage in derive tests, improves errors by not refering to implementation details
1 parent 8475bc4 commit af3a29b

4 files changed

+37
-34
lines changed

tests/ui/derives/deriving-with-repr-packed-move-errors.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ use std::cmp::Ordering;
1111
#[repr(packed)]
1212
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
1313
struct StructA(String);
14-
//~^ ERROR: cannot move out of `self` which is behind a shared reference
15-
//~| ERROR: cannot move out of `self` which is behind a shared reference
16-
//~| ERROR: cannot move out of `other` which is behind a shared reference
17-
//~| ERROR: cannot move out of `self` which is behind a shared reference
18-
//~| ERROR: cannot move out of `other` which is behind a shared reference
19-
//~| ERROR: cannot move out of `self` which is behind a shared reference
20-
//~| ERROR: cannot move out of `other` which is behind a shared reference
21-
//~| ERROR: cannot move out of `self` which is behind a shared reference
22-
//~| ERROR: cannot move out of `self` which is behind a shared reference
14+
//~^ ERROR: cannot move out of a shared reference [E0507]
15+
//~| ERROR: cannot move out of a shared reference [E0507]
16+
//~| ERROR: cannot move out of a shared reference [E0507]
17+
//~| ERROR: cannot move out of a shared reference [E0507]
18+
//~| ERROR: cannot move out of a shared reference [E0507]
19+
//~| ERROR: cannot move out of a shared reference [E0507]
20+
//~| ERROR: cannot move out of a shared reference [E0507]
21+
//~| ERROR: cannot move out of a shared reference [E0507]
22+
//~| ERROR: cannot move out of a shared reference [E0507]
2323

2424

2525
// Unrelated impl: additinal diagnostic should NOT be emitted

tests/ui/derives/deriving-with-repr-packed-move-errors.stderr

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,125 @@
1-
error[E0507]: cannot move out of `self` which is behind a shared reference
1+
error[E0507]: cannot move out of a shared reference
22
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
33
|
44
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
55
| ----- in this derive macro expansion
66
LL | struct StructA(String);
7-
| ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
7+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
88
|
99
= note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
1010
help: consider cloning the value if the performance cost is acceptable
1111
|
1212
LL | struct StructA(String.clone());
1313
| ++++++++
1414

15-
error[E0507]: cannot move out of `self` which is behind a shared reference
15+
error[E0507]: cannot move out of a shared reference
1616
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
1717
|
1818
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
1919
| --------- in this derive macro expansion
2020
LL | struct StructA(String);
21-
| ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
21+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
2222
|
2323
= note: `#[derive(PartialEq)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
2424
help: consider cloning the value if the performance cost is acceptable
2525
|
2626
LL | struct StructA(String.clone());
2727
| ++++++++
2828

29-
error[E0507]: cannot move out of `other` which is behind a shared reference
29+
error[E0507]: cannot move out of a shared reference
3030
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
3131
|
3232
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
3333
| --------- in this derive macro expansion
3434
LL | struct StructA(String);
35-
| ^^^^^^ move occurs because `other.0` has type `String`, which does not implement the `Copy` trait
35+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
3636
|
3737
= note: `#[derive(PartialEq)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
38+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3839
help: consider cloning the value if the performance cost is acceptable
3940
|
4041
LL | struct StructA(String.clone());
4142
| ++++++++
4243

43-
error[E0507]: cannot move out of `self` which is behind a shared reference
44+
error[E0507]: cannot move out of a shared reference
4445
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
4546
|
4647
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
4748
| ---------- in this derive macro expansion
4849
LL | struct StructA(String);
49-
| ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
50+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
5051
|
5152
= note: `#[derive(PartialOrd)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
5253
help: consider cloning the value if the performance cost is acceptable
5354
|
5455
LL | struct StructA(String.clone());
5556
| ++++++++
5657

57-
error[E0507]: cannot move out of `other` which is behind a shared reference
58+
error[E0507]: cannot move out of a shared reference
5859
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
5960
|
6061
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
6162
| ---------- in this derive macro expansion
6263
LL | struct StructA(String);
63-
| ^^^^^^ move occurs because `other.0` has type `String`, which does not implement the `Copy` trait
64+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
6465
|
6566
= note: `#[derive(PartialOrd)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
67+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
6668
help: consider cloning the value if the performance cost is acceptable
6769
|
6870
LL | struct StructA(String.clone());
6971
| ++++++++
7072

71-
error[E0507]: cannot move out of `self` which is behind a shared reference
73+
error[E0507]: cannot move out of a shared reference
7274
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
7375
|
7476
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
7577
| --- in this derive macro expansion
7678
LL | struct StructA(String);
77-
| ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
79+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
7880
|
7981
= note: `#[derive(Ord)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
8082
help: consider cloning the value if the performance cost is acceptable
8183
|
8284
LL | struct StructA(String.clone());
8385
| ++++++++
8486

85-
error[E0507]: cannot move out of `other` which is behind a shared reference
87+
error[E0507]: cannot move out of a shared reference
8688
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
8789
|
8890
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
8991
| --- in this derive macro expansion
9092
LL | struct StructA(String);
91-
| ^^^^^^ move occurs because `other.0` has type `String`, which does not implement the `Copy` trait
93+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
9294
|
9395
= note: `#[derive(Ord)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
96+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
9497
help: consider cloning the value if the performance cost is acceptable
9598
|
9699
LL | struct StructA(String.clone());
97100
| ++++++++
98101

99-
error[E0507]: cannot move out of `self` which is behind a shared reference
102+
error[E0507]: cannot move out of a shared reference
100103
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
101104
|
102105
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
103106
| ---- in this derive macro expansion
104107
LL | struct StructA(String);
105-
| ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
108+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
106109
|
107110
= note: `#[derive(Hash)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
108111
help: consider cloning the value if the performance cost is acceptable
109112
|
110113
LL | struct StructA(String.clone());
111114
| ++++++++
112115

113-
error[E0507]: cannot move out of `self` which is behind a shared reference
116+
error[E0507]: cannot move out of a shared reference
114117
--> $DIR/deriving-with-repr-packed-move-errors.rs:13:16
115118
|
116119
LL | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
117120
| ----- in this derive macro expansion
118121
LL | struct StructA(String);
119-
| ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
122+
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
120123
|
121124
= note: `#[derive(Clone)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
122125
help: consider cloning the value if the performance cost is acceptable

tests/ui/derives/deriving-with-repr-packed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Y(usize);
2020
#[derive(Debug, Default)]
2121
#[repr(packed)]
2222
struct X(Y);
23-
//~^ ERROR cannot move out of `self` which is behind a shared reference
23+
//~^ ERROR cannot move out of a shared reference [E0507]
2424

2525
#[derive(Debug)]
2626
#[repr(packed)]

tests/ui/derives/deriving-with-repr-packed.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0507]: cannot move out of `self` which is behind a shared reference
1+
error[E0507]: cannot move out of a shared reference
22
--> $DIR/deriving-with-repr-packed.rs:22:10
33
|
44
LL | #[derive(Debug, Default)]
55
| ----- in this derive macro expansion
66
LL | #[repr(packed)]
77
LL | struct X(Y);
8-
| ^ move occurs because `self.0` has type `Y`, which does not implement the `Copy` trait
8+
| ^ move occurs because value has type `Y`, which does not implement the `Copy` trait
99
|
1010
note: if `Y` implemented `Clone`, you could clone the value
1111
--> $DIR/deriving-with-repr-packed.rs:16:1
@@ -23,14 +23,14 @@ error[E0161]: cannot move a value of type `[u8]`
2323
LL | data: [u8],
2424
| ^^^^^^^^^^ the size of `[u8]` cannot be statically determined
2525

26-
error[E0507]: cannot move out of `self.data` which is behind a shared reference
26+
error[E0507]: cannot move out of a shared reference
2727
--> $DIR/deriving-with-repr-packed.rs:29:5
2828
|
2929
LL | #[derive(Debug)]
3030
| ----- in this derive macro expansion
3131
...
3232
LL | data: [u8],
33-
| ^^^^^^^^^^ move occurs because `self.data` has type `[u8]`, which does not implement the `Copy` trait
33+
| ^^^^^^^^^^ move occurs because value has type `[u8]`, which does not implement the `Copy` trait
3434
|
3535
= note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
3636

@@ -40,14 +40,14 @@ error[E0161]: cannot move a value of type `str`
4040
LL | data: str,
4141
| ^^^^^^^^^ the size of `str` cannot be statically determined
4242

43-
error[E0507]: cannot move out of `self.data` which is behind a shared reference
43+
error[E0507]: cannot move out of a shared reference
4444
--> $DIR/deriving-with-repr-packed.rs:38:5
4545
|
4646
LL | #[derive(Debug)]
4747
| ----- in this derive macro expansion
4848
...
4949
LL | data: str,
50-
| ^^^^^^^^^ move occurs because `self.data` has type `str`, which does not implement the `Copy` trait
50+
| ^^^^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
5151
|
5252
= note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
5353

0 commit comments

Comments
 (0)