Skip to content

Commit 3c3a352

Browse files
tests/ui/binop: add annotations for reference rules
1 parent 085c58f commit 3c3a352

7 files changed

Lines changed: 62 additions & 53 deletions

tests/ui/binop/augmented-assignment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ run-pass
2+
//@ reference: expr.arith-logic.behavior
23

34
#![allow(unused_imports)]
45
#![deny(unused_assignments)]

tests/ui/binop/binary-minus-without-space.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//@ run-pass
2+
//@ reference: expr.arith-logic.syntax
3+
//@ reference: patterns.literal.syntax
4+
//@ reference: patterns.literal.intro
25
// Check that issue #954 stays fixed
36

47

tests/ui/binop/binop-consume-args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ reference: expr.arith-logic.behavior
12
// Test that binary operators consume their arguments
23

34
use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr};

tests/ui/binop/binop-consume-args.stderr

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0382]: use of moved value: `lhs`
2-
--> $DIR/binop-consume-args.rs:7:10
2+
--> $DIR/binop-consume-args.rs:8:10
33
|
44
LL | fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
55
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -9,7 +9,7 @@ LL | drop(lhs);
99
| ^^^ value used here after move
1010
|
1111
help: if `A` implemented `Clone`, you could clone the value
12-
--> $DIR/binop-consume-args.rs:5:8
12+
--> $DIR/binop-consume-args.rs:6:8
1313
|
1414
LL | fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
1515
| ^ consider constraining this type parameter with `Clone`
@@ -23,7 +23,7 @@ LL | fn add<A: Add<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
2323
| ++++++
2424

2525
error[E0382]: use of moved value: `rhs`
26-
--> $DIR/binop-consume-args.rs:8:10
26+
--> $DIR/binop-consume-args.rs:9:10
2727
|
2828
LL | fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
2929
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -34,7 +34,7 @@ LL | drop(rhs);
3434
| ^^^ value used here after move
3535
|
3636
help: if `B` implemented `Clone`, you could clone the value
37-
--> $DIR/binop-consume-args.rs:5:30
37+
--> $DIR/binop-consume-args.rs:6:30
3838
|
3939
LL | fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
4040
| ^ consider constraining this type parameter with `Clone`
@@ -46,7 +46,7 @@ LL | fn add<A: Add<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
4646
| ++++++
4747

4848
error[E0382]: use of moved value: `lhs`
49-
--> $DIR/binop-consume-args.rs:13:10
49+
--> $DIR/binop-consume-args.rs:14:10
5050
|
5151
LL | fn sub<A: Sub<B, Output=()>, B>(lhs: A, rhs: B) {
5252
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -56,7 +56,7 @@ LL | drop(lhs);
5656
| ^^^ value used here after move
5757
|
5858
help: if `A` implemented `Clone`, you could clone the value
59-
--> $DIR/binop-consume-args.rs:11:8
59+
--> $DIR/binop-consume-args.rs:12:8
6060
|
6161
LL | fn sub<A: Sub<B, Output=()>, B>(lhs: A, rhs: B) {
6262
| ^ consider constraining this type parameter with `Clone`
@@ -70,7 +70,7 @@ LL | fn sub<A: Sub<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
7070
| ++++++
7171

7272
error[E0382]: use of moved value: `rhs`
73-
--> $DIR/binop-consume-args.rs:14:10
73+
--> $DIR/binop-consume-args.rs:15:10
7474
|
7575
LL | fn sub<A: Sub<B, Output=()>, B>(lhs: A, rhs: B) {
7676
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -81,7 +81,7 @@ LL | drop(rhs);
8181
| ^^^ value used here after move
8282
|
8383
help: if `B` implemented `Clone`, you could clone the value
84-
--> $DIR/binop-consume-args.rs:11:30
84+
--> $DIR/binop-consume-args.rs:12:30
8585
|
8686
LL | fn sub<A: Sub<B, Output=()>, B>(lhs: A, rhs: B) {
8787
| ^ consider constraining this type parameter with `Clone`
@@ -93,7 +93,7 @@ LL | fn sub<A: Sub<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
9393
| ++++++
9494

9595
error[E0382]: use of moved value: `lhs`
96-
--> $DIR/binop-consume-args.rs:19:10
96+
--> $DIR/binop-consume-args.rs:20:10
9797
|
9898
LL | fn mul<A: Mul<B, Output=()>, B>(lhs: A, rhs: B) {
9999
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -103,7 +103,7 @@ LL | drop(lhs);
103103
| ^^^ value used here after move
104104
|
105105
help: if `A` implemented `Clone`, you could clone the value
106-
--> $DIR/binop-consume-args.rs:17:8
106+
--> $DIR/binop-consume-args.rs:18:8
107107
|
108108
LL | fn mul<A: Mul<B, Output=()>, B>(lhs: A, rhs: B) {
109109
| ^ consider constraining this type parameter with `Clone`
@@ -117,7 +117,7 @@ LL | fn mul<A: Mul<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
117117
| ++++++
118118

119119
error[E0382]: use of moved value: `rhs`
120-
--> $DIR/binop-consume-args.rs:20:10
120+
--> $DIR/binop-consume-args.rs:21:10
121121
|
122122
LL | fn mul<A: Mul<B, Output=()>, B>(lhs: A, rhs: B) {
123123
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -128,7 +128,7 @@ LL | drop(rhs);
128128
| ^^^ value used here after move
129129
|
130130
help: if `B` implemented `Clone`, you could clone the value
131-
--> $DIR/binop-consume-args.rs:17:30
131+
--> $DIR/binop-consume-args.rs:18:30
132132
|
133133
LL | fn mul<A: Mul<B, Output=()>, B>(lhs: A, rhs: B) {
134134
| ^ consider constraining this type parameter with `Clone`
@@ -140,7 +140,7 @@ LL | fn mul<A: Mul<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
140140
| ++++++
141141

142142
error[E0382]: use of moved value: `lhs`
143-
--> $DIR/binop-consume-args.rs:25:10
143+
--> $DIR/binop-consume-args.rs:26:10
144144
|
145145
LL | fn div<A: Div<B, Output=()>, B>(lhs: A, rhs: B) {
146146
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -150,7 +150,7 @@ LL | drop(lhs);
150150
| ^^^ value used here after move
151151
|
152152
help: if `A` implemented `Clone`, you could clone the value
153-
--> $DIR/binop-consume-args.rs:23:8
153+
--> $DIR/binop-consume-args.rs:24:8
154154
|
155155
LL | fn div<A: Div<B, Output=()>, B>(lhs: A, rhs: B) {
156156
| ^ consider constraining this type parameter with `Clone`
@@ -164,7 +164,7 @@ LL | fn div<A: Div<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
164164
| ++++++
165165

166166
error[E0382]: use of moved value: `rhs`
167-
--> $DIR/binop-consume-args.rs:26:10
167+
--> $DIR/binop-consume-args.rs:27:10
168168
|
169169
LL | fn div<A: Div<B, Output=()>, B>(lhs: A, rhs: B) {
170170
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -175,7 +175,7 @@ LL | drop(rhs);
175175
| ^^^ value used here after move
176176
|
177177
help: if `B` implemented `Clone`, you could clone the value
178-
--> $DIR/binop-consume-args.rs:23:30
178+
--> $DIR/binop-consume-args.rs:24:30
179179
|
180180
LL | fn div<A: Div<B, Output=()>, B>(lhs: A, rhs: B) {
181181
| ^ consider constraining this type parameter with `Clone`
@@ -187,7 +187,7 @@ LL | fn div<A: Div<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
187187
| ++++++
188188

189189
error[E0382]: use of moved value: `lhs`
190-
--> $DIR/binop-consume-args.rs:31:10
190+
--> $DIR/binop-consume-args.rs:32:10
191191
|
192192
LL | fn rem<A: Rem<B, Output=()>, B>(lhs: A, rhs: B) {
193193
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -197,7 +197,7 @@ LL | drop(lhs);
197197
| ^^^ value used here after move
198198
|
199199
help: if `A` implemented `Clone`, you could clone the value
200-
--> $DIR/binop-consume-args.rs:29:8
200+
--> $DIR/binop-consume-args.rs:30:8
201201
|
202202
LL | fn rem<A: Rem<B, Output=()>, B>(lhs: A, rhs: B) {
203203
| ^ consider constraining this type parameter with `Clone`
@@ -211,7 +211,7 @@ LL | fn rem<A: Rem<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
211211
| ++++++
212212

213213
error[E0382]: use of moved value: `rhs`
214-
--> $DIR/binop-consume-args.rs:32:10
214+
--> $DIR/binop-consume-args.rs:33:10
215215
|
216216
LL | fn rem<A: Rem<B, Output=()>, B>(lhs: A, rhs: B) {
217217
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -222,7 +222,7 @@ LL | drop(rhs);
222222
| ^^^ value used here after move
223223
|
224224
help: if `B` implemented `Clone`, you could clone the value
225-
--> $DIR/binop-consume-args.rs:29:30
225+
--> $DIR/binop-consume-args.rs:30:30
226226
|
227227
LL | fn rem<A: Rem<B, Output=()>, B>(lhs: A, rhs: B) {
228228
| ^ consider constraining this type parameter with `Clone`
@@ -234,7 +234,7 @@ LL | fn rem<A: Rem<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
234234
| ++++++
235235

236236
error[E0382]: use of moved value: `lhs`
237-
--> $DIR/binop-consume-args.rs:37:10
237+
--> $DIR/binop-consume-args.rs:38:10
238238
|
239239
LL | fn bitand<A: BitAnd<B, Output=()>, B>(lhs: A, rhs: B) {
240240
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -244,7 +244,7 @@ LL | drop(lhs);
244244
| ^^^ value used here after move
245245
|
246246
help: if `A` implemented `Clone`, you could clone the value
247-
--> $DIR/binop-consume-args.rs:35:11
247+
--> $DIR/binop-consume-args.rs:36:11
248248
|
249249
LL | fn bitand<A: BitAnd<B, Output=()>, B>(lhs: A, rhs: B) {
250250
| ^ consider constraining this type parameter with `Clone`
@@ -258,7 +258,7 @@ LL | fn bitand<A: BitAnd<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
258258
| ++++++
259259

260260
error[E0382]: use of moved value: `rhs`
261-
--> $DIR/binop-consume-args.rs:38:10
261+
--> $DIR/binop-consume-args.rs:39:10
262262
|
263263
LL | fn bitand<A: BitAnd<B, Output=()>, B>(lhs: A, rhs: B) {
264264
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -269,7 +269,7 @@ LL | drop(rhs);
269269
| ^^^ value used here after move
270270
|
271271
help: if `B` implemented `Clone`, you could clone the value
272-
--> $DIR/binop-consume-args.rs:35:36
272+
--> $DIR/binop-consume-args.rs:36:36
273273
|
274274
LL | fn bitand<A: BitAnd<B, Output=()>, B>(lhs: A, rhs: B) {
275275
| ^ consider constraining this type parameter with `Clone`
@@ -281,7 +281,7 @@ LL | fn bitand<A: BitAnd<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
281281
| ++++++
282282

283283
error[E0382]: use of moved value: `lhs`
284-
--> $DIR/binop-consume-args.rs:43:10
284+
--> $DIR/binop-consume-args.rs:44:10
285285
|
286286
LL | fn bitor<A: BitOr<B, Output=()>, B>(lhs: A, rhs: B) {
287287
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -291,7 +291,7 @@ LL | drop(lhs);
291291
| ^^^ value used here after move
292292
|
293293
help: if `A` implemented `Clone`, you could clone the value
294-
--> $DIR/binop-consume-args.rs:41:10
294+
--> $DIR/binop-consume-args.rs:42:10
295295
|
296296
LL | fn bitor<A: BitOr<B, Output=()>, B>(lhs: A, rhs: B) {
297297
| ^ consider constraining this type parameter with `Clone`
@@ -305,7 +305,7 @@ LL | fn bitor<A: BitOr<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
305305
| ++++++
306306

307307
error[E0382]: use of moved value: `rhs`
308-
--> $DIR/binop-consume-args.rs:44:10
308+
--> $DIR/binop-consume-args.rs:45:10
309309
|
310310
LL | fn bitor<A: BitOr<B, Output=()>, B>(lhs: A, rhs: B) {
311311
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -316,7 +316,7 @@ LL | drop(rhs);
316316
| ^^^ value used here after move
317317
|
318318
help: if `B` implemented `Clone`, you could clone the value
319-
--> $DIR/binop-consume-args.rs:41:34
319+
--> $DIR/binop-consume-args.rs:42:34
320320
|
321321
LL | fn bitor<A: BitOr<B, Output=()>, B>(lhs: A, rhs: B) {
322322
| ^ consider constraining this type parameter with `Clone`
@@ -328,7 +328,7 @@ LL | fn bitor<A: BitOr<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
328328
| ++++++
329329

330330
error[E0382]: use of moved value: `lhs`
331-
--> $DIR/binop-consume-args.rs:49:10
331+
--> $DIR/binop-consume-args.rs:50:10
332332
|
333333
LL | fn bitxor<A: BitXor<B, Output=()>, B>(lhs: A, rhs: B) {
334334
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -338,7 +338,7 @@ LL | drop(lhs);
338338
| ^^^ value used here after move
339339
|
340340
help: if `A` implemented `Clone`, you could clone the value
341-
--> $DIR/binop-consume-args.rs:47:11
341+
--> $DIR/binop-consume-args.rs:48:11
342342
|
343343
LL | fn bitxor<A: BitXor<B, Output=()>, B>(lhs: A, rhs: B) {
344344
| ^ consider constraining this type parameter with `Clone`
@@ -352,7 +352,7 @@ LL | fn bitxor<A: BitXor<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
352352
| ++++++
353353

354354
error[E0382]: use of moved value: `rhs`
355-
--> $DIR/binop-consume-args.rs:50:10
355+
--> $DIR/binop-consume-args.rs:51:10
356356
|
357357
LL | fn bitxor<A: BitXor<B, Output=()>, B>(lhs: A, rhs: B) {
358358
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -363,7 +363,7 @@ LL | drop(rhs);
363363
| ^^^ value used here after move
364364
|
365365
help: if `B` implemented `Clone`, you could clone the value
366-
--> $DIR/binop-consume-args.rs:47:36
366+
--> $DIR/binop-consume-args.rs:48:36
367367
|
368368
LL | fn bitxor<A: BitXor<B, Output=()>, B>(lhs: A, rhs: B) {
369369
| ^ consider constraining this type parameter with `Clone`
@@ -375,7 +375,7 @@ LL | fn bitxor<A: BitXor<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
375375
| ++++++
376376

377377
error[E0382]: use of moved value: `lhs`
378-
--> $DIR/binop-consume-args.rs:55:10
378+
--> $DIR/binop-consume-args.rs:56:10
379379
|
380380
LL | fn shl<A: Shl<B, Output=()>, B>(lhs: A, rhs: B) {
381381
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -385,7 +385,7 @@ LL | drop(lhs);
385385
| ^^^ value used here after move
386386
|
387387
help: if `A` implemented `Clone`, you could clone the value
388-
--> $DIR/binop-consume-args.rs:53:8
388+
--> $DIR/binop-consume-args.rs:54:8
389389
|
390390
LL | fn shl<A: Shl<B, Output=()>, B>(lhs: A, rhs: B) {
391391
| ^ consider constraining this type parameter with `Clone`
@@ -399,7 +399,7 @@ LL | fn shl<A: Shl<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
399399
| ++++++
400400

401401
error[E0382]: use of moved value: `rhs`
402-
--> $DIR/binop-consume-args.rs:56:10
402+
--> $DIR/binop-consume-args.rs:57:10
403403
|
404404
LL | fn shl<A: Shl<B, Output=()>, B>(lhs: A, rhs: B) {
405405
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -410,7 +410,7 @@ LL | drop(rhs);
410410
| ^^^ value used here after move
411411
|
412412
help: if `B` implemented `Clone`, you could clone the value
413-
--> $DIR/binop-consume-args.rs:53:30
413+
--> $DIR/binop-consume-args.rs:54:30
414414
|
415415
LL | fn shl<A: Shl<B, Output=()>, B>(lhs: A, rhs: B) {
416416
| ^ consider constraining this type parameter with `Clone`
@@ -422,7 +422,7 @@ LL | fn shl<A: Shl<B, Output=()>, B: Copy>(lhs: A, rhs: B) {
422422
| ++++++
423423

424424
error[E0382]: use of moved value: `lhs`
425-
--> $DIR/binop-consume-args.rs:61:10
425+
--> $DIR/binop-consume-args.rs:62:10
426426
|
427427
LL | fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
428428
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
@@ -432,7 +432,7 @@ LL | drop(lhs);
432432
| ^^^ value used here after move
433433
|
434434
help: if `A` implemented `Clone`, you could clone the value
435-
--> $DIR/binop-consume-args.rs:59:8
435+
--> $DIR/binop-consume-args.rs:60:8
436436
|
437437
LL | fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
438438
| ^ consider constraining this type parameter with `Clone`
@@ -446,7 +446,7 @@ LL | fn shr<A: Shr<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
446446
| ++++++
447447

448448
error[E0382]: use of moved value: `rhs`
449-
--> $DIR/binop-consume-args.rs:62:10
449+
--> $DIR/binop-consume-args.rs:63:10
450450
|
451451
LL | fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
452452
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
@@ -457,7 +457,7 @@ LL | drop(rhs);
457457
| ^^^ value used here after move
458458
|
459459
help: if `B` implemented `Clone`, you could clone the value
460-
--> $DIR/binop-consume-args.rs:59:30
460+
--> $DIR/binop-consume-args.rs:60:30
461461
|
462462
LL | fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
463463
| ^ consider constraining this type parameter with `Clone`

tests/ui/binop/binop-move-semantics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ reference: expr.arith-logic.behavior
12
// Test that move restrictions are enforced on overloaded binary operations
23

34
use std::ops::Add;

0 commit comments

Comments
 (0)