diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-03-24 15:36:59 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-03-30 04:59:56 -0400 |
| commit | d6466ff13aef6af45f24f28e23f2f3dd36c96cf0 (patch) | |
| tree | a4f0ffb7eef1074bec8e72219b7b9fb555c82c81 /src/libcore | |
| parent | d649292e601a47b3b602415a2e9d9b6ebc298d45 (diff) | |
| download | rust-d6466ff13aef6af45f24f28e23f2f3dd36c96cf0.tar.gz rust-d6466ff13aef6af45f24f28e23f2f3dd36c96cf0.zip | |
Driveby cleanup of the impl for negation, which had some kind of
surprising casts. This version more obviously corresponds to the builtin semantics.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ops.rs | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 26deb80d8c5..862eb16d0bf 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -485,6 +485,7 @@ pub trait Neg { macro_rules! neg_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] + #[allow(unsigned_negation)] impl Neg for $t { #[stable(feature = "rust1", since = "1.0.0")] type Output = $t; @@ -498,28 +499,7 @@ macro_rules! neg_impl { )*) } -macro_rules! neg_uint_impl { - ($t:ty, $t_signed:ty) => { - #[stable(feature = "rust1", since = "1.0.0")] - impl Neg for $t { - type Output = $t; - - #[inline] - fn neg(self) -> $t { -(self as $t_signed) as $t } - } - - forward_ref_unop! { impl Neg, neg for $t } - } -} - -neg_impl! { isize i8 i16 i32 i64 f32 f64 } - -neg_uint_impl! { usize, isize } -neg_uint_impl! { u8, i8 } -neg_uint_impl! { u16, i16 } -neg_uint_impl! { u32, i32 } -neg_uint_impl! { u64, i64 } - +neg_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `Not` trait is used to specify the functionality of unary `!`. /// |
