Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/ui/binop/augmented-assignment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
//@ reference: expr.arith-logic.behavior

#![allow(unused_imports)]
#![deny(unused_assignments)]
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/binop/binary-minus-without-space.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//@ run-pass
//@ reference: expr.arith-logic.syntax
//@ reference: patterns.literal.syntax
//@ reference: patterns.literal.intro
// Check that issue #954 stays fixed


Expand Down
1 change: 1 addition & 0 deletions tests/ui/binop/binop-consume-args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ reference: expr.arith-logic.behavior
// Test that binary operators consume their arguments

use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr};
Expand Down
80 changes: 40 additions & 40 deletions tests/ui/binop/binop-consume-args.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0382]: use of moved value: `lhs`
--> $DIR/binop-consume-args.rs:7:10
--> $DIR/binop-consume-args.rs:8:10
|
LL | fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
| --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait
Expand All @@ -9,7 +9,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
help: if `A` implemented `Clone`, you could clone the value
--> $DIR/binop-consume-args.rs:5:8
--> $DIR/binop-consume-args.rs:6:8
|
LL | fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
| ^ consider constraining this type parameter with `Clone`
Expand All @@ -23,7 +23,7 @@ LL | fn add<A: Add<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
| ++++++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

error[E0382]: use of moved value: `rhs`
--> $DIR/binop-consume-args.rs:62:10
--> $DIR/binop-consume-args.rs:63:10
|
LL | fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
| --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait
Expand All @@ -457,7 +457,7 @@ LL | drop(rhs);
| ^^^ value used here after move
|
help: if `B` implemented `Clone`, you could clone the value
--> $DIR/binop-consume-args.rs:59:30
--> $DIR/binop-consume-args.rs:60:30
|
LL | fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
| ^ consider constraining this type parameter with `Clone`
Expand Down
1 change: 1 addition & 0 deletions tests/ui/binop/binop-move-semantics.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ reference: expr.arith-logic.behavior
// Test that move restrictions are enforced on overloaded binary operations

use std::ops::Add;
Expand Down
Loading
Loading