Skip to content

Commit 8ab4060

Browse files
authored
Rollup merge of #69348 - LeSeulArtichaut:patch-1, r=Centril
Wrong error message for move_ref_pattern The current error message states that move occurs *because of `Copy`*: ```Rust "move occurs because `{}` has type `{}` which does implement the `Copy` trait." ``` I found this randomly when surfing through the sources. This means, I don't have any context and might be completely wrong. r? @Centril
2 parents 1cb9fb5 + 38a22b8 commit 8ab4060

6 files changed

+34
-34
lines changed

src/librustc_mir_build/hair/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
659659
});
660660
if !conflicts_ref.is_empty() {
661661
let occurs_because = format!(
662-
"move occurs because `{}` has type `{}` which does implement the `Copy` trait",
662+
"move occurs because `{}` has type `{}` which does not implement the `Copy` trait",
663663
name,
664664
tables.node_type(pat.hir_id),
665665
);

src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | Some(_z @ ref _y) => {}
1515
| | |
1616
| | value borrowed here after move
1717
| value moved into `_z` here
18-
| move occurs because `_z` has type `X` which does implement the `Copy` trait
18+
| move occurs because `_z` has type `X` which does not implement the `Copy` trait
1919

2020
error: cannot move out of value because it is borrowed
2121
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:29:14
@@ -34,7 +34,7 @@ LL | Some(_z @ ref mut _y) => {}
3434
| | |
3535
| | value borrowed here after move
3636
| value moved into `_z` here
37-
| move occurs because `_z` has type `X` which does implement the `Copy` trait
37+
| move occurs because `_z` has type `X` which does not implement the `Copy` trait
3838

3939
error[E0382]: borrow of moved value
4040
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:21:19

src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | let a @ ref b = U;
66
| | |
77
| | value borrowed here after move
88
| value moved into `a` here
9-
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
9+
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait
1010

1111
error: aborting due to previous error
1212

src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr

+25-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | let a @ ref b = U;
66
| | |
77
| | value borrowed here after move
88
| value moved into `a` here
9-
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
9+
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait
1010

1111
error: borrow of moved value
1212
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9
@@ -17,7 +17,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
1717
| | | value borrowed here after move
1818
| | value borrowed here after move
1919
| value moved into `a` here
20-
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
20+
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait
2121

2222
error: borrow of moved value
2323
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:14
@@ -27,7 +27,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
2727
| | |
2828
| | value borrowed here after move
2929
| value moved into `b` here
30-
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
30+
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait
3131

3232
error: borrow of moved value
3333
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:33
@@ -37,7 +37,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
3737
| | |
3838
| | value borrowed here after move
3939
| value moved into `d` here
40-
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
40+
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait
4141

4242
error: borrow of moved value
4343
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9
@@ -48,7 +48,7 @@ LL | let a @ [ref mut b, ref c] = [U, U];
4848
| | | value borrowed here after move
4949
| | value borrowed here after move
5050
| value moved into `a` here
51-
| move occurs because `a` has type `[main::U; 2]` which does implement the `Copy` trait
51+
| move occurs because `a` has type `[main::U; 2]` which does not implement the `Copy` trait
5252

5353
error: borrow of moved value
5454
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:41:9
@@ -58,7 +58,7 @@ LL | let a @ ref b = u();
5858
| | |
5959
| | value borrowed here after move
6060
| value moved into `a` here
61-
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
61+
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait
6262

6363
error: borrow of moved value
6464
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:9
@@ -69,7 +69,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
6969
| | | value borrowed here after move
7070
| | value borrowed here after move
7171
| value moved into `a` here
72-
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
72+
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait
7373

7474
error: borrow of moved value
7575
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:14
@@ -79,7 +79,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
7979
| | |
8080
| | value borrowed here after move
8181
| value moved into `b` here
82-
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
82+
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait
8383

8484
error: borrow of moved value
8585
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:33
@@ -89,7 +89,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
8989
| | |
9090
| | value borrowed here after move
9191
| value moved into `d` here
92-
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
92+
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait
9393

9494
error: borrow of moved value
9595
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:51:9
@@ -100,7 +100,7 @@ LL | let a @ [ref mut b, ref c] = [u(), u()];
100100
| | | value borrowed here after move
101101
| | value borrowed here after move
102102
| value moved into `a` here
103-
| move occurs because `a` has type `[main::U; 2]` which does implement the `Copy` trait
103+
| move occurs because `a` has type `[main::U; 2]` which does not implement the `Copy` trait
104104

105105
error: borrow of moved value
106106
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:56:9
@@ -110,7 +110,7 @@ LL | a @ Some(ref b) => {}
110110
| | |
111111
| | value borrowed here after move
112112
| value moved into `a` here
113-
| move occurs because `a` has type `std::option::Option<main::U>` which does implement the `Copy` trait
113+
| move occurs because `a` has type `std::option::Option<main::U>` which does not implement the `Copy` trait
114114

115115
error: borrow of moved value
116116
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9
@@ -121,7 +121,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
121121
| | | value borrowed here after move
122122
| | value borrowed here after move
123123
| value moved into `a` here
124-
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does implement the `Copy` trait
124+
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does not implement the `Copy` trait
125125

126126
error: borrow of moved value
127127
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:19
@@ -131,7 +131,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
131131
| | |
132132
| | value borrowed here after move
133133
| value moved into `b` here
134-
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
134+
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait
135135

136136
error: borrow of moved value
137137
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:38
@@ -141,7 +141,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
141141
| | |
142142
| | value borrowed here after move
143143
| value moved into `d` here
144-
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
144+
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait
145145

146146
error: borrow of moved value
147147
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:71:9
@@ -152,7 +152,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
152152
| | | value borrowed here after move
153153
| | value borrowed here after move
154154
| value moved into `a` here
155-
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does implement the `Copy` trait
155+
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does not implement the `Copy` trait
156156

157157
error: borrow of moved value
158158
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:9
@@ -162,7 +162,7 @@ LL | a @ Some(ref b) => {}
162162
| | |
163163
| | value borrowed here after move
164164
| value moved into `a` here
165-
| move occurs because `a` has type `std::option::Option<main::U>` which does implement the `Copy` trait
165+
| move occurs because `a` has type `std::option::Option<main::U>` which does not implement the `Copy` trait
166166

167167
error: borrow of moved value
168168
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:83:9
@@ -173,7 +173,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
173173
| | | value borrowed here after move
174174
| | value borrowed here after move
175175
| value moved into `a` here
176-
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does implement the `Copy` trait
176+
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does not implement the `Copy` trait
177177

178178
error: borrow of moved value
179179
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:83:19
@@ -183,7 +183,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
183183
| | |
184184
| | value borrowed here after move
185185
| value moved into `b` here
186-
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
186+
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait
187187

188188
error: borrow of moved value
189189
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:83:38
@@ -193,7 +193,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
193193
| | |
194194
| | value borrowed here after move
195195
| value moved into `d` here
196-
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
196+
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait
197197

198198
error: borrow of moved value
199199
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:93:9
@@ -204,7 +204,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
204204
| | | value borrowed here after move
205205
| | value borrowed here after move
206206
| value moved into `a` here
207-
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does implement the `Copy` trait
207+
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does not implement the `Copy` trait
208208

209209
error: borrow of moved value
210210
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
@@ -214,7 +214,7 @@ LL | fn f1(a @ ref b: U) {}
214214
| | |
215215
| | value borrowed here after move
216216
| value moved into `a` here
217-
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
217+
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait
218218

219219
error: borrow of moved value
220220
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:18:11
@@ -225,7 +225,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
225225
| | | value borrowed here after move
226226
| | value borrowed here after move
227227
| value moved into `a` here
228-
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
228+
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait
229229

230230
error: borrow of moved value
231231
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:18:20
@@ -235,7 +235,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
235235
| | |
236236
| | value borrowed here after move
237237
| value moved into `b` here
238-
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
238+
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait
239239

240240
error: borrow of moved value
241241
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:18:31
@@ -245,7 +245,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
245245
| | |
246246
| | value borrowed here after move
247247
| value moved into `d` here
248-
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
248+
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait
249249

250250
error: borrow of moved value
251251
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:25:11
@@ -256,7 +256,7 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {}
256256
| | | value borrowed here after move
257257
| | value borrowed here after move
258258
| value moved into `a` here
259-
| move occurs because `a` has type `[main::U; 2]` which does implement the `Copy` trait
259+
| move occurs because `a` has type `[main::U; 2]` which does not implement the `Copy` trait
260260

261261
error[E0382]: borrow of moved value
262262
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:22

src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ LL | let a @ (ref mut b, ref mut c) = (U, U);
9696
| | | value borrowed here after move
9797
| | value borrowed here after move
9898
| value moved into `a` here
99-
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
99+
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait
100100

101101
error: borrow of moved value
102102
--> $DIR/borrowck-pat-ref-mut-twice.rs:70:9
@@ -108,7 +108,7 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
108108
| | | value borrowed here after move
109109
| | value borrowed here after move
110110
| value moved into `a` here
111-
| move occurs because `a` has type `&mut (main::U, [main::U; 2])` which does implement the `Copy` trait
111+
| move occurs because `a` has type `&mut (main::U, [main::U; 2])` which does not implement the `Copy` trait
112112

113113
error: borrow of moved value
114114
--> $DIR/borrowck-pat-ref-mut-twice.rs:74:9
@@ -118,7 +118,7 @@ LL | let a @ &mut ref mut b = &mut U;
118118
| | |
119119
| | value borrowed here after move
120120
| value moved into `a` here
121-
| move occurs because `a` has type `&mut main::U` which does implement the `Copy` trait
121+
| move occurs because `a` has type `&mut main::U` which does not implement the `Copy` trait
122122

123123
error: borrow of moved value
124124
--> $DIR/borrowck-pat-ref-mut-twice.rs:77:9
@@ -129,7 +129,7 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
129129
| | | value borrowed here after move
130130
| | value borrowed here after move
131131
| value moved into `a` here
132-
| move occurs because `a` has type `&mut (main::U, main::U)` which does implement the `Copy` trait
132+
| move occurs because `a` has type `&mut (main::U, main::U)` which does not implement the `Copy` trait
133133

134134
error: cannot borrow value as mutable more than once at a time
135135
--> $DIR/borrowck-pat-ref-mut-twice.rs:82:9

src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LL | Ok(ref a @ b) | Err(b @ ref a) => {
3333
| | |
3434
| | value borrowed here after move
3535
| value moved into `b` here
36-
| move occurs because `b` has type `main::NotCopy` which does implement the `Copy` trait
36+
| move occurs because `b` has type `main::NotCopy` which does not implement the `Copy` trait
3737

3838
error: cannot move out of value because it is borrowed
3939
--> $DIR/default-binding-modes-both-sides-independent.rs:44:9

0 commit comments

Comments
 (0)