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