From 6892809fdf7d1e11012b8cb630dc3954e3a5e4d5 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Thu, 22 Feb 2018 20:37:39 +1300 Subject: [PATCH] Conditionally disable i128/u128 code based on the 'i128_type' feature There is an existing i128_type feature, enabled by default. Most code that refers to i128 and u128 ignore it. Because of this, disabling i128_type would cause compiler errors. After this commit, no code referring to i128 or u128 will be enabled if i128_type is disabled. --- core/cmp.rs | 15 ++++-- core/default.rs | 2 + core/fmt/num.rs | 9 +++- core/hash/mod.rs | 8 +++ core/iter/range.rs | 1 + core/iter/traits.rs | 6 ++- core/nonzero.rs | 7 ++- core/num/i128.rs | 1 + core/num/mod.rs | 113 ++++++++++++++++++++++++++++++++++--------- core/num/u128.rs | 1 + core/num/wrapping.rs | 5 +- core/ops/arith.rs | 54 ++++++++++++++++----- core/ops/bit.rs | 63 +++++++++++++++++++----- 13 files changed, 233 insertions(+), 52 deletions(-) diff --git a/core/cmp.rs b/core/cmp.rs index 266cae3..96c67e8 100644 --- a/core/cmp.rs +++ b/core/cmp.rs @@ -779,9 +779,12 @@ mod impls { } partial_eq_impl! { - bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 + bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + #[cfg(i128_type)] + partial_eq_impl! { u128 i128 } + macro_rules! eq_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] @@ -789,7 +792,10 @@ mod impls { )*) } - eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + #[cfg(i128_type)] + eq_impl! { u128 i128 } macro_rules! partial_ord_impl { ($($t:ty)*) => ($( @@ -878,7 +884,10 @@ mod impls { } } - ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + #[cfg(i128_type)] + ord_impl! { u128 i128 } #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/core/default.rs b/core/default.rs index ab36e29..34a2a1e 100644 --- a/core/default.rs +++ b/core/default.rs @@ -145,6 +145,7 @@ default_impl! { u8, 0, "Returns the default value of `0`" } default_impl! { u16, 0, "Returns the default value of `0`" } default_impl! { u32, 0, "Returns the default value of `0`" } default_impl! { u64, 0, "Returns the default value of `0`" } +#[cfg(i128_type)] default_impl! { u128, 0, "Returns the default value of `0`" } default_impl! { isize, 0, "Returns the default value of `0`" } @@ -152,6 +153,7 @@ default_impl! { i8, 0, "Returns the default value of `0`" } default_impl! { i16, 0, "Returns the default value of `0`" } default_impl! { i32, 0, "Returns the default value of `0`" } default_impl! { i64, 0, "Returns the default value of `0`" } +#[cfg(i128_type)] default_impl! { i128, 0, "Returns the default value of `0`" } default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } diff --git a/core/fmt/num.rs b/core/fmt/num.rs index 2992e7c..b6d2d72 100644 --- a/core/fmt/num.rs +++ b/core/fmt/num.rs @@ -29,6 +29,7 @@ trait Int: PartialEq + PartialOrd + Div + Rem + fn to_u16(&self) -> u16; fn to_u32(&self) -> u32; fn to_u64(&self) -> u64; + #[cfg(i128_type)] fn to_u128(&self) -> u128; } @@ -40,10 +41,14 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } fn to_u32(&self) -> u32 { *self as u32 } fn to_u64(&self) -> u64 { *self as u64 } + #[cfg(i128_type)] fn to_u128(&self) -> u128 { *self as u128 } })*) } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } + +#[cfg(i128_type)] +doit! { i128 u128 } /// A type that represents a specific radix #[doc(hidden)] @@ -185,6 +190,7 @@ integer! { i8, u8 } integer! { i16, u16 } integer! { i32, u32 } integer! { i64, u64 } +#[cfg(i128_type)] integer! { i128, u128 } const DEC_DIGITS_LUT: &'static[u8] = @@ -261,6 +267,7 @@ macro_rules! impl_Display { impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); +#[cfg(i128_type)] impl_Display!(i128, u128: to_u128); #[cfg(target_pointer_width = "16")] impl_Display!(isize, usize: to_u16); diff --git a/core/hash/mod.rs b/core/hash/mod.rs index 15545a0..f0c0c51 100644 --- a/core/hash/mod.rs +++ b/core/hash/mod.rs @@ -308,6 +308,7 @@ pub trait Hasher { /// Writes a single `u128` into this hasher. #[inline] #[unstable(feature = "i128", issue = "35118")] + #[cfg(i128_type)] fn write_u128(&mut self, i: u128) { self.write(&unsafe { mem::transmute::<_, [u8; 16]>(i) }) } @@ -348,6 +349,7 @@ pub trait Hasher { /// Writes a single `i128` into this hasher. #[inline] #[unstable(feature = "i128", issue = "35118")] + #[cfg(i128_type)] fn write_i128(&mut self, i: i128) { self.write_u128(i as u128) } @@ -379,6 +381,7 @@ impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { fn write_u64(&mut self, i: u64) { (**self).write_u64(i) } + #[cfg(i128_type)] fn write_u128(&mut self, i: u128) { (**self).write_u128(i) } @@ -397,6 +400,7 @@ impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { fn write_i64(&mut self, i: i64) { (**self).write_i64(i) } + #[cfg(i128_type)] fn write_i128(&mut self, i: i128) { (**self).write_i128(i) } @@ -576,6 +580,10 @@ mod impls { (i32, write_i32), (i64, write_i64), (isize, write_isize), + } + + #[cfg(i128_type)] + impl_write! { (u128, write_u128), (i128, write_i128), } diff --git a/core/iter/range.rs b/core/iter/range.rs index 65b38c9..302553d 100644 --- a/core/iter/range.rs +++ b/core/iter/range.rs @@ -175,6 +175,7 @@ step_impl_signed!([i64: u64]); // assume here that it is less than 64-bits. #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); +#[cfg(i128_type)] step_impl_no_between!(u128 i128); macro_rules! range_exact_iter_impl { diff --git a/core/iter/traits.rs b/core/iter/traits.rs index 860742d..211a139 100644 --- a/core/iter/traits.rs +++ b/core/iter/traits.rs @@ -841,7 +841,11 @@ macro_rules! float_sum_product { )*) } -integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } + +#[cfg(i128_type)] +integer_sum_product! { i128 u128 } + float_sum_product! { f32 f64 } /// An iterator adapter that produces output as long as the underlying diff --git a/core/nonzero.rs b/core/nonzero.rs index 2c966eb..fc83a79 100644 --- a/core/nonzero.rs +++ b/core/nonzero.rs @@ -54,10 +54,13 @@ impl_zeroable_for_pointer_types! { } impl_zeroable_for_integer_types! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 + usize u8 u16 u32 u64 + isize i8 i16 i32 i64 } +#[cfg(i128_type)] +impl_zeroable_for_integer_types! { u128 i128 } + /// A wrapper type for raw pointers and integers that will never be /// NULL or 0 that might allow certain optimizations. #[lang = "non_zero"] diff --git a/core/num/i128.rs b/core/num/i128.rs index 04354e2..47a37f5 100644 --- a/core/num/i128.rs +++ b/core/num/i128.rs @@ -14,4 +14,5 @@ #![unstable(feature = "i128", issue="35118")] +#[cfg(i128_type)] int_module! { i128, #[unstable(feature = "i128", issue="35118")] } diff --git a/core/num/mod.rs b/core/num/mod.rs index 5554312..85cdae1 100644 --- a/core/num/mod.rs +++ b/core/num/mod.rs @@ -1362,6 +1362,7 @@ impl i64 { } #[lang = "i128"] +#[cfg(i128_type)] impl i128 { int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, 170141183460469231731687303715884105727, "#![feature(i128_type)] @@ -3044,6 +3045,7 @@ impl u64 { } #[lang = "u128"] +#[cfg(i128_type)] impl u128 { uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "#![feature(i128_type)] #![feature(i128)] @@ -3211,7 +3213,10 @@ macro_rules! from_str_radix_int_impl { } )*} } -from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } +from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } + +#[cfg(i128_type)] +from_str_radix_int_impl! { i128 u128 } /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] @@ -3328,11 +3333,13 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); +#[cfg(i128_type)] try_from_upper_bounded!(u128, u64, u32, u16, u8); try_from_both_bounded!(i16, i8); try_from_both_bounded!(i32, i16, i8); try_from_both_bounded!(i64, i32, i16, i8); +#[cfg(i128_type)] try_from_both_bounded!(i128, i64, i32, i16, i8); // unsigned-to-signed @@ -3340,17 +3347,29 @@ try_from_upper_bounded!(u8, i8); try_from_upper_bounded!(u16, i8, i16); try_from_upper_bounded!(u32, i8, i16, i32); try_from_upper_bounded!(u64, i8, i16, i32, i64); +#[cfg(i128_type)] try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); // signed-to-unsigned -try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); -try_from_lower_bounded!(i16, u16, u32, u64, u128); -try_from_lower_bounded!(i32, u32, u64, u128); -try_from_lower_bounded!(i64, u64, u128); +try_from_lower_bounded!(i8, u8, u16, u32, u64); +#[cfg(i128_type)] +try_from_lower_bounded!(i8, u128); +try_from_lower_bounded!(i16, u16, u32, u64); +#[cfg(i128_type)] +try_from_lower_bounded!(i16, u128); +try_from_lower_bounded!(i32, u32, u64); +#[cfg(i128_type)] +try_from_lower_bounded!(i32, u128); +#[cfg(i128_type)] +try_from_lower_bounded!(i64, u64); +#[cfg(i128_type)] +try_from_lower_bounded!(i64, u128); +#[cfg(i128_type)] try_from_lower_bounded!(i128, u128); try_from_both_bounded!(i16, u8); try_from_both_bounded!(i32, u16, u8); try_from_both_bounded!(i64, u32, u16, u8); +#[cfg(i128_type)] try_from_both_bounded!(i128, u64, u32, u16, u8); // usize/isize @@ -3363,24 +3382,40 @@ mod ptr_try_from_impls { use convert::{Infallible, TryFrom}; try_from_upper_bounded!(usize, u8); - try_from_unbounded!(usize, u16, u32, u64, u128); + try_from_unbounded!(usize, u16, u32, u64); + #[cfg(i128_type)] + try_from_unbounded!(usize, u128); try_from_upper_bounded!(usize, i8, i16); - try_from_unbounded!(usize, i32, i64, i128); + try_from_unbounded!(usize, i32, i64); + #[cfg(i128_type)] + try_from_unbounded!(usize, i128); try_from_both_bounded!(isize, u8); - try_from_lower_bounded!(isize, u16, u32, u64, u128); + try_from_lower_bounded!(isize, u16, u32, u64); + #[cfg(i128_type)] + try_from_lower_bounded!(isize, u128); try_from_both_bounded!(isize, i8); - try_from_unbounded!(isize, i16, i32, i64, i128); + try_from_unbounded!(isize, i16, i32, i64); + #[cfg(i128_type)] + try_from_unbounded!(isize, i128); rev!(try_from_unbounded, usize, u16); - rev!(try_from_upper_bounded, usize, u32, u64, u128); + rev!(try_from_upper_bounded, usize, u32, u64); + #[cfg(i128_type)] + rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16); - rev!(try_from_both_bounded, usize, i32, i64, i128); + rev!(try_from_both_bounded, usize, i32, i64); + #[cfg(i128_type)] + rev!(try_from_both_bounded, usize, i128); rev!(try_from_unbounded, isize, u8); - rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); + rev!(try_from_upper_bounded, isize, u16, u32, u64); + #[cfg(i128_type)] + rev!(try_from_upper_bounded, isize, u128); rev!(try_from_unbounded, isize, i16); - rev!(try_from_both_bounded, isize, i32, i64, i128); + rev!(try_from_both_bounded, isize, i32, i64); + #[cfg(i128_type)] + rev!(try_from_both_bounded, isize, i128); } #[cfg(target_pointer_width = "32")] @@ -3389,24 +3424,38 @@ mod ptr_try_from_impls { use convert::{Infallible, TryFrom}; try_from_upper_bounded!(usize, u8, u16); - try_from_unbounded!(usize, u32, u64, u128); + try_from_unbounded!(usize, u32, u64); + #[cfg(i128_type)] + try_from_unbounded!(usize, u128); try_from_upper_bounded!(usize, i8, i16, i32); - try_from_unbounded!(usize, i64, i128); + try_from_unbounded!(usize, i64); + #[cfg(i128_type)] + try_from_unbounded!(usize, i128); try_from_both_bounded!(isize, u8, u16); - try_from_lower_bounded!(isize, u32, u64, u128); + try_from_lower_bounded!(isize, u32, u64); + #[cfg(i128_type)] + try_from_lower_bounded!(isize, u128); try_from_both_bounded!(isize, i8, i16); - try_from_unbounded!(isize, i32, i64, i128); + try_from_unbounded!(isize, i32, i64); + #[cfg(i128_type)] + try_from_unbounded!(isize, i128); rev!(try_from_unbounded, usize, u16, u32); - rev!(try_from_upper_bounded, usize, u64, u128); + rev!(try_from_upper_bounded, usize, u64); + #[cfg(i128_type)] + rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32); - rev!(try_from_both_bounded, usize, i64, i128); + rev!(try_from_both_bounded, usize, i64); + #[cfg(i128_type)] + rev!(try_from_both_bounded, usize, i128); rev!(try_from_unbounded, isize, u8, u16); rev!(try_from_upper_bounded, isize, u32, u64, u128); rev!(try_from_unbounded, isize, i16, i32); - rev!(try_from_both_bounded, isize, i64, i128); + rev!(try_from_both_bounded, isize, i64); + #[cfg(i128_type)] + rev!(try_from_both_bounded, isize, i128); } #[cfg(target_pointer_width = "64")] @@ -3417,21 +3466,26 @@ mod ptr_try_from_impls { try_from_upper_bounded!(usize, u8, u16, u32); try_from_unbounded!(usize, u64, u128); try_from_upper_bounded!(usize, i8, i16, i32, i64); + #[cfg(i128_type)] try_from_unbounded!(usize, i128); try_from_both_bounded!(isize, u8, u16, u32); try_from_lower_bounded!(isize, u64, u128); try_from_both_bounded!(isize, i8, i16, i32); - try_from_unbounded!(isize, i64, i128); + try_from_unbounded!(isize, i64); + #[cfg(i128_type)] + try_from_unbounded!(isize, i128); rev!(try_from_unbounded, usize, u16, u32, u64); rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); + #[cfg(i128_type)] rev!(try_from_both_bounded, usize, i128); rev!(try_from_unbounded, isize, u8, u16, u32); rev!(try_from_upper_bounded, isize, u64, u128); rev!(try_from_unbounded, isize, i16, i32, i64); + #[cfg(i128_type)] rev!(try_from_both_bounded, isize, i128); } @@ -3467,7 +3521,10 @@ macro_rules! doit { } })*) } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } + +#[cfg(i128_type)] +doit! { i128 u128 } fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; @@ -3602,38 +3659,50 @@ macro_rules! impl_from { impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { u8, u128, #[unstable(feature = "i128", issue = "35118")] } impl_from! { u8, usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u16, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u16, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { u16, u128, #[unstable(feature = "i128", issue = "35118")] } impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { u32, u128, #[unstable(feature = "i128", issue = "35118")] } +#[cfg(i128_type)] impl_from! { u64, u128, #[unstable(feature = "i128", issue = "35118")] } // Signed -> Signed impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { i8, i128, #[unstable(feature = "i128", issue = "35118")] } impl_from! { i8, isize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { i16, i128, #[unstable(feature = "i128", issue = "35118")] } impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { i32, i128, #[unstable(feature = "i128", issue = "35118")] } +#[cfg(i128_type)] impl_from! { i64, i128, #[unstable(feature = "i128", issue = "35118")] } // Unsigned -> Signed impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { u8, i128, #[unstable(feature = "i128", issue = "35118")] } impl_from! { u16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { u16, i128, #[unstable(feature = "i128", issue = "35118")] } impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +#[cfg(i128_type)] impl_from! { u32, i128, #[unstable(feature = "i128", issue = "35118")] } +#[cfg(i128_type)] impl_from! { u64, i128, #[unstable(feature = "i128", issue = "35118")] } // Note: integers can only be represented with full precision in a float if diff --git a/core/num/u128.rs b/core/num/u128.rs index 987ac3e..2413c80 100644 --- a/core/num/u128.rs +++ b/core/num/u128.rs @@ -13,4 +13,5 @@ //! *[See also the `u128` primitive type](../../std/primitive.u128.html).* #![unstable(feature = "i128", issue="35118")] +#[cfg(i128_type)] uint_module! { u128, #[unstable(feature = "i128", issue="35118")] } diff --git a/core/num/wrapping.rs b/core/num/wrapping.rs index ae1b0b3..2db24fa 100644 --- a/core/num/wrapping.rs +++ b/core/num/wrapping.rs @@ -320,7 +320,10 @@ macro_rules! wrapping_impl { )*) } -wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +wrapping_impl! { u128 i128 } mod shift_max { #![allow(non_upper_case_globals)] diff --git a/core/ops/arith.rs b/core/ops/arith.rs index 88db019..4942148 100644 --- a/core/ops/arith.rs +++ b/core/ops/arith.rs @@ -112,7 +112,10 @@ macro_rules! add_impl { )*) } -add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +add_impl! { u128 i128 } /// The subtraction operator `-`. /// @@ -208,7 +211,10 @@ macro_rules! sub_impl { )*) } -sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +sub_impl! { u128 i128 } /// The multiplication operator `*`. /// @@ -326,7 +332,10 @@ macro_rules! mul_impl { )*) } -mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +mul_impl! { u128 i128 } /// The division operator `/`. /// @@ -449,7 +458,10 @@ macro_rules! div_impl_integer { )*) } -div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +div_impl_integer! { u128 i128 } macro_rules! div_impl_float { ($($t:ty)*) => ($( @@ -532,8 +544,10 @@ macro_rules! rem_impl_integer { )*) } -rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } +#[cfg(i128_type)] +rem_impl_integer! { u128 i128 } macro_rules! rem_impl_float { ($($t:ty)*) => ($( @@ -629,7 +643,10 @@ macro_rules! neg_impl_unsigned { } // neg_impl_unsigned! { usize u8 u16 u32 u64 } -neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } +neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +neg_impl_numeric! { i128 } /// The addition assignment operator `+=`. /// @@ -683,7 +700,10 @@ macro_rules! add_assign_impl { )+) } -add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +add_assign_impl! { u128 i128 } /// The subtraction assignment operator `-=`. /// @@ -737,7 +757,10 @@ macro_rules! sub_assign_impl { )+) } -sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +sub_assign_impl! { u128 i128 } /// The multiplication assignment operator `*=`. /// @@ -782,7 +805,10 @@ macro_rules! mul_assign_impl { )+) } -mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +mul_assign_impl! { u128 i128 } /// The division assignment operator `/=`. /// @@ -826,7 +852,10 @@ macro_rules! div_assign_impl { )+) } -div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +div_assign_impl! { u128 i128 } /// The remainder assignment operator `%=`. /// @@ -874,4 +903,7 @@ macro_rules! rem_assign_impl { )+) } -rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + +#[cfg(i128_type)] +rem_assign_impl! { u128 i128 } diff --git a/core/ops/bit.rs b/core/ops/bit.rs index a0ecd6c..8167637 100644 --- a/core/ops/bit.rs +++ b/core/ops/bit.rs @@ -64,7 +64,10 @@ macro_rules! not_impl { )*) } -not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +not_impl! { u128 i128 } /// The bitwise AND operator `&`. /// @@ -146,7 +149,10 @@ macro_rules! bitand_impl { )*) } -bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +bitand_impl! { u128 i128 } /// The bitwise OR operator `|`. /// @@ -228,7 +234,10 @@ macro_rules! bitor_impl { )*) } -bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +bitor_impl! { u128 i128 } /// The bitwise XOR operator `^`. /// @@ -313,7 +322,10 @@ macro_rules! bitxor_impl { )*) } -bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +bitxor_impl! { u128 i128 } /// The left shift operator `<<`. /// @@ -403,6 +415,7 @@ macro_rules! shl_impl_all { shl_impl! { $t, u16 } shl_impl! { $t, u32 } shl_impl! { $t, u64 } + #[cfg(i128_type)] shl_impl! { $t, u128 } shl_impl! { $t, usize } @@ -410,12 +423,16 @@ macro_rules! shl_impl_all { shl_impl! { $t, i16 } shl_impl! { $t, i32 } shl_impl! { $t, i64 } + #[cfg(i128_type)] shl_impl! { $t, i128 } shl_impl! { $t, isize } )*) } -shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } +shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + +#[cfg(i128_type)] +shl_impl_all! { u128 i128 } /// The right shift operator `>>`. /// @@ -505,6 +522,7 @@ macro_rules! shr_impl_all { shr_impl! { $t, u16 } shr_impl! { $t, u32 } shr_impl! { $t, u64 } + #[cfg(i128_type)] shr_impl! { $t, u128 } shr_impl! { $t, usize } @@ -512,12 +530,16 @@ macro_rules! shr_impl_all { shr_impl! { $t, i16 } shr_impl! { $t, i32 } shr_impl! { $t, i64 } + #[cfg(i128_type)] shr_impl! { $t, i128 } shr_impl! { $t, isize } )*) } -shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + +#[cfg(i128_type)] +shr_impl_all! { u128 i128 } /// The bitwise AND assignment operator `&=`. /// @@ -604,7 +626,10 @@ macro_rules! bitand_assign_impl { )+) } -bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +bitand_assign_impl! { u128 i128 } /// The bitwise OR assignment operator `|=`. /// @@ -652,7 +677,10 @@ macro_rules! bitor_assign_impl { )+) } -bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +bitor_assign_impl! { u128 i128 } /// The bitwise XOR assignment operator `^=`. /// @@ -700,7 +728,10 @@ macro_rules! bitxor_assign_impl { )+) } -bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + +#[cfg(i128_type)] +bitxor_assign_impl! { u128 i128 } /// The left shift assignment operator `<<=`. /// @@ -755,6 +786,7 @@ macro_rules! shl_assign_impl_all { shl_assign_impl! { $t, u16 } shl_assign_impl! { $t, u32 } shl_assign_impl! { $t, u64 } + #[cfg(i128_type)] shl_assign_impl! { $t, u128 } shl_assign_impl! { $t, usize } @@ -762,12 +794,16 @@ macro_rules! shl_assign_impl_all { shl_assign_impl! { $t, i16 } shl_assign_impl! { $t, i32 } shl_assign_impl! { $t, i64 } + #[cfg(i128_type)] shl_assign_impl! { $t, i128 } shl_assign_impl! { $t, isize } )*) } -shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + +#[cfg(i128_type)] +shl_assign_impl_all! { u128 i128 } /// The right shift assignment operator `>>=`. /// @@ -822,6 +858,7 @@ macro_rules! shr_assign_impl_all { shr_assign_impl! { $t, u16 } shr_assign_impl! { $t, u32 } shr_assign_impl! { $t, u64 } + #[cfg(i128_type)] shr_assign_impl! { $t, u128 } shr_assign_impl! { $t, usize } @@ -829,9 +866,13 @@ macro_rules! shr_assign_impl_all { shr_assign_impl! { $t, i16 } shr_assign_impl! { $t, i32 } shr_assign_impl! { $t, i64 } + #[cfg(i128_type)] shr_assign_impl! { $t, i128 } shr_assign_impl! { $t, isize } )*) } -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + +#[cfg(i128_type)] +shr_assign_impl_all! { u128 i128 }