From 04f8ba2ece3de0892e826db86f491f044e06d24c Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sat, 30 Apr 2016 03:40:34 +0300 Subject: [PATCH] Impl int/uint::MIN/MAX in terms of min/max_value --- src/libcore/num/int_macros.rs | 13 +++++++++++++ src/libcore/num/uint_macros.rs | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index 42349257ab7..fb1a3bbe3b4 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -10,6 +10,7 @@ #![doc(hidden)] +#[cfg(stage0)] macro_rules! int_module { ($T:ty, $bits:expr) => ( // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of @@ -25,3 +26,15 @@ pub const MIN: $T = (-1 as $T) << ($bits - 1); pub const MAX: $T = !MIN; ) } + +#[cfg(not(stage0))] +macro_rules! int_module { ($T:ident, $bits:expr) => ( + +#[stable(feature = "rust1", since = "1.0.0")] +#[allow(missing_docs)] +pub const MIN: $T = $T::min_value(); +#[stable(feature = "rust1", since = "1.0.0")] +#[allow(missing_docs)] +pub const MAX: $T = $T::max_value(); + +) } diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs index 6479836cbe1..af6b1b89f96 100644 --- a/src/libcore/num/uint_macros.rs +++ b/src/libcore/num/uint_macros.rs @@ -10,6 +10,7 @@ #![doc(hidden)] +#[cfg(stage0)] macro_rules! uint_module { ($T:ty, $bits:expr) => ( #[stable(feature = "rust1", since = "1.0.0")] @@ -20,3 +21,15 @@ pub const MIN: $T = 0 as $T; pub const MAX: $T = !0 as $T; ) } + +#[cfg(not(stage0))] +macro_rules! uint_module { ($T:ident, $bits:expr) => ( + +#[stable(feature = "rust1", since = "1.0.0")] +#[allow(missing_docs)] +pub const MIN: $T = $T::min_value(); +#[stable(feature = "rust1", since = "1.0.0")] +#[allow(missing_docs)] +pub const MAX: $T = $T::max_value(); + +) }