From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/binop/binop-consume-args.rs | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/ui/binop/binop-consume-args.rs (limited to 'src/test/ui/binop/binop-consume-args.rs') diff --git a/src/test/ui/binop/binop-consume-args.rs b/src/test/ui/binop/binop-consume-args.rs new file mode 100644 index 000000000..8d6c725d7 --- /dev/null +++ b/src/test/ui/binop/binop-consume-args.rs @@ -0,0 +1,65 @@ +// Test that binary operators consume their arguments + +use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr}; + +fn add, B>(lhs: A, rhs: B) { + lhs + rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn sub, B>(lhs: A, rhs: B) { + lhs - rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn mul, B>(lhs: A, rhs: B) { + lhs * rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn div, B>(lhs: A, rhs: B) { + lhs / rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn rem, B>(lhs: A, rhs: B) { + lhs % rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn bitand, B>(lhs: A, rhs: B) { + lhs & rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn bitor, B>(lhs: A, rhs: B) { + lhs | rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn bitxor, B>(lhs: A, rhs: B) { + lhs ^ rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn shl, B>(lhs: A, rhs: B) { + lhs << rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn shr, B>(lhs: A, rhs: B) { + lhs >> rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn main() {} -- cgit v1.2.3