2016-01-11 12:31:46 +01:00
|
|
|
// Test that negating unsigned integers doesn't compile
|
2015-04-16 22:48:31 +10:00
|
|
|
|
2015-07-14 01:03:24 +03:00
|
|
|
struct S;
|
|
|
|
impl std::ops::Neg for S {
|
|
|
|
type Output = u32;
|
|
|
|
fn neg(self) -> u32 { 0 }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2017-01-03 21:48:17 +02:00
|
|
|
let _max: usize = -1;
|
|
|
|
//~^ ERROR cannot apply unary operator `-` to type `usize`
|
|
|
|
|
2015-12-16 18:44:15 +01:00
|
|
|
let x = 5u8;
|
2017-01-03 21:48:17 +02:00
|
|
|
let _y = -x;
|
|
|
|
//~^ ERROR cannot apply unary operator `-` to type `u8`
|
|
|
|
|
2015-07-14 01:03:24 +03:00
|
|
|
-S; // should not trigger the gate; issue 26840
|
|
|
|
}
|