diff options
Diffstat (limited to 'tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs')
| -rw-r--r-- | tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs b/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs new file mode 100644 index 00000000000..4325c8b111b --- /dev/null +++ b/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs @@ -0,0 +1,7 @@ +//! This test ensures that the unary negation operator (`-`) cannot be applied to unsigned ints + +fn main() { + let x = -1 as usize; //~ ERROR: cannot apply unary operator `-` + let x = (-1) as usize; //~ ERROR: cannot apply unary operator `-` + let x: u32 = -1; //~ ERROR: cannot apply unary operator `-` +} |
