Browse Source

Assume i128 support

Josh Stone 2 years ago
parent
commit
4fc497fe9e
19 changed files with 29 additions and 160 deletions
  1. 1 1
      .github/workflows/ci.yaml
  2. 2 0
      Cargo.toml
  3. 0 4
      README.md
  4. 0 6
      build.rs
  5. 0 1
      ci/test_full.sh
  6. 2 7
      src/bounds.rs
  7. 4 40
      src/cast.rs
  8. 0 4
      src/identities.rs
  9. 0 3
      src/int.rs
  10. 2 3
      src/lib.rs
  11. 0 16
      src/ops/checked.rs
  12. 6 14
      src/ops/euclid.rs
  13. 4 6
      src/ops/mul_add.rs
  14. 2 10
      src/ops/overflowing.rs
  15. 2 9
      src/ops/saturating.rs
  16. 0 12
      src/ops/wrapping.rs
  17. 0 10
      src/pow.rs
  18. 2 7
      src/sign.rs
  19. 2 7
      tests/cast.rs

+ 1 - 1
.github/workflows/ci.yaml

@@ -44,7 +44,7 @@ jobs:
       - uses: dtolnay/rust-toolchain@stable
         with:
           target: thumbv6m-none-eabi
-      - run: cargo build --target thumbv6m-none-eabi --no-default-features --features i128
+      - run: cargo build --target thumbv6m-none-eabi --no-default-features
       - run: cargo build --target thumbv6m-none-eabi --no-default-features --features libm
 
   fmt:

+ 2 - 0
Cargo.toml

@@ -24,6 +24,8 @@ libm = { version = "0.2.0", optional = true }
 [features]
 default = ["std"]
 std = []
+
+# vestigial features, now always in effect
 i128 = []
 
 [build-dependencies]

+ 0 - 4
README.md

@@ -35,10 +35,6 @@ The `FloatCore` trait is always available.  `MulAdd` and `MulAddAssign` for `f32
 and `f64` also require `std` or `libm`, as do implementations of signed and floating-
 point exponents in `Pow`.
 
-Implementations for `i128` and `u128` are only available with Rust 1.26 and
-later.  The build script automatically detects this, but you can make it
-mandatory by enabling the `i128` crate feature.
-
 ## Releases
 
 Release notes are available in [RELEASES.md](RELEASES.md).

+ 0 - 6
build.rs

@@ -3,12 +3,6 @@ use std::env;
 fn main() {
     let ac = autocfg::new();
 
-    // If the "i128" feature is explicity requested, don't bother probing for it.
-    // It will still cause a build error if that was set improperly.
-    if env::var_os("CARGO_FEATURE_I128").is_some() || ac.probe_type("i128") {
-        autocfg::emit("has_i128");
-    }
-
     ac.emit_expression_cfg(
         "unsafe { 1f64.to_int_unchecked::<i32>() }",
         "has_to_int_unchecked",

+ 0 - 1
ci/test_full.sh

@@ -28,7 +28,6 @@ if ! check_version $MSRV ; then
 fi
 
 FEATURES=()
-check_version 1.26 && FEATURES+=(i128)
 check_version 1.27 && FEATURES+=(libm)
 echo "Testing supported features: ${FEATURES[*]}"
 

+ 2 - 7
src/bounds.rs

@@ -1,9 +1,7 @@
 use core::num::Wrapping;
 use core::{f32, f64};
-#[cfg(has_i128)]
-use core::{i128, u128};
-use core::{i16, i32, i64, i8, isize};
-use core::{u16, u32, u64, u8, usize};
+use core::{i128, i16, i32, i64, i8, isize};
+use core::{u128, u16, u32, u64, u8, usize};
 
 /// Numbers which have upper and lower bounds
 pub trait Bounded {
@@ -61,7 +59,6 @@ bounded_impl!(u8, u8::MIN, u8::MAX);
 bounded_impl!(u16, u16::MIN, u16::MAX);
 bounded_impl!(u32, u32::MIN, u32::MAX);
 bounded_impl!(u64, u64::MIN, u64::MAX);
-#[cfg(has_i128)]
 bounded_impl!(u128, u128::MIN, u128::MAX);
 
 bounded_impl!(isize, isize::MIN, isize::MAX);
@@ -69,7 +66,6 @@ bounded_impl!(i8, i8::MIN, i8::MAX);
 bounded_impl!(i16, i16::MIN, i16::MAX);
 bounded_impl!(i32, i32::MIN, i32::MAX);
 bounded_impl!(i64, i64::MIN, i64::MAX);
-#[cfg(has_i128)]
 bounded_impl!(i128, i128::MIN, i128::MAX);
 
 impl<T: Bounded> Bounded for Wrapping<T> {
@@ -130,7 +126,6 @@ fn wrapping_bounded() {
     test_wrapping_bounded!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
 }
 
-#[cfg(has_i128)]
 #[test]
 fn wrapping_bounded_i128() {
     macro_rules! test_wrapping_bounded {

+ 4 - 40
src/cast.rs

@@ -1,10 +1,8 @@
 use core::mem::size_of;
 use core::num::Wrapping;
 use core::{f32, f64};
-#[cfg(has_i128)]
-use core::{i128, u128};
-use core::{i16, i32, i64, i8, isize};
-use core::{u16, u32, u64, u8, usize};
+use core::{i128, i16, i32, i64, i8, isize};
+use core::{u128, u16, u32, u64, u8, usize};
 
 /// A generic trait for converting a value to a number.
 ///
@@ -53,12 +51,9 @@ pub trait ToPrimitive {
     /// represented by an `i128` (`i64` under the default implementation), then
     /// `None` is returned.
     ///
-    /// This method is only available with feature `i128` enabled on Rust >= 1.26.
-    ///
     /// The default implementation converts through `to_i64()`. Types implementing
     /// this trait should override this method if they can represent a greater range.
     #[inline]
-    #[cfg(has_i128)]
     fn to_i128(&self) -> Option<i128> {
         self.to_i64().map(From::from)
     }
@@ -99,12 +94,9 @@ pub trait ToPrimitive {
     /// represented by a `u128` (`u64` under the default implementation), then
     /// `None` is returned.
     ///
-    /// This method is only available with feature `i128` enabled on Rust >= 1.26.
-    ///
     /// The default implementation converts through `to_u64()`. Types implementing
     /// this trait should override this method if they can represent a greater range.
     #[inline]
-    #[cfg(has_i128)]
     fn to_u128(&self) -> Option<u128> {
         self.to_u64().map(From::from)
     }
@@ -173,7 +165,6 @@ macro_rules! impl_to_primitive_int {
                 fn to_i16 -> i16;
                 fn to_i32 -> i32;
                 fn to_i64 -> i64;
-                #[cfg(has_i128)]
                 fn to_i128 -> i128;
             }
 
@@ -183,7 +174,6 @@ macro_rules! impl_to_primitive_int {
                 fn to_u16 -> u16;
                 fn to_u32 -> u32;
                 fn to_u64 -> u64;
-                #[cfg(has_i128)]
                 fn to_u128 -> u128;
             }
 
@@ -204,7 +194,6 @@ impl_to_primitive_int!(i8);
 impl_to_primitive_int!(i16);
 impl_to_primitive_int!(i32);
 impl_to_primitive_int!(i64);
-#[cfg(has_i128)]
 impl_to_primitive_int!(i128);
 
 macro_rules! impl_to_primitive_uint_to_int {
@@ -246,7 +235,6 @@ macro_rules! impl_to_primitive_uint {
                 fn to_i16 -> i16;
                 fn to_i32 -> i32;
                 fn to_i64 -> i64;
-                #[cfg(has_i128)]
                 fn to_i128 -> i128;
             }
 
@@ -256,7 +244,6 @@ macro_rules! impl_to_primitive_uint {
                 fn to_u16 -> u16;
                 fn to_u32 -> u32;
                 fn to_u64 -> u64;
-                #[cfg(has_i128)]
                 fn to_u128 -> u128;
             }
 
@@ -277,7 +264,6 @@ impl_to_primitive_uint!(u8);
 impl_to_primitive_uint!(u16);
 impl_to_primitive_uint!(u32);
 impl_to_primitive_uint!(u64);
-#[cfg(has_i128)]
 impl_to_primitive_uint!(u128);
 
 macro_rules! impl_to_primitive_float_to_float {
@@ -373,7 +359,6 @@ macro_rules! impl_to_primitive_float {
                 fn to_i16 -> i16;
                 fn to_i32 -> i32;
                 fn to_i64 -> i64;
-                #[cfg(has_i128)]
                 fn to_i128 -> i128;
             }
 
@@ -383,7 +368,6 @@ macro_rules! impl_to_primitive_float {
                 fn to_u16 -> u16;
                 fn to_u32 -> u32;
                 fn to_u64 -> u64;
-                #[cfg(has_i128)]
                 fn to_u128 -> u128;
             }
 
@@ -444,12 +428,9 @@ pub trait FromPrimitive: Sized {
     /// Converts an `i128` to return an optional value of this type. If the
     /// value cannot be represented by this type, then `None` is returned.
     ///
-    /// This method is only available with feature `i128` enabled on Rust >= 1.26.
-    ///
     /// The default implementation converts through `from_i64()`. Types implementing
     /// this trait should override this method if they can represent a greater range.
     #[inline]
-    #[cfg(has_i128)]
     fn from_i128(n: i128) -> Option<Self> {
         n.to_i64().and_then(FromPrimitive::from_i64)
     }
@@ -489,12 +470,9 @@ pub trait FromPrimitive: Sized {
     /// Converts an `u128` to return an optional value of this type. If the
     /// value cannot be represented by this type, then `None` is returned.
     ///
-    /// This method is only available with feature `i128` enabled on Rust >= 1.26.
-    ///
     /// The default implementation converts through `from_u64()`. Types implementing
     /// this trait should override this method if they can represent a greater range.
     #[inline]
-    #[cfg(has_i128)]
     fn from_u128(n: u128) -> Option<Self> {
         n.to_u64().and_then(FromPrimitive::from_u64)
     }
@@ -545,7 +523,6 @@ macro_rules! impl_from_primitive {
             fn from_i64(n: i64) -> Option<$T> {
                 n.$to_ty()
             }
-            #[cfg(has_i128)]
             #[inline]
             fn from_i128(n: i128) -> Option<$T> {
                 n.$to_ty()
@@ -571,7 +548,6 @@ macro_rules! impl_from_primitive {
             fn from_u64(n: u64) -> Option<$T> {
                 n.$to_ty()
             }
-            #[cfg(has_i128)]
             #[inline]
             fn from_u128(n: u128) -> Option<$T> {
                 n.$to_ty()
@@ -594,14 +570,12 @@ impl_from_primitive!(i8, to_i8);
 impl_from_primitive!(i16, to_i16);
 impl_from_primitive!(i32, to_i32);
 impl_from_primitive!(i64, to_i64);
-#[cfg(has_i128)]
 impl_from_primitive!(i128, to_i128);
 impl_from_primitive!(usize, to_usize);
 impl_from_primitive!(u8, to_u8);
 impl_from_primitive!(u16, to_u16);
 impl_from_primitive!(u32, to_u32);
 impl_from_primitive!(u64, to_u64);
-#[cfg(has_i128)]
 impl_from_primitive!(u128, to_u128);
 impl_from_primitive!(f32, to_f32);
 impl_from_primitive!(f64, to_f64);
@@ -623,7 +597,6 @@ impl<T: ToPrimitive> ToPrimitive for Wrapping<T> {
         fn to_i16 -> i16;
         fn to_i32 -> i32;
         fn to_i64 -> i64;
-        #[cfg(has_i128)]
         fn to_i128 -> i128;
 
         fn to_usize -> usize;
@@ -631,7 +604,6 @@ impl<T: ToPrimitive> ToPrimitive for Wrapping<T> {
         fn to_u16 -> u16;
         fn to_u32 -> u32;
         fn to_u64 -> u64;
-        #[cfg(has_i128)]
         fn to_u128 -> u128;
 
         fn to_f32 -> f32;
@@ -656,7 +628,6 @@ impl<T: FromPrimitive> FromPrimitive for Wrapping<T> {
         fn from_i16(i16);
         fn from_i32(i32);
         fn from_i64(i64);
-        #[cfg(has_i128)]
         fn from_i128(i128);
 
         fn from_usize(usize);
@@ -664,7 +635,6 @@ impl<T: FromPrimitive> FromPrimitive for Wrapping<T> {
         fn from_u16(u16);
         fn from_u32(u32);
         fn from_u64(u64);
-        #[cfg(has_i128)]
         fn from_u128(u128);
 
         fn from_f32(f32);
@@ -722,14 +692,12 @@ impl_num_cast!(u8, to_u8);
 impl_num_cast!(u16, to_u16);
 impl_num_cast!(u32, to_u32);
 impl_num_cast!(u64, to_u64);
-#[cfg(has_i128)]
 impl_num_cast!(u128, to_u128);
 impl_num_cast!(usize, to_usize);
 impl_num_cast!(i8, to_i8);
 impl_num_cast!(i16, to_i16);
 impl_num_cast!(i32, to_i32);
 impl_num_cast!(i64, to_i64);
-#[cfg(has_i128)]
 impl_num_cast!(i128, to_i128);
 impl_num_cast!(isize, to_isize);
 impl_num_cast!(f32, to_f32);
@@ -787,10 +755,8 @@ macro_rules! impl_as_primitive {
     )*};
     ($T: ty => { $( $U: ty ),* } ) => {
         impl_as_primitive!(@ $T => { $( $U ),* });
-        impl_as_primitive!(@ $T => { u8, u16, u32, u64, usize });
-        impl_as_primitive!(@ $T => #[cfg(has_i128)] impl u128);
-        impl_as_primitive!(@ $T => { i8, i16, i32, i64, isize });
-        impl_as_primitive!(@ $T => #[cfg(has_i128)] impl i128);
+        impl_as_primitive!(@ $T => { u8, u16, u32, u64, u128, usize });
+        impl_as_primitive!(@ $T => { i8, i16, i32, i64, i128, isize });
     };
 }
 
@@ -802,9 +768,7 @@ impl_as_primitive!(u32 => { f32, f64 });
 impl_as_primitive!(i32 => { f32, f64 });
 impl_as_primitive!(u64 => { f32, f64 });
 impl_as_primitive!(i64 => { f32, f64 });
-#[cfg(has_i128)]
 impl_as_primitive!(u128 => { f32, f64 });
-#[cfg(has_i128)]
 impl_as_primitive!(i128 => { f32, f64 });
 impl_as_primitive!(usize => { f32, f64 });
 impl_as_primitive!(isize => { f32, f64 });

+ 0 - 4
src/identities.rs

@@ -48,7 +48,6 @@ zero_impl!(u8, 0);
 zero_impl!(u16, 0);
 zero_impl!(u32, 0);
 zero_impl!(u64, 0);
-#[cfg(has_i128)]
 zero_impl!(u128, 0);
 
 zero_impl!(isize, 0);
@@ -56,7 +55,6 @@ zero_impl!(i8, 0);
 zero_impl!(i16, 0);
 zero_impl!(i32, 0);
 zero_impl!(i64, 0);
-#[cfg(has_i128)]
 zero_impl!(i128, 0);
 
 zero_impl!(f32, 0.0);
@@ -137,7 +135,6 @@ one_impl!(u8, 1);
 one_impl!(u16, 1);
 one_impl!(u32, 1);
 one_impl!(u64, 1);
-#[cfg(has_i128)]
 one_impl!(u128, 1);
 
 one_impl!(isize, 1);
@@ -145,7 +142,6 @@ one_impl!(i8, 1);
 one_impl!(i16, 1);
 one_impl!(i32, 1);
 one_impl!(i64, 1);
-#[cfg(has_i128)]
 one_impl!(i128, 1);
 
 one_impl!(f32, 1.0);

+ 0 - 3
src/int.rs

@@ -500,14 +500,12 @@ prim_int_impl!(u8, i8, u8);
 prim_int_impl!(u16, i16, u16);
 prim_int_impl!(u32, i32, u32);
 prim_int_impl!(u64, i64, u64);
-#[cfg(has_i128)]
 prim_int_impl!(u128, i128, u128);
 prim_int_impl!(usize, isize, usize);
 prim_int_impl!(i8, i8, u8);
 prim_int_impl!(i16, i16, u16);
 prim_int_impl!(i32, i32, u32);
 prim_int_impl!(i64, i64, u64);
-#[cfg(has_i128)]
 prim_int_impl!(i128, i128, u128);
 prim_int_impl!(isize, isize, usize);
 
@@ -554,7 +552,6 @@ mod tests {
     }
 
     #[test]
-    #[cfg(has_i128)]
     pub fn reverse_bits_i128() {
         use core::i128;
 

+ 2 - 3
src/lib.rs

@@ -172,9 +172,8 @@ macro_rules! int_trait_impl {
         }
     )*)
 }
-int_trait_impl!(Num for usize u8 u16 u32 u64 isize i8 i16 i32 i64);
-#[cfg(has_i128)]
-int_trait_impl!(Num for u128 i128);
+int_trait_impl!(Num for usize u8 u16 u32 u64 u128);
+int_trait_impl!(Num for isize i8 i16 i32 i64 i128);
 
 impl<T: Num> Num for Wrapping<T>
 where

+ 0 - 16
src/ops/checked.rs

@@ -24,7 +24,6 @@ checked_impl!(CheckedAdd, checked_add, u16);
 checked_impl!(CheckedAdd, checked_add, u32);
 checked_impl!(CheckedAdd, checked_add, u64);
 checked_impl!(CheckedAdd, checked_add, usize);
-#[cfg(has_i128)]
 checked_impl!(CheckedAdd, checked_add, u128);
 
 checked_impl!(CheckedAdd, checked_add, i8);
@@ -32,7 +31,6 @@ checked_impl!(CheckedAdd, checked_add, i16);
 checked_impl!(CheckedAdd, checked_add, i32);
 checked_impl!(CheckedAdd, checked_add, i64);
 checked_impl!(CheckedAdd, checked_add, isize);
-#[cfg(has_i128)]
 checked_impl!(CheckedAdd, checked_add, i128);
 
 /// Performs subtraction that returns `None` instead of wrapping around on underflow.
@@ -47,7 +45,6 @@ checked_impl!(CheckedSub, checked_sub, u16);
 checked_impl!(CheckedSub, checked_sub, u32);
 checked_impl!(CheckedSub, checked_sub, u64);
 checked_impl!(CheckedSub, checked_sub, usize);
-#[cfg(has_i128)]
 checked_impl!(CheckedSub, checked_sub, u128);
 
 checked_impl!(CheckedSub, checked_sub, i8);
@@ -55,7 +52,6 @@ checked_impl!(CheckedSub, checked_sub, i16);
 checked_impl!(CheckedSub, checked_sub, i32);
 checked_impl!(CheckedSub, checked_sub, i64);
 checked_impl!(CheckedSub, checked_sub, isize);
-#[cfg(has_i128)]
 checked_impl!(CheckedSub, checked_sub, i128);
 
 /// Performs multiplication that returns `None` instead of wrapping around on underflow or
@@ -71,7 +67,6 @@ checked_impl!(CheckedMul, checked_mul, u16);
 checked_impl!(CheckedMul, checked_mul, u32);
 checked_impl!(CheckedMul, checked_mul, u64);
 checked_impl!(CheckedMul, checked_mul, usize);
-#[cfg(has_i128)]
 checked_impl!(CheckedMul, checked_mul, u128);
 
 checked_impl!(CheckedMul, checked_mul, i8);
@@ -79,7 +74,6 @@ checked_impl!(CheckedMul, checked_mul, i16);
 checked_impl!(CheckedMul, checked_mul, i32);
 checked_impl!(CheckedMul, checked_mul, i64);
 checked_impl!(CheckedMul, checked_mul, isize);
-#[cfg(has_i128)]
 checked_impl!(CheckedMul, checked_mul, i128);
 
 /// Performs division that returns `None` instead of panicking on division by zero and instead of
@@ -95,7 +89,6 @@ checked_impl!(CheckedDiv, checked_div, u16);
 checked_impl!(CheckedDiv, checked_div, u32);
 checked_impl!(CheckedDiv, checked_div, u64);
 checked_impl!(CheckedDiv, checked_div, usize);
-#[cfg(has_i128)]
 checked_impl!(CheckedDiv, checked_div, u128);
 
 checked_impl!(CheckedDiv, checked_div, i8);
@@ -103,7 +96,6 @@ checked_impl!(CheckedDiv, checked_div, i16);
 checked_impl!(CheckedDiv, checked_div, i32);
 checked_impl!(CheckedDiv, checked_div, i64);
 checked_impl!(CheckedDiv, checked_div, isize);
-#[cfg(has_i128)]
 checked_impl!(CheckedDiv, checked_div, i128);
 
 /// Performs an integral remainder that returns `None` instead of panicking on division by zero and
@@ -136,7 +128,6 @@ checked_impl!(CheckedRem, checked_rem, u16);
 checked_impl!(CheckedRem, checked_rem, u32);
 checked_impl!(CheckedRem, checked_rem, u64);
 checked_impl!(CheckedRem, checked_rem, usize);
-#[cfg(has_i128)]
 checked_impl!(CheckedRem, checked_rem, u128);
 
 checked_impl!(CheckedRem, checked_rem, i8);
@@ -144,7 +135,6 @@ checked_impl!(CheckedRem, checked_rem, i16);
 checked_impl!(CheckedRem, checked_rem, i32);
 checked_impl!(CheckedRem, checked_rem, i64);
 checked_impl!(CheckedRem, checked_rem, isize);
-#[cfg(has_i128)]
 checked_impl!(CheckedRem, checked_rem, i128);
 
 macro_rules! checked_impl_unary {
@@ -184,7 +174,6 @@ checked_impl_unary!(CheckedNeg, checked_neg, u16);
 checked_impl_unary!(CheckedNeg, checked_neg, u32);
 checked_impl_unary!(CheckedNeg, checked_neg, u64);
 checked_impl_unary!(CheckedNeg, checked_neg, usize);
-#[cfg(has_i128)]
 checked_impl_unary!(CheckedNeg, checked_neg, u128);
 
 checked_impl_unary!(CheckedNeg, checked_neg, i8);
@@ -192,7 +181,6 @@ checked_impl_unary!(CheckedNeg, checked_neg, i16);
 checked_impl_unary!(CheckedNeg, checked_neg, i32);
 checked_impl_unary!(CheckedNeg, checked_neg, i64);
 checked_impl_unary!(CheckedNeg, checked_neg, isize);
-#[cfg(has_i128)]
 checked_impl_unary!(CheckedNeg, checked_neg, i128);
 
 /// Performs a left shift that returns `None` on shifts larger than
@@ -230,7 +218,6 @@ checked_shift_impl!(CheckedShl, checked_shl, u16);
 checked_shift_impl!(CheckedShl, checked_shl, u32);
 checked_shift_impl!(CheckedShl, checked_shl, u64);
 checked_shift_impl!(CheckedShl, checked_shl, usize);
-#[cfg(has_i128)]
 checked_shift_impl!(CheckedShl, checked_shl, u128);
 
 checked_shift_impl!(CheckedShl, checked_shl, i8);
@@ -238,7 +225,6 @@ checked_shift_impl!(CheckedShl, checked_shl, i16);
 checked_shift_impl!(CheckedShl, checked_shl, i32);
 checked_shift_impl!(CheckedShl, checked_shl, i64);
 checked_shift_impl!(CheckedShl, checked_shl, isize);
-#[cfg(has_i128)]
 checked_shift_impl!(CheckedShl, checked_shl, i128);
 
 /// Performs a right shift that returns `None` on shifts larger than
@@ -265,7 +251,6 @@ checked_shift_impl!(CheckedShr, checked_shr, u16);
 checked_shift_impl!(CheckedShr, checked_shr, u32);
 checked_shift_impl!(CheckedShr, checked_shr, u64);
 checked_shift_impl!(CheckedShr, checked_shr, usize);
-#[cfg(has_i128)]
 checked_shift_impl!(CheckedShr, checked_shr, u128);
 
 checked_shift_impl!(CheckedShr, checked_shr, i8);
@@ -273,5 +258,4 @@ checked_shift_impl!(CheckedShr, checked_shr, i16);
 checked_shift_impl!(CheckedShr, checked_shr, i32);
 checked_shift_impl!(CheckedShr, checked_shr, i64);
 checked_shift_impl!(CheckedShr, checked_shr, isize);
-#[cfg(has_i128)]
 checked_shift_impl!(CheckedShr, checked_shr, i128);

+ 6 - 14
src/ops/euclid.rs

@@ -116,12 +116,8 @@ macro_rules! euclid_uint_impl {
     )*}
 }
 
-euclid_int_impl!(isize i8 i16 i32 i64);
-euclid_uint_impl!(usize u8 u16 u32 u64);
-#[cfg(has_i128)]
-euclid_int_impl!(i128);
-#[cfg(has_i128)]
-euclid_uint_impl!(u128);
+euclid_int_impl!(isize i8 i16 i32 i64 i128);
+euclid_uint_impl!(usize u8 u16 u32 u64 u128);
 
 #[cfg(all(has_div_euclid, feature = "std"))]
 euclid_forward_impl!(f32 f64);
@@ -251,12 +247,8 @@ macro_rules! checked_euclid_uint_impl {
     )*}
 }
 
-checked_euclid_int_impl!(isize i8 i16 i32 i64);
-checked_euclid_uint_impl!(usize u8 u16 u32 u64);
-#[cfg(has_i128)]
-checked_euclid_int_impl!(i128);
-#[cfg(has_i128)]
-checked_euclid_uint_impl!(u128);
+checked_euclid_int_impl!(isize i8 i16 i32 i64 i128);
+checked_euclid_uint_impl!(usize u8 u16 u32 u64 u128);
 
 #[cfg(test)]
 mod tests {
@@ -300,7 +292,7 @@ mod tests {
             };
         }
 
-        test_euclid!(isize i8 i16 i32 i64);
+        test_euclid!(isize i8 i16 i32 i64 i128);
     }
 
     #[test]
@@ -342,6 +334,6 @@ mod tests {
             };
         }
 
-        test_euclid_checked!(isize i8 i16 i32 i64);
+        test_euclid_checked!(isize i8 i16 i32 i64 i128);
     }
 }

+ 4 - 6
src/ops/mul_add.rs

@@ -67,9 +67,8 @@ macro_rules! mul_add_impl {
     )*}
 }
 
-mul_add_impl!(MulAdd for isize usize i8 u8 i16 u16 i32 u32 i64 u64);
-#[cfg(has_i128)]
-mul_add_impl!(MulAdd for i128 u128);
+mul_add_impl!(MulAdd for isize i8 i16 i32 i64 i128);
+mul_add_impl!(MulAdd for usize u8 u16 u32 u64 u128);
 
 #[cfg(any(feature = "std", feature = "libm"))]
 impl MulAddAssign<f32, f32> for f32 {
@@ -98,9 +97,8 @@ macro_rules! mul_add_assign_impl {
     )*}
 }
 
-mul_add_assign_impl!(MulAddAssign for isize usize i8 u8 i16 u16 i32 u32 i64 u64);
-#[cfg(has_i128)]
-mul_add_assign_impl!(MulAddAssign for i128 u128);
+mul_add_assign_impl!(MulAddAssign for isize i8 i16 i32 i64 i128);
+mul_add_assign_impl!(MulAddAssign for usize u8 u16 u32 u64 u128);
 
 #[cfg(test)]
 mod tests {

+ 2 - 10
src/ops/overflowing.rs

@@ -1,8 +1,6 @@
 use core::ops::{Add, Mul, Sub};
-#[cfg(has_i128)]
-use core::{i128, u128};
-use core::{i16, i32, i64, i8, isize};
-use core::{u16, u32, u64, u8, usize};
+use core::{i128, i16, i32, i64, i8, isize};
+use core::{u128, u16, u32, u64, u8, usize};
 
 macro_rules! overflowing_impl {
     ($trait_name:ident, $method:ident, $t:ty) => {
@@ -27,7 +25,6 @@ overflowing_impl!(OverflowingAdd, overflowing_add, u16);
 overflowing_impl!(OverflowingAdd, overflowing_add, u32);
 overflowing_impl!(OverflowingAdd, overflowing_add, u64);
 overflowing_impl!(OverflowingAdd, overflowing_add, usize);
-#[cfg(has_i128)]
 overflowing_impl!(OverflowingAdd, overflowing_add, u128);
 
 overflowing_impl!(OverflowingAdd, overflowing_add, i8);
@@ -35,7 +32,6 @@ overflowing_impl!(OverflowingAdd, overflowing_add, i16);
 overflowing_impl!(OverflowingAdd, overflowing_add, i32);
 overflowing_impl!(OverflowingAdd, overflowing_add, i64);
 overflowing_impl!(OverflowingAdd, overflowing_add, isize);
-#[cfg(has_i128)]
 overflowing_impl!(OverflowingAdd, overflowing_add, i128);
 
 /// Performs substraction with a flag for overflow.
@@ -50,7 +46,6 @@ overflowing_impl!(OverflowingSub, overflowing_sub, u16);
 overflowing_impl!(OverflowingSub, overflowing_sub, u32);
 overflowing_impl!(OverflowingSub, overflowing_sub, u64);
 overflowing_impl!(OverflowingSub, overflowing_sub, usize);
-#[cfg(has_i128)]
 overflowing_impl!(OverflowingSub, overflowing_sub, u128);
 
 overflowing_impl!(OverflowingSub, overflowing_sub, i8);
@@ -58,7 +53,6 @@ overflowing_impl!(OverflowingSub, overflowing_sub, i16);
 overflowing_impl!(OverflowingSub, overflowing_sub, i32);
 overflowing_impl!(OverflowingSub, overflowing_sub, i64);
 overflowing_impl!(OverflowingSub, overflowing_sub, isize);
-#[cfg(has_i128)]
 overflowing_impl!(OverflowingSub, overflowing_sub, i128);
 
 /// Performs multiplication with a flag for overflow.
@@ -73,7 +67,6 @@ overflowing_impl!(OverflowingMul, overflowing_mul, u16);
 overflowing_impl!(OverflowingMul, overflowing_mul, u32);
 overflowing_impl!(OverflowingMul, overflowing_mul, u64);
 overflowing_impl!(OverflowingMul, overflowing_mul, usize);
-#[cfg(has_i128)]
 overflowing_impl!(OverflowingMul, overflowing_mul, u128);
 
 overflowing_impl!(OverflowingMul, overflowing_mul, i8);
@@ -81,7 +74,6 @@ overflowing_impl!(OverflowingMul, overflowing_mul, i16);
 overflowing_impl!(OverflowingMul, overflowing_mul, i32);
 overflowing_impl!(OverflowingMul, overflowing_mul, i64);
 overflowing_impl!(OverflowingMul, overflowing_mul, isize);
-#[cfg(has_i128)]
 overflowing_impl!(OverflowingMul, overflowing_mul, i128);
 
 #[test]

+ 2 - 9
src/ops/saturating.rs

@@ -28,9 +28,8 @@ macro_rules! deprecated_saturating_impl {
     )*}
 }
 
-deprecated_saturating_impl!(Saturating for isize usize i8 u8 i16 u16 i32 u32 i64 u64);
-#[cfg(has_i128)]
-deprecated_saturating_impl!(Saturating for i128 u128);
+deprecated_saturating_impl!(Saturating for isize i8 i16 i32 i64 i128);
+deprecated_saturating_impl!(Saturating for usize u8 u16 u32 u64 u128);
 
 macro_rules! saturating_impl {
     ($trait_name:ident, $method:ident, $t:ty) => {
@@ -55,7 +54,6 @@ saturating_impl!(SaturatingAdd, saturating_add, u16);
 saturating_impl!(SaturatingAdd, saturating_add, u32);
 saturating_impl!(SaturatingAdd, saturating_add, u64);
 saturating_impl!(SaturatingAdd, saturating_add, usize);
-#[cfg(has_i128)]
 saturating_impl!(SaturatingAdd, saturating_add, u128);
 
 saturating_impl!(SaturatingAdd, saturating_add, i8);
@@ -63,7 +61,6 @@ saturating_impl!(SaturatingAdd, saturating_add, i16);
 saturating_impl!(SaturatingAdd, saturating_add, i32);
 saturating_impl!(SaturatingAdd, saturating_add, i64);
 saturating_impl!(SaturatingAdd, saturating_add, isize);
-#[cfg(has_i128)]
 saturating_impl!(SaturatingAdd, saturating_add, i128);
 
 /// Performs subtraction that saturates at the numeric bounds instead of overflowing.
@@ -78,7 +75,6 @@ saturating_impl!(SaturatingSub, saturating_sub, u16);
 saturating_impl!(SaturatingSub, saturating_sub, u32);
 saturating_impl!(SaturatingSub, saturating_sub, u64);
 saturating_impl!(SaturatingSub, saturating_sub, usize);
-#[cfg(has_i128)]
 saturating_impl!(SaturatingSub, saturating_sub, u128);
 
 saturating_impl!(SaturatingSub, saturating_sub, i8);
@@ -86,7 +82,6 @@ saturating_impl!(SaturatingSub, saturating_sub, i16);
 saturating_impl!(SaturatingSub, saturating_sub, i32);
 saturating_impl!(SaturatingSub, saturating_sub, i64);
 saturating_impl!(SaturatingSub, saturating_sub, isize);
-#[cfg(has_i128)]
 saturating_impl!(SaturatingSub, saturating_sub, i128);
 
 /// Performs multiplication that saturates at the numeric bounds instead of overflowing.
@@ -101,7 +96,6 @@ saturating_impl!(SaturatingMul, saturating_mul, u16);
 saturating_impl!(SaturatingMul, saturating_mul, u32);
 saturating_impl!(SaturatingMul, saturating_mul, u64);
 saturating_impl!(SaturatingMul, saturating_mul, usize);
-#[cfg(has_i128)]
 saturating_impl!(SaturatingMul, saturating_mul, u128);
 
 saturating_impl!(SaturatingMul, saturating_mul, i8);
@@ -109,7 +103,6 @@ saturating_impl!(SaturatingMul, saturating_mul, i16);
 saturating_impl!(SaturatingMul, saturating_mul, i32);
 saturating_impl!(SaturatingMul, saturating_mul, i64);
 saturating_impl!(SaturatingMul, saturating_mul, isize);
-#[cfg(has_i128)]
 saturating_impl!(SaturatingMul, saturating_mul, i128);
 
 // TODO: add SaturatingNeg for signed integer primitives once the saturating_neg() API is stable.

+ 0 - 12
src/ops/wrapping.rs

@@ -32,7 +32,6 @@ wrapping_impl!(WrappingAdd, wrapping_add, u16);
 wrapping_impl!(WrappingAdd, wrapping_add, u32);
 wrapping_impl!(WrappingAdd, wrapping_add, u64);
 wrapping_impl!(WrappingAdd, wrapping_add, usize);
-#[cfg(has_i128)]
 wrapping_impl!(WrappingAdd, wrapping_add, u128);
 
 wrapping_impl!(WrappingAdd, wrapping_add, i8);
@@ -40,7 +39,6 @@ wrapping_impl!(WrappingAdd, wrapping_add, i16);
 wrapping_impl!(WrappingAdd, wrapping_add, i32);
 wrapping_impl!(WrappingAdd, wrapping_add, i64);
 wrapping_impl!(WrappingAdd, wrapping_add, isize);
-#[cfg(has_i128)]
 wrapping_impl!(WrappingAdd, wrapping_add, i128);
 
 /// Performs subtraction that wraps around on overflow.
@@ -55,7 +53,6 @@ wrapping_impl!(WrappingSub, wrapping_sub, u16);
 wrapping_impl!(WrappingSub, wrapping_sub, u32);
 wrapping_impl!(WrappingSub, wrapping_sub, u64);
 wrapping_impl!(WrappingSub, wrapping_sub, usize);
-#[cfg(has_i128)]
 wrapping_impl!(WrappingSub, wrapping_sub, u128);
 
 wrapping_impl!(WrappingSub, wrapping_sub, i8);
@@ -63,7 +60,6 @@ wrapping_impl!(WrappingSub, wrapping_sub, i16);
 wrapping_impl!(WrappingSub, wrapping_sub, i32);
 wrapping_impl!(WrappingSub, wrapping_sub, i64);
 wrapping_impl!(WrappingSub, wrapping_sub, isize);
-#[cfg(has_i128)]
 wrapping_impl!(WrappingSub, wrapping_sub, i128);
 
 /// Performs multiplication that wraps around on overflow.
@@ -78,7 +74,6 @@ wrapping_impl!(WrappingMul, wrapping_mul, u16);
 wrapping_impl!(WrappingMul, wrapping_mul, u32);
 wrapping_impl!(WrappingMul, wrapping_mul, u64);
 wrapping_impl!(WrappingMul, wrapping_mul, usize);
-#[cfg(has_i128)]
 wrapping_impl!(WrappingMul, wrapping_mul, u128);
 
 wrapping_impl!(WrappingMul, wrapping_mul, i8);
@@ -86,7 +81,6 @@ wrapping_impl!(WrappingMul, wrapping_mul, i16);
 wrapping_impl!(WrappingMul, wrapping_mul, i32);
 wrapping_impl!(WrappingMul, wrapping_mul, i64);
 wrapping_impl!(WrappingMul, wrapping_mul, isize);
-#[cfg(has_i128)]
 wrapping_impl!(WrappingMul, wrapping_mul, i128);
 
 macro_rules! wrapping_unary_impl {
@@ -127,14 +121,12 @@ wrapping_unary_impl!(WrappingNeg, wrapping_neg, u16);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, u32);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, u64);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, usize);
-#[cfg(has_i128)]
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, u128);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, i8);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, i16);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, i32);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, i64);
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, isize);
-#[cfg(has_i128)]
 wrapping_unary_impl!(WrappingNeg, wrapping_neg, i128);
 
 macro_rules! wrapping_shift_impl {
@@ -172,7 +164,6 @@ wrapping_shift_impl!(WrappingShl, wrapping_shl, u16);
 wrapping_shift_impl!(WrappingShl, wrapping_shl, u32);
 wrapping_shift_impl!(WrappingShl, wrapping_shl, u64);
 wrapping_shift_impl!(WrappingShl, wrapping_shl, usize);
-#[cfg(has_i128)]
 wrapping_shift_impl!(WrappingShl, wrapping_shl, u128);
 
 wrapping_shift_impl!(WrappingShl, wrapping_shl, i8);
@@ -180,7 +171,6 @@ wrapping_shift_impl!(WrappingShl, wrapping_shl, i16);
 wrapping_shift_impl!(WrappingShl, wrapping_shl, i32);
 wrapping_shift_impl!(WrappingShl, wrapping_shl, i64);
 wrapping_shift_impl!(WrappingShl, wrapping_shl, isize);
-#[cfg(has_i128)]
 wrapping_shift_impl!(WrappingShl, wrapping_shl, i128);
 
 /// Performs a right shift that does not panic.
@@ -207,7 +197,6 @@ wrapping_shift_impl!(WrappingShr, wrapping_shr, u16);
 wrapping_shift_impl!(WrappingShr, wrapping_shr, u32);
 wrapping_shift_impl!(WrappingShr, wrapping_shr, u64);
 wrapping_shift_impl!(WrappingShr, wrapping_shr, usize);
-#[cfg(has_i128)]
 wrapping_shift_impl!(WrappingShr, wrapping_shr, u128);
 
 wrapping_shift_impl!(WrappingShr, wrapping_shr, i8);
@@ -215,7 +204,6 @@ wrapping_shift_impl!(WrappingShr, wrapping_shr, i16);
 wrapping_shift_impl!(WrappingShr, wrapping_shr, i32);
 wrapping_shift_impl!(WrappingShr, wrapping_shr, i64);
 wrapping_shift_impl!(WrappingShr, wrapping_shr, isize);
-#[cfg(has_i128)]
 wrapping_shift_impl!(WrappingShr, wrapping_shr, i128);
 
 // Well this is a bit funny, but all the more appropriate.

+ 0 - 10
src/pow.rs

@@ -99,22 +99,14 @@ pow_impl!(i64, u16, u32, i64::pow);
 pow_impl!(i64, u32, u32, i64::pow);
 pow_impl!(i64, usize);
 
-#[cfg(has_i128)]
 pow_impl!(u128, u8, u32, u128::pow);
-#[cfg(has_i128)]
 pow_impl!(u128, u16, u32, u128::pow);
-#[cfg(has_i128)]
 pow_impl!(u128, u32, u32, u128::pow);
-#[cfg(has_i128)]
 pow_impl!(u128, usize);
 
-#[cfg(has_i128)]
 pow_impl!(i128, u8, u32, i128::pow);
-#[cfg(has_i128)]
 pow_impl!(i128, u16, u32, i128::pow);
-#[cfg(has_i128)]
 pow_impl!(i128, u32, u32, i128::pow);
-#[cfg(has_i128)]
 pow_impl!(i128, usize);
 
 pow_impl!(usize, u8, u32, usize::pow);
@@ -133,9 +125,7 @@ pow_impl!(Wrapping<u32>);
 pow_impl!(Wrapping<i32>);
 pow_impl!(Wrapping<u64>);
 pow_impl!(Wrapping<i64>);
-#[cfg(has_i128)]
 pow_impl!(Wrapping<u128>);
-#[cfg(has_i128)]
 pow_impl!(Wrapping<i128>);
 pow_impl!(Wrapping<usize>);
 pow_impl!(Wrapping<isize>);

+ 2 - 7
src/sign.rs

@@ -72,10 +72,7 @@ macro_rules! signed_impl {
     )*)
 }
 
-signed_impl!(isize i8 i16 i32 i64);
-
-#[cfg(has_i128)]
-signed_impl!(i128);
+signed_impl!(isize i8 i16 i32 i64 i128);
 
 impl<T: Signed> Signed for Wrapping<T>
 where
@@ -202,9 +199,7 @@ macro_rules! empty_trait_impl {
     )*)
 }
 
-empty_trait_impl!(Unsigned for usize u8 u16 u32 u64);
-#[cfg(has_i128)]
-empty_trait_impl!(Unsigned for u128);
+empty_trait_impl!(Unsigned for usize u8 u16 u32 u64 u128);
 
 impl<T: Unsigned> Unsigned for Wrapping<T> where Wrapping<T>: Num {}
 

+ 2 - 7
tests/cast.rs

@@ -10,10 +10,8 @@ use num_traits::cast::*;
 use num_traits::Bounded;
 
 use core::{f32, f64};
-#[cfg(has_i128)]
-use core::{i128, u128};
-use core::{i16, i32, i64, i8, isize};
-use core::{u16, u32, u64, u8, usize};
+use core::{i128, i16, i32, i64, i8, isize};
+use core::{u128, u16, u32, u64, u8, usize};
 
 use core::fmt::Debug;
 use core::mem;
@@ -145,7 +143,6 @@ fn cast_to_unsigned_int_checks_overflow() {
 }
 
 #[test]
-#[cfg(has_i128)]
 fn cast_to_i128_checks_overflow() {
     let big_f: f64 = 1.0e123;
     let normal_f: f64 = 1.0;
@@ -241,7 +238,6 @@ fn cast_float_to_int_edge_cases() {
 }
 
 #[test]
-#[cfg(has_i128)]
 fn cast_float_to_i128_edge_cases() {
     float_test_edge!(f32 -> i128 u128);
     float_test_edge!(f64 -> i128 u128);
@@ -300,7 +296,6 @@ fn cast_int_to_int_edge_cases() {
 }
 
 #[test]
-#[cfg(has_i128)]
 fn cast_int_to_128_edge_cases() {
     use core::cmp::Ordering::*;