From 271ba5a3ea59f25ebc7ba3b9a2e620a833e50b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 18:01:11 +0100 Subject: [PATCH 01/11] Stabilize assoc_int_consts --- src/libcore/lib.rs | 1 - src/libcore/num/f32.rs | 28 ++++++++++++++-------------- src/libcore/num/f64.rs | 28 ++++++++++++++-------------- src/libcore/num/mod.rs | 12 ++++-------- src/libstd/lib.rs | 1 - 5 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 12647fae9004e..4c543f1173bb7 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -138,7 +138,6 @@ #![feature(associated_type_bounds)] #![feature(const_type_id)] #![feature(const_caller_location)] -#![feature(assoc_int_consts)] #![cfg_attr(not(bootstrap), feature(no_niche))] // rust-lang/rust#68303 #[prelude_import] diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index da8dd9acd9f48..99df846c09528 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -154,15 +154,15 @@ pub mod consts { #[cfg(not(test))] impl f32 { /// The radix or base of the internal representation of `f32`. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const RADIX: u32 = 2; /// Number of significant digits in base 2. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MANTISSA_DIGITS: u32 = 24; /// Approximate number of significant digits in base 10. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const DIGITS: u32 = 6; /// [Machine epsilon] value for `f32`. @@ -170,41 +170,41 @@ impl f32 { /// This is the difference between `1.0` and the next larger representable number. /// /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const EPSILON: f32 = 1.19209290e-07_f32; /// Smallest finite `f32` value. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN: f32 = -3.40282347e+38_f32; /// Smallest positive normal `f32` value. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32; /// Largest finite `f32` value. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX: f32 = 3.40282347e+38_f32; /// One greater than the minimum possible normal power of 2 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_EXP: i32 = -125; /// Maximum possible power of 2 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX_EXP: i32 = 128; /// Minimum possible normal power of 10 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_10_EXP: i32 = -37; /// Maximum possible power of 10 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX_10_EXP: i32 = 38; /// Not a Number (NaN). - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const NAN: f32 = 0.0_f32 / 0.0_f32; /// Infinity (∞). - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const INFINITY: f32 = 1.0_f32 / 0.0_f32; /// Negative infinity (-∞). - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32; /// Returns `true` if this value is `NaN`. diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index a6081f184ab22..63caffc19c6f9 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -154,14 +154,14 @@ pub mod consts { #[cfg(not(test))] impl f64 { /// The radix or base of the internal representation of `f64`. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const RADIX: u32 = 2; /// Number of significant digits in base 2. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MANTISSA_DIGITS: u32 = 53; /// Approximate number of significant digits in base 10. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const DIGITS: u32 = 15; /// [Machine epsilon] value for `f64`. @@ -169,41 +169,41 @@ impl f64 { /// This is the difference between `1.0` and the next larger representable number. /// /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const EPSILON: f64 = 2.2204460492503131e-16_f64; /// Smallest finite `f64` value. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN: f64 = -1.7976931348623157e+308_f64; /// Smallest positive normal `f64` value. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_POSITIVE: f64 = 2.2250738585072014e-308_f64; /// Largest finite `f64` value. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX: f64 = 1.7976931348623157e+308_f64; /// One greater than the minimum possible normal power of 2 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_EXP: i32 = -1021; /// Maximum possible power of 2 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX_EXP: i32 = 1024; /// Minimum possible normal power of 10 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_10_EXP: i32 = -307; /// Maximum possible power of 10 exponent. - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX_10_EXP: i32 = 308; /// Not a Number (NaN). - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const NAN: f64 = 0.0_f64 / 0.0_f64; /// Infinity (∞). - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const INFINITY: f64 = 1.0_f64 / 0.0_f64; /// Negative infinity (-∞). - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64; /// Returns `true` if this value is `NaN`. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 471ab96662249..bcc38d0f0c85b 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -257,11 +257,10 @@ macro_rules! int_impl { Basic usage: ``` -#![feature(assoc_int_consts)] ", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");", $EndFeature, " ```"), - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self; } @@ -273,11 +272,10 @@ $EndFeature, " Basic usage: ``` -#![feature(assoc_int_consts)] ", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($Max), ");", $EndFeature, " ```"), - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX: Self = !Self::MIN; } @@ -2435,10 +2433,9 @@ macro_rules! uint_impl { Basic usage: ``` -#![feature(assoc_int_consts)] ", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, 0);", $EndFeature, " ```"), - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN: Self = 0; } @@ -2450,11 +2447,10 @@ Basic usage: Basic usage: ``` -#![feature(assoc_int_consts)] ", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($MaxV), ");", $EndFeature, " ```"), - #[unstable(feature = "assoc_int_consts", reason = "recently added", issue = "68490")] + #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX: Self = !0; } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index f9c9f224730da..50f05d0c7f9d7 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -237,7 +237,6 @@ #![feature(arbitrary_self_types)] #![feature(array_error_internals)] #![feature(asm)] -#![feature(assoc_int_consts)] #![feature(associated_type_bounds)] #![feature(box_syntax)] #![feature(c_variadic)] From 35298349c3efd75cd8050f9f23e4bf1409d96118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 18:08:17 +0100 Subject: [PATCH 02/11] Add "soft deprecation" notice to old min/max_value() docs --- src/libcore/num/mod.rs | 100 ++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index bcc38d0f0c85b..09e4cfa87a7b3 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -279,28 +279,6 @@ $EndFeature, " pub const MAX: Self = !Self::MIN; } - doc_comment! { - "Returns the smallest value that can be represented by this integer type.", - #[stable(feature = "rust1", since = "1.0.0")] - #[inline(always)] - #[rustc_promotable] - #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")] - pub const fn min_value() -> Self { - Self::MIN - } - } - - doc_comment! { - "Returns the largest value that can be represented by this integer type.", - #[stable(feature = "rust1", since = "1.0.0")] - #[inline(always)] - #[rustc_promotable] - #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")] - pub const fn max_value() -> Self { - Self::MAX - } - } - doc_comment! { concat!("Converts a string slice in a given base to an integer. @@ -2351,6 +2329,38 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), unsafe { mem::transmute(bytes) } } } + + doc_comment! { + concat!("**This method is soft-deprecated.** + +Although using it won’t cause compilation warning, +new code should use [`", stringify!($SelfT), "::MIN", "`](#associatedconstant.MIN) instead. + +Returns the smallest value that can be represented by this integer type."), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline(always)] + #[rustc_promotable] + #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")] + pub const fn min_value() -> Self { + Self::MIN + } + } + + doc_comment! { + concat!("**This method is soft-deprecated.** + +Although using it won’t cause compilation warning, +new code should use [`", stringify!($SelfT), "::MAX", "`](#associatedconstant.MAX) instead. + +Returns the largest value that can be represented by this integer type."), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline(always)] + #[rustc_promotable] + #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")] + pub const fn max_value() -> Self { + Self::MAX + } + } } } @@ -2454,24 +2464,6 @@ $EndFeature, " pub const MAX: Self = !0; } - doc_comment! { - "Returns the smallest value that can be represented by this integer type.", - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_promotable] - #[inline(always)] - #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")] - pub const fn min_value() -> Self { Self::MIN } - } - - doc_comment! { - "Returns the largest value that can be represented by this integer type.", - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_promotable] - #[inline(always)] - #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")] - pub const fn max_value() -> Self { Self::MAX } - } - doc_comment! { concat!("Converts a string slice in a given base to an integer. @@ -4277,6 +4269,34 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), unsafe { mem::transmute(bytes) } } } + + doc_comment! { + concat!("**This method is soft-deprecated.** + +Although using it won’t cause compilation warning, +new code should use [`", stringify!($SelfT), "::MIN", "`](#associatedconstant.MIN) instead. + +Returns the smallest value that can be represented by this integer type."), + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_promotable] + #[inline(always)] + #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")] + pub const fn min_value() -> Self { Self::MIN } + } + + doc_comment! { + concat!("**This method is soft-deprecated.** + +Although using it won’t cause compilation warning, +new code should use [`", stringify!($SelfT), "::MAX", "`](#associatedconstant.MAX) instead. + +Returns the largest value that can be represented by this integer type."), + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_promotable] + #[inline(always)] + #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")] + pub const fn max_value() -> Self { Self::MAX } + } } } From 97bdd31b0eab51d0a51b8746123f910cd868dff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 18:13:26 +0100 Subject: [PATCH 03/11] Add "soft deprecation" notice to old MIN/MAX docs --- src/libcore/num/int_macros.rs | 19 +++++++++++++------ src/libcore/num/uint_macros.rs | 34 ++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index 5c59fe25f6483..d3d6db5a7687b 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -3,11 +3,18 @@ macro_rules! int_module { ($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]);); ($T:ident, #[$attr:meta]) => ( - /// The smallest value that can be represented by this integer type. - #[$attr] - pub const MIN: $T = $T::min_value(); - /// The largest value that can be represented by this integer type. - #[$attr] - pub const MAX: $T = $T::max_value(); + doc_comment! { + concat!("The smallest value that can be represented by this integer type. +Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."), + #[$attr] + pub const MIN: $T = $T::min_value(); + } + + doc_comment! { + concat!("The largest value that can be represented by this integer type. +Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."), + #[$attr] + pub const MAX: $T = $T::max_value(); + } ) } diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs index a94b541ddb907..ff16a1f38d8a7 100644 --- a/src/libcore/num/uint_macros.rs +++ b/src/libcore/num/uint_macros.rs @@ -1,13 +1,35 @@ #![doc(hidden)] +macro_rules! doc_comment { + ($x:expr, $($tt:tt)*) => { + #[doc = $x] + $($tt)* + }; +} + macro_rules! uint_module { ($T:ident) => (uint_module!($T, #[stable(feature = "rust1", since = "1.0.0")]);); ($T:ident, #[$attr:meta]) => ( - /// The smallest value that can be represented by this integer type. - #[$attr] - pub const MIN: $T = $T::min_value(); - /// The largest value that can be represented by this integer type. - #[$attr] - pub const MAX: $T = $T::max_value(); + doc_comment! { + concat!("**This method is soft-deprecated.** + + Although using it won’t cause compilation warning, + new code should use [`", stringify!($T), "::MIN", "`] instead. + + The smallest value that can be represented by this integer type."), + #[$attr] + pub const MIN: $T = $T::min_value(); + } + + doc_comment! { + concat!("**This method is soft-deprecated.** + + Although using it won’t cause compilation warning, + new code should use [`", stringify!($T), "::MAX", "`] instead. + + The largest value that can be represented by this integer type."), + #[$attr] + pub const MAX: $T = $T::max_value(); + } ) } From fd71fbe8d51dc291f87fdb6beb12e174a304bd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 10 Feb 2020 19:42:14 +0100 Subject: [PATCH 04/11] Remove reference from integer docs to their modules --- src/libstd/primitive_docs.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index d4b41e11c0e82..b6bd709efe789 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -788,80 +788,60 @@ mod prim_f64 {} #[doc(primitive = "i8")] // /// The 8-bit signed integer type. -/// -/// *[See also the `std::i8` module](i8/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_i8 {} #[doc(primitive = "i16")] // /// The 16-bit signed integer type. -/// -/// *[See also the `std::i16` module](i16/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_i16 {} #[doc(primitive = "i32")] // /// The 32-bit signed integer type. -/// -/// *[See also the `std::i32` module](i32/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_i32 {} #[doc(primitive = "i64")] // /// The 64-bit signed integer type. -/// -/// *[See also the `std::i64` module](i64/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_i64 {} #[doc(primitive = "i128")] // /// The 128-bit signed integer type. -/// -/// *[See also the `std::i128` module](i128/index.html).* #[stable(feature = "i128", since = "1.26.0")] mod prim_i128 {} #[doc(primitive = "u8")] // /// The 8-bit unsigned integer type. -/// -/// *[See also the `std::u8` module](u8/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_u8 {} #[doc(primitive = "u16")] // /// The 16-bit unsigned integer type. -/// -/// *[See also the `std::u16` module](u16/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_u16 {} #[doc(primitive = "u32")] // /// The 32-bit unsigned integer type. -/// -/// *[See also the `std::u32` module](u32/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_u32 {} #[doc(primitive = "u64")] // /// The 64-bit unsigned integer type. -/// -/// *[See also the `std::u64` module](u64/index.html).* #[stable(feature = "rust1", since = "1.0.0")] mod prim_u64 {} #[doc(primitive = "u128")] // /// The 128-bit unsigned integer type. -/// -/// *[See also the `std::u128` module](u128/index.html).* #[stable(feature = "i128", since = "1.26.0")] mod prim_u128 {} @@ -869,8 +849,6 @@ mod prim_u128 {} // /// The pointer-sized signed integer type. /// -/// *[See also the `std::isize` module](isize/index.html).* -/// /// The size of this primitive is how many bytes it takes to reference any /// location in memory. For example, on a 32 bit target, this is 4 bytes /// and on a 64 bit target, this is 8 bytes. @@ -881,8 +859,6 @@ mod prim_isize {} // /// The pointer-sized unsigned integer type. /// -/// *[See also the `std::usize` module](usize/index.html).* -/// /// The size of this primitive is how many bytes it takes to reference any /// location in memory. For example, on a 32 bit target, this is 4 bytes /// and on a 64 bit target, this is 8 bytes. From cf255c6dc1a9c41bf8e98865d85f8577ce8d2056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 18:34:50 +0100 Subject: [PATCH 05/11] Use new preferred consts in int docs --- src/libcore/num/mod.rs | 48 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 09e4cfa87a7b3..782d1103000be 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -805,8 +805,7 @@ assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None); Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".checked_rem(2), Some(1)); assert_eq!(5", stringify!($SelfT), ".checked_rem(0), None); assert_eq!(", stringify!($SelfT), "::MIN.checked_rem(-1), None);", @@ -836,8 +835,6 @@ if `rhs == 0` or the division results in overflow. Basic usage: ``` -use std::", stringify!($SelfT), "; - assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(2), Some(1)); assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None); assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None); @@ -864,8 +861,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None); Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".checked_neg(), Some(-5)); assert_eq!(", stringify!($SelfT), "::MIN.checked_neg(), None);", $EndFeature, " @@ -936,8 +932,7 @@ $EndFeature, " Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!((-5", stringify!($SelfT), ").checked_abs(), Some(5)); assert_eq!(", stringify!($SelfT), "::MIN.checked_abs(), None);", $EndFeature, " @@ -1115,8 +1110,7 @@ numeric bounds instead of overflowing. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(10", stringify!($SelfT), ".saturating_mul(12), 120); assert_eq!(", stringify!($SelfT), "::MAX.saturating_mul(10), ", stringify!($SelfT), "::MAX); assert_eq!(", stringify!($SelfT), "::MIN.saturating_mul(10), ", stringify!($SelfT), "::MIN);", @@ -1148,8 +1142,7 @@ saturating at the numeric bounds instead of overflowing. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!((-4", stringify!($SelfT), ").saturating_pow(3), -64); assert_eq!(", stringify!($SelfT), "::MIN.saturating_pow(2), ", stringify!($SelfT), "::MAX); assert_eq!(", stringify!($SelfT), "::MIN.saturating_pow(3), ", stringify!($SelfT), "::MIN);", @@ -1536,8 +1529,7 @@ occur. If an overflow would have occurred then the wrapped value is returned. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false)); assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (", stringify!($SelfT), "::MIN, true));", $EndFeature, " @@ -1564,8 +1556,7 @@ would occur. If an overflow would have occurred then the wrapped value is return Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".overflowing_sub(2), (3, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_sub(1), (", stringify!($SelfT), "::MAX, true));", $EndFeature, " @@ -1622,8 +1613,7 @@ This function will panic if `rhs` is 0. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".overflowing_div(2), (2, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div(-1), (", stringify!($SelfT), "::MIN, true));", @@ -1658,8 +1648,6 @@ This function will panic if `rhs` is 0. Basic usage: ``` -use std::", stringify!($SelfT), "; - assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div_euclid(-1), (", stringify!($SelfT), "::MIN, true)); @@ -1693,8 +1681,7 @@ This function will panic if `rhs` is 0. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".overflowing_rem(2), (1, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem(-1), (0, true));", $EndFeature, " @@ -1729,8 +1716,6 @@ This function will panic if `rhs` is 0. Basic usage: ``` -use std::", stringify!($SelfT), "; - assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true)); ```"), @@ -1761,8 +1746,6 @@ minimum value will be returned again and `true` will be returned for an overflow Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - assert_eq!(2", stringify!($SelfT), ".overflowing_neg(), (-2, false)); assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($SelfT), "::MIN, true));", $EndFeature, " @@ -3187,8 +3170,7 @@ saturating at the numeric bounds instead of overflowing. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(2", stringify!($SelfT), ".saturating_mul(10), 20); assert_eq!((", stringify!($SelfT), "::MAX).saturating_mul(10), ", stringify!($SelfT), "::MAX);", $EndFeature, " @@ -3215,8 +3197,7 @@ saturating at the numeric bounds instead of overflowing. Basic usage: ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(4", stringify!($SelfT), ".saturating_pow(3), 64); assert_eq!(", stringify!($SelfT), "::MAX.saturating_pow(2), ", stringify!($SelfT), "::MAX);", $EndFeature, " @@ -3553,8 +3534,7 @@ have occurred then the wrapped value is returned. Basic usage ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false)); assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (0, true));", $EndFeature, " ```"), @@ -3581,8 +3561,7 @@ have occurred then the wrapped value is returned. Basic usage ``` -", $Feature, "use std::", stringify!($SelfT), "; - +", $Feature, " assert_eq!(5", stringify!($SelfT), ".overflowing_sub(2), (3, false)); assert_eq!(0", stringify!($SelfT), ".overflowing_sub(1), (", stringify!($SelfT), "::MAX, true));", $EndFeature, " @@ -4868,7 +4847,6 @@ impl usize { /// /// ``` /// use std::num::FpCategory; -/// use std::f32; /// /// let num = 12.4_f32; /// let inf = f32::INFINITY; From 5e17f31d94a0e2f1e69d5c4bd5171cf48ff9e5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 18:39:15 +0100 Subject: [PATCH 06/11] Replace min/max_value() with MIN/MAX in integer docs --- src/libcore/num/mod.rs | 104 ++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 782d1103000be..50d967dba6338 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -336,7 +336,7 @@ $EndFeature, " Basic usage: ``` -", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 1);", $EndFeature, " +", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 1);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] @@ -673,8 +673,8 @@ Basic usage: ``` ", $Feature, "assert_eq!((", stringify!($SelfT), -"::max_value() - 2).checked_add(1), Some(", stringify!($SelfT), "::max_value() - 1)); -assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", +"::MAX - 2).checked_add(1), Some(", stringify!($SelfT), "::MAX - 1)); +assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -698,8 +698,8 @@ Basic usage: ``` ", $Feature, "assert_eq!((", stringify!($SelfT), -"::min_value() + 2).checked_sub(1), Some(", stringify!($SelfT), "::min_value() + 1)); -assert_eq!((", stringify!($SelfT), "::min_value() + 2).checked_sub(3), None);", +"::MIN + 2).checked_sub(1), Some(", stringify!($SelfT), "::MIN + 1)); +assert_eq!((", stringify!($SelfT), "::MIN + 2).checked_sub(3), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -723,8 +723,8 @@ Basic usage: ``` ", $Feature, "assert_eq!(", stringify!($SelfT), -"::max_value().checked_mul(1), Some(", stringify!($SelfT), "::max_value())); -assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);", +"::MAX.checked_mul(1), Some(", stringify!($SelfT), "::MAX)); +assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -748,8 +748,8 @@ Basic usage: ``` ", $Feature, "assert_eq!((", stringify!($SelfT), -"::min_value() + 1).checked_div(-1), Some(", stringify!($Max), ")); -assert_eq!(", stringify!($SelfT), "::min_value().checked_div(-1), None); +"::MIN + 1).checked_div(-1), Some(", stringify!($Max), ")); +assert_eq!(", stringify!($SelfT), "::MIN.checked_div(-1), None); assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);", $EndFeature, " ```"), @@ -778,8 +778,8 @@ Basic usage: ``` assert_eq!((", stringify!($SelfT), -"::min_value() + 1).checked_div_euclid(-1), Some(", stringify!($Max), ")); -assert_eq!(", stringify!($SelfT), "::min_value().checked_div_euclid(-1), None); +"::MIN + 1).checked_div_euclid(-1), Some(", stringify!($Max), ")); +assert_eq!(", stringify!($SelfT), "::MIN.checked_div_euclid(-1), None); assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None); ```"), #[stable(feature = "euclidean_division", since = "1.38.0")] @@ -959,7 +959,7 @@ Basic usage: ``` ", $Feature, "assert_eq!(8", stringify!($SelfT), ".checked_pow(2), Some(64)); -assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);", +assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);", $EndFeature, " ```"), @@ -1000,10 +1000,10 @@ Basic usage: ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); -assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT), -"::max_value()); -assert_eq!(", stringify!($SelfT), "::min_value().saturating_add(-1), ", stringify!($SelfT), -"::min_value());", +assert_eq!(", stringify!($SelfT), "::MAX.saturating_add(100), ", stringify!($SelfT), +"::MAX); +assert_eq!(", stringify!($SelfT), "::MIN.saturating_add(-1), ", stringify!($SelfT), +"::MIN);", $EndFeature, " ```"), @@ -1027,10 +1027,10 @@ Basic usage: ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27); -assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT), -"::min_value()); -assert_eq!(", stringify!($SelfT), "::max_value().saturating_sub(-1), ", stringify!($SelfT), -"::max_value());", +assert_eq!(", stringify!($SelfT), "::MIN.saturating_sub(100), ", stringify!($SelfT), +"::MIN); +assert_eq!(", stringify!($SelfT), "::MAX.saturating_sub(-1), ", stringify!($SelfT), +"::MAX);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -1055,10 +1055,10 @@ Basic usage: ", $Feature, "#![feature(saturating_neg)] assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100); assert_eq!((-100", stringify!($SelfT), ").saturating_neg(), 100); -assert_eq!(", stringify!($SelfT), "::min_value().saturating_neg(), ", stringify!($SelfT), -"::max_value()); -assert_eq!(", stringify!($SelfT), "::max_value().saturating_neg(), ", stringify!($SelfT), -"::min_value() + 1);", +assert_eq!(", stringify!($SelfT), "::MIN.saturating_neg(), ", stringify!($SelfT), +"::MAX); +assert_eq!(", stringify!($SelfT), "::MAX.saturating_neg(), ", stringify!($SelfT), +"::MIN + 1);", $EndFeature, " ```"), @@ -1082,10 +1082,10 @@ Basic usage: ", $Feature, "#![feature(saturating_neg)] assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100); assert_eq!((-100", stringify!($SelfT), ").saturating_abs(), 100); -assert_eq!(", stringify!($SelfT), "::min_value().saturating_abs(), ", stringify!($SelfT), -"::max_value()); -assert_eq!((", stringify!($SelfT), "::min_value() + 1).saturating_abs(), ", stringify!($SelfT), -"::max_value());", +assert_eq!(", stringify!($SelfT), "::MIN.saturating_abs(), ", stringify!($SelfT), +"::MAX); +assert_eq!((", stringify!($SelfT), "::MIN + 1).saturating_abs(), ", stringify!($SelfT), +"::MAX);", $EndFeature, " ```"), @@ -1171,8 +1171,8 @@ Basic usage: ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_add(27), 127); -assert_eq!(", stringify!($SelfT), "::max_value().wrapping_add(2), ", stringify!($SelfT), -"::min_value() + 1);", +assert_eq!(", stringify!($SelfT), "::MAX.wrapping_add(2), ", stringify!($SelfT), +"::MIN + 1);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -1195,8 +1195,8 @@ Basic usage: ``` ", $Feature, "assert_eq!(0", stringify!($SelfT), ".wrapping_sub(127), -127); -assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::max_value()), ", -stringify!($SelfT), "::max_value());", +assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::MAX), ", +stringify!($SelfT), "::MAX);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -1367,8 +1367,8 @@ Basic usage: ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100); -assert_eq!(", stringify!($SelfT), "::min_value().wrapping_neg(), ", stringify!($SelfT), -"::min_value());", +assert_eq!(", stringify!($SelfT), "::MIN.wrapping_neg(), ", stringify!($SelfT), +"::MIN);", $EndFeature, " ```"), #[stable(feature = "num_wrapping", since = "1.2.0")] @@ -1458,8 +1458,8 @@ Basic usage: ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_abs(), 100); assert_eq!((-100", stringify!($SelfT), ").wrapping_abs(), 100); -assert_eq!(", stringify!($SelfT), "::min_value().wrapping_abs(), ", stringify!($SelfT), -"::min_value()); +assert_eq!(", stringify!($SelfT), "::MIN.wrapping_abs(), ", stringify!($SelfT), +"::MIN); assert_eq!((-128i8).wrapping_abs() as u8, 128);", $EndFeature, " ```"), @@ -1831,8 +1831,8 @@ Basic usage: ``` ", $Feature, "assert_eq!(10", stringify!($SelfT), ".overflowing_abs(), (10, false)); assert_eq!((-10", stringify!($SelfT), ").overflowing_abs(), (10, false)); -assert_eq!((", stringify!($SelfT), "::min_value()).overflowing_abs(), (", stringify!($SelfT), -"::min_value(), true));", +assert_eq!((", stringify!($SelfT), "::MIN).overflowing_abs(), (", stringify!($SelfT), +"::MIN, true));", $EndFeature, " ```"), #[stable(feature = "no_panic_abs", since = "1.13.0")] @@ -2028,10 +2028,10 @@ assert_eq!((-a).rem_euclid(-b), 1); # Overflow behavior -The absolute value of `", stringify!($SelfT), "::min_value()` cannot be represented as an +The absolute value of `", stringify!($SelfT), "::MIN` cannot be represented as an `", stringify!($SelfT), "`, and attempting to calculate it will cause an overflow. This means that code in debug mode will trigger a panic on this case and optimized code will return `", -stringify!($SelfT), "::min_value()` without a panic. +stringify!($SelfT), "::MIN` without a panic. # Examples @@ -2505,7 +2505,7 @@ assert_eq!(n.count_ones(), 3);", $EndFeature, " Basic usage: ``` -", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 0);", $EndFeature, " +", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 0);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] @@ -2523,7 +2523,7 @@ Basic usage: Basic usage: ``` -", $Feature, "let n = ", stringify!($SelfT), "::max_value() >> 2; +", $Feature, "let n = ", stringify!($SelfT), "::MAX >> 2; assert_eq!(n.leading_zeros(), 2);", $EndFeature, " ```"), @@ -2565,7 +2565,7 @@ Basic usage: ``` ", $Feature, "#![feature(leading_trailing_ones)] -let n = !(", stringify!($SelfT), "::max_value() >> 2); +let n = !(", stringify!($SelfT), "::MAX >> 2); assert_eq!(n.leading_ones(), 2);", $EndFeature, " ```"), @@ -2839,9 +2839,9 @@ if overflow occurred. Basic usage: ``` -", $Feature, "assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(1), ", -"Some(", stringify!($SelfT), "::max_value() - 1)); -assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", $EndFeature, " +", $Feature, "assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(1), ", +"Some(", stringify!($SelfT), "::MAX - 1)); +assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] @@ -2887,7 +2887,7 @@ Basic usage: ``` ", $Feature, "assert_eq!(5", stringify!($SelfT), ".checked_mul(1), Some(5)); -assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);", $EndFeature, " +assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] @@ -3087,7 +3087,7 @@ Basic usage: ``` ", $Feature, "assert_eq!(2", stringify!($SelfT), ".checked_pow(5), Some(32)); -assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);", $EndFeature, " +assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);", $EndFeature, " ```"), #[stable(feature = "no_panic_pow", since = "1.34.0")] #[must_use = "this returns the result of the operation, \ @@ -3224,7 +3224,7 @@ Basic usage: ``` ", $Feature, "assert_eq!(200", stringify!($SelfT), ".wrapping_add(55), 255); -assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::max_value()), 199);", +assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::MAX), 199);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -3247,7 +3247,7 @@ Basic usage: ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_sub(100), 0); -assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::max_value()), 101);", +assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::MAX), 101);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] @@ -4029,7 +4029,7 @@ Basic usage: ", $Feature, "assert_eq!(2", stringify!($SelfT), ".checked_next_power_of_two(), Some(2)); assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4)); -assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);", +assert_eq!(", stringify!($SelfT), "::MAX.checked_next_power_of_two(), None);", $EndFeature, " ```"), #[inline] @@ -4053,7 +4053,7 @@ Basic usage: ", $Feature, " assert_eq!(2", stringify!($SelfT), ".wrapping_next_power_of_two(), 2); assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4); -assert_eq!(", stringify!($SelfT), "::max_value().wrapping_next_power_of_two(), 0);", +assert_eq!(", stringify!($SelfT), "::MAX.wrapping_next_power_of_two(), 0);", $EndFeature, " ```"), #[unstable(feature = "wrapping_next_power_of_two", issue = "32463", From 847a0dd845dbc74b4d49adf873c585519e356b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 18:56:04 +0100 Subject: [PATCH 07/11] Remove uint_macros that was identical to int_macros --- src/libcore/lib.rs | 4 ---- src/libcore/num/int_macros.rs | 7 +++++++ src/libcore/num/u128.rs | 2 +- src/libcore/num/u16.rs | 2 +- src/libcore/num/u32.rs | 2 +- src/libcore/num/u64.rs | 2 +- src/libcore/num/u8.rs | 2 +- src/libcore/num/uint_macros.rs | 35 ---------------------------------- src/libcore/num/usize.rs | 2 +- 9 files changed, 13 insertions(+), 45 deletions(-) delete mode 100644 src/libcore/num/uint_macros.rs diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 4c543f1173bb7..1cd3e413ecc34 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -155,10 +155,6 @@ mod internal_macros; #[macro_use] mod int_macros; -#[path = "num/uint_macros.rs"] -#[macro_use] -mod uint_macros; - #[path = "num/i128.rs"] pub mod i128; #[path = "num/i16.rs"] diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index d3d6db5a7687b..b68a09e113180 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -1,5 +1,12 @@ #![doc(hidden)] +macro_rules! doc_comment { + ($x:expr, $($tt:tt)*) => { + #[doc = $x] + $($tt)* + }; +} + macro_rules! int_module { ($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]);); ($T:ident, #[$attr:meta]) => ( diff --git a/src/libcore/num/u128.rs b/src/libcore/num/u128.rs index 7d1aa664de30c..b9a83a55ced40 100644 --- a/src/libcore/num/u128.rs +++ b/src/libcore/num/u128.rs @@ -3,4 +3,4 @@ //! *[See also the `u128` primitive type](../../std/primitive.u128.html).* #![stable(feature = "i128", since = "1.26.0")] -uint_module! { u128, #[stable(feature = "i128", since="1.26.0")] } +int_module! { u128, #[stable(feature = "i128", since="1.26.0")] } diff --git a/src/libcore/num/u16.rs b/src/libcore/num/u16.rs index 34f80abaecc05..b481755c8d359 100644 --- a/src/libcore/num/u16.rs +++ b/src/libcore/num/u16.rs @@ -4,4 +4,4 @@ #![stable(feature = "rust1", since = "1.0.0")] -uint_module! { u16 } +int_module! { u16 } diff --git a/src/libcore/num/u32.rs b/src/libcore/num/u32.rs index 5fd486f546608..7355b6c19867e 100644 --- a/src/libcore/num/u32.rs +++ b/src/libcore/num/u32.rs @@ -4,4 +4,4 @@ #![stable(feature = "rust1", since = "1.0.0")] -uint_module! { u32 } +int_module! { u32 } diff --git a/src/libcore/num/u64.rs b/src/libcore/num/u64.rs index 044d238aea9be..2da5f013f054b 100644 --- a/src/libcore/num/u64.rs +++ b/src/libcore/num/u64.rs @@ -4,4 +4,4 @@ #![stable(feature = "rust1", since = "1.0.0")] -uint_module! { u64 } +int_module! { u64 } diff --git a/src/libcore/num/u8.rs b/src/libcore/num/u8.rs index 6747e6a0f6c24..76d3d70d9e999 100644 --- a/src/libcore/num/u8.rs +++ b/src/libcore/num/u8.rs @@ -4,4 +4,4 @@ #![stable(feature = "rust1", since = "1.0.0")] -uint_module! { u8 } +int_module! { u8 } diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs deleted file mode 100644 index ff16a1f38d8a7..0000000000000 --- a/src/libcore/num/uint_macros.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![doc(hidden)] - -macro_rules! doc_comment { - ($x:expr, $($tt:tt)*) => { - #[doc = $x] - $($tt)* - }; -} - -macro_rules! uint_module { - ($T:ident) => (uint_module!($T, #[stable(feature = "rust1", since = "1.0.0")]);); - ($T:ident, #[$attr:meta]) => ( - doc_comment! { - concat!("**This method is soft-deprecated.** - - Although using it won’t cause compilation warning, - new code should use [`", stringify!($T), "::MIN", "`] instead. - - The smallest value that can be represented by this integer type."), - #[$attr] - pub const MIN: $T = $T::min_value(); - } - - doc_comment! { - concat!("**This method is soft-deprecated.** - - Although using it won’t cause compilation warning, - new code should use [`", stringify!($T), "::MAX", "`] instead. - - The largest value that can be represented by this integer type."), - #[$attr] - pub const MAX: $T = $T::max_value(); - } - ) -} diff --git a/src/libcore/num/usize.rs b/src/libcore/num/usize.rs index e3a5239d908dc..fe1325754598f 100644 --- a/src/libcore/num/usize.rs +++ b/src/libcore/num/usize.rs @@ -4,4 +4,4 @@ #![stable(feature = "rust1", since = "1.0.0")] -uint_module! { usize } +int_module! { usize } From c67de2570f881a0601f15c7c15e1fb9a26f2d3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Mon, 10 Feb 2020 19:45:44 +0100 Subject: [PATCH 08/11] Add notice about using new consts in new code on float modules --- src/libcore/num/f32.rs | 3 +++ src/libcore/num/f64.rs | 3 +++ src/libstd/f32.rs | 3 +++ src/libstd/f64.rs | 3 +++ src/libstd/primitive_docs.rs | 4 ++-- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 99df846c09528..ee3e09f3577ad 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -4,6 +4,9 @@ //! *[See also the `f32` primitive type](../../std/primitive.f32.html).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 63caffc19c6f9..40c1cee1d2da7 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -4,6 +4,9 @@ //! *[See also the `f64` primitive type](../../std/primitive.f64.html).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 941ea6a767c57..20425aea8d517 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -4,6 +4,9 @@ //! *[See also the `f32` primitive type](../../std/primitive.f32.html).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index d89b38e1a0035..a1128a589a64a 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -4,6 +4,9 @@ //! *[See also the `f64` primitive type](../../std/primitive.f64.html).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index b6bd709efe789..adad90f56d1cf 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -771,7 +771,7 @@ mod prim_tuple {} #[doc(primitive = "f32")] /// The 32-bit floating point type. /// -/// *[See also the `std::f32` module](f32/index.html).* +/// *[See also the `std::f32::consts` module](f32/consts/index.html).* /// #[stable(feature = "rust1", since = "1.0.0")] mod prim_f32 {} @@ -780,7 +780,7 @@ mod prim_f32 {} // /// The 64-bit floating point type. /// -/// *[See also the `std::f64` module](f64/index.html).* +/// *[See also the `std::f64::consts` module](f64/consts/index.html).* /// #[stable(feature = "rust1", since = "1.0.0")] mod prim_f64 {} From 086927480be716a14f9c68954d417b544066184b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 23:00:40 +0100 Subject: [PATCH 09/11] Add notice about using new consts in new code on int modules --- src/libcore/num/i128.rs | 3 +++ src/libcore/num/i16.rs | 3 +++ src/libcore/num/i32.rs | 3 +++ src/libcore/num/i64.rs | 3 +++ src/libcore/num/i8.rs | 3 +++ src/libcore/num/isize.rs | 3 +++ src/libcore/num/u128.rs | 3 +++ src/libcore/num/u16.rs | 3 +++ src/libcore/num/u32.rs | 3 +++ src/libcore/num/u64.rs | 3 +++ src/libcore/num/u8.rs | 3 +++ src/libcore/num/usize.rs | 3 +++ 12 files changed, 36 insertions(+) diff --git a/src/libcore/num/i128.rs b/src/libcore/num/i128.rs index 564ed598a882c..08cb795946868 100644 --- a/src/libcore/num/i128.rs +++ b/src/libcore/num/i128.rs @@ -1,6 +1,9 @@ //! The 128-bit signed integer type. //! //! *[See also the `i128` primitive type](../../std/primitive.i128.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "i128", since = "1.26.0")] diff --git a/src/libcore/num/i16.rs b/src/libcore/num/i16.rs index 44d6aaef25ba0..288eaceba59d6 100644 --- a/src/libcore/num/i16.rs +++ b/src/libcore/num/i16.rs @@ -1,6 +1,9 @@ //! The 16-bit signed integer type. //! //! *[See also the `i16` primitive type](../../std/primitive.i16.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/i32.rs b/src/libcore/num/i32.rs index 90a5f89195e31..0e1a2ec56ccb2 100644 --- a/src/libcore/num/i32.rs +++ b/src/libcore/num/i32.rs @@ -1,6 +1,9 @@ //! The 32-bit signed integer type. //! //! *[See also the `i32` primitive type](../../std/primitive.i32.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/i64.rs b/src/libcore/num/i64.rs index 04a8a9d757915..27f7092710b34 100644 --- a/src/libcore/num/i64.rs +++ b/src/libcore/num/i64.rs @@ -1,6 +1,9 @@ //! The 64-bit signed integer type. //! //! *[See also the `i64` primitive type](../../std/primitive.i64.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/i8.rs b/src/libcore/num/i8.rs index 5a52a967cf96d..e84b421e1a444 100644 --- a/src/libcore/num/i8.rs +++ b/src/libcore/num/i8.rs @@ -1,6 +1,9 @@ //! The 8-bit signed integer type. //! //! *[See also the `i8` primitive type](../../std/primitive.i8.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/isize.rs b/src/libcore/num/isize.rs index 143f8b3b272d6..0dcfa4a2bd134 100644 --- a/src/libcore/num/isize.rs +++ b/src/libcore/num/isize.rs @@ -1,6 +1,9 @@ //! The pointer-sized signed integer type. //! //! *[See also the `isize` primitive type](../../std/primitive.isize.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/u128.rs b/src/libcore/num/u128.rs index b9a83a55ced40..dd45ff141539f 100644 --- a/src/libcore/num/u128.rs +++ b/src/libcore/num/u128.rs @@ -1,6 +1,9 @@ //! The 128-bit unsigned integer type. //! //! *[See also the `u128` primitive type](../../std/primitive.u128.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "i128", since = "1.26.0")] int_module! { u128, #[stable(feature = "i128", since="1.26.0")] } diff --git a/src/libcore/num/u16.rs b/src/libcore/num/u16.rs index b481755c8d359..738071643b639 100644 --- a/src/libcore/num/u16.rs +++ b/src/libcore/num/u16.rs @@ -1,6 +1,9 @@ //! The 16-bit unsigned integer type. //! //! *[See also the `u16` primitive type](../../std/primitive.u16.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/u32.rs b/src/libcore/num/u32.rs index 7355b6c19867e..9800c9099748f 100644 --- a/src/libcore/num/u32.rs +++ b/src/libcore/num/u32.rs @@ -1,6 +1,9 @@ //! The 32-bit unsigned integer type. //! //! *[See also the `u32` primitive type](../../std/primitive.u32.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/u64.rs b/src/libcore/num/u64.rs index 2da5f013f054b..fb686c396f033 100644 --- a/src/libcore/num/u64.rs +++ b/src/libcore/num/u64.rs @@ -1,6 +1,9 @@ //! The 64-bit unsigned integer type. //! //! *[See also the `u64` primitive type](../../std/primitive.u64.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/u8.rs b/src/libcore/num/u8.rs index 76d3d70d9e999..c03cbdda25dbb 100644 --- a/src/libcore/num/u8.rs +++ b/src/libcore/num/u8.rs @@ -1,6 +1,9 @@ //! The 8-bit unsigned integer type. //! //! *[See also the `u8` primitive type](../../std/primitive.u8.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/usize.rs b/src/libcore/num/usize.rs index fe1325754598f..a893041615244 100644 --- a/src/libcore/num/usize.rs +++ b/src/libcore/num/usize.rs @@ -1,6 +1,9 @@ //! The pointer-sized unsigned integer type. //! //! *[See also the `usize` primitive type](../../std/primitive.usize.html).* +//! +//! Although using these constants won’t cause compilation warnings, +//! new code should use the associated constants directly on the primitive type. #![stable(feature = "rust1", since = "1.0.0")] From 83191c2da6da6c13466f7f30568cdea02c761ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 4 Feb 2020 23:08:59 +0100 Subject: [PATCH 10/11] Update float documentation to use associated consts --- src/libcore/num/f32.rs | 15 ++------------- src/libcore/num/f64.rs | 9 --------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index ee3e09f3577ad..3a2f3691d8a97 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -213,8 +213,6 @@ impl f32 { /// Returns `true` if this value is `NaN`. /// /// ``` - /// use std::f32; - /// /// let nan = f32::NAN; /// let f = 7.0_f32; /// @@ -239,8 +237,6 @@ impl f32 { /// `false` otherwise. /// /// ``` - /// use std::f32; - /// /// let f = 7.0f32; /// let inf = f32::INFINITY; /// let neg_inf = f32::NEG_INFINITY; @@ -261,8 +257,6 @@ impl f32 { /// Returns `true` if this number is neither infinite nor `NaN`. /// /// ``` - /// use std::f32; - /// /// let f = 7.0f32; /// let inf = f32::INFINITY; /// let neg_inf = f32::NEG_INFINITY; @@ -286,8 +280,6 @@ impl f32 { /// [subnormal], or `NaN`. /// /// ``` - /// use std::f32; - /// /// let min = f32::MIN_POSITIVE; // 1.17549435e-38f32 /// let max = f32::MAX; /// let lower_than_min = 1.0e-40_f32; @@ -315,7 +307,6 @@ impl f32 { /// /// ``` /// use std::num::FpCategory; - /// use std::f32; /// /// let num = 12.4_f32; /// let inf = f32::INFINITY; @@ -375,8 +366,6 @@ impl f32 { /// Takes the reciprocal (inverse) of a number, `1/x`. /// /// ``` - /// use std::f32; - /// /// let x = 2.0_f32; /// let abs_difference = (x.recip() - (1.0 / x)).abs(); /// @@ -391,7 +380,7 @@ impl f32 { /// Converts radians to degrees. /// /// ``` - /// use std::f32::{self, consts}; + /// use std::f32::consts; /// /// let angle = consts::PI; /// @@ -410,7 +399,7 @@ impl f32 { /// Converts degrees to radians. /// /// ``` - /// use std::f32::{self, consts}; + /// use std::f32::consts; /// /// let angle = 180.0f32; /// diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 40c1cee1d2da7..ca81f98a6b505 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -212,8 +212,6 @@ impl f64 { /// Returns `true` if this value is `NaN`. /// /// ``` - /// use std::f64; - /// /// let nan = f64::NAN; /// let f = 7.0_f64; /// @@ -238,8 +236,6 @@ impl f64 { /// `false` otherwise. /// /// ``` - /// use std::f64; - /// /// let f = 7.0f64; /// let inf = f64::INFINITY; /// let neg_inf = f64::NEG_INFINITY; @@ -260,8 +256,6 @@ impl f64 { /// Returns `true` if this number is neither infinite nor `NaN`. /// /// ``` - /// use std::f64; - /// /// let f = 7.0f64; /// let inf: f64 = f64::INFINITY; /// let neg_inf: f64 = f64::NEG_INFINITY; @@ -285,8 +279,6 @@ impl f64 { /// [subnormal], or `NaN`. /// /// ``` - /// use std::f64; - /// /// let min = f64::MIN_POSITIVE; // 2.2250738585072014e-308f64 /// let max = f64::MAX; /// let lower_than_min = 1.0e-308_f64; @@ -314,7 +306,6 @@ impl f64 { /// /// ``` /// use std::num::FpCategory; - /// use std::f64; /// /// let num = 12.4_f64; /// let inf = f64::INFINITY; From b2dc6187699d99436f6183218d928be09d439578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Sat, 8 Feb 2020 12:15:22 +0100 Subject: [PATCH 11/11] Add usage recommendation to old float constants --- src/libcore/num/f32.rs | 14 ++++++++++++++ src/libcore/num/f64.rs | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 3a2f3691d8a97..3a641ae94a443 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -17,17 +17,21 @@ use crate::mem; use crate::num::FpCategory; /// The radix or base of the internal representation of `f32`. +/// Use [`f32::RADIX`](../../std/primitive.f32.html#associatedconstant.RADIX) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const RADIX: u32 = f32::RADIX; /// Number of significant digits in base 2. +/// Use [`f32::MANTISSA_DIGITS`](../../std/primitive.f32.html#associatedconstant.MANTISSA_DIGITS) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS; /// Approximate number of significant digits in base 10. +/// Use [`f32::DIGITS`](../../std/primitive.f32.html#associatedconstant.DIGITS) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const DIGITS: u32 = f32::DIGITS; /// [Machine epsilon] value for `f32`. +/// Use [`f32::EPSILON`](../../std/primitive.f32.html#associatedconstant.EPSILON) instead. /// /// This is the difference between `1.0` and the next larger representable number. /// @@ -36,36 +40,46 @@ pub const DIGITS: u32 = f32::DIGITS; pub const EPSILON: f32 = f32::EPSILON; /// Smallest finite `f32` value. +/// Use [`f32::MIN`](../../std/primitive.f32.html#associatedconstant.MIN) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN: f32 = f32::MIN; /// Smallest positive normal `f32` value. +/// Use [`f32::MIN_POSITIVE`](../../std/primitive.f32.html#associatedconstant.MIN_POSITIVE) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE; /// Largest finite `f32` value. +/// Use [`f32::MAX`](../../std/primitive.f32.html#associatedconstant.MAX) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: f32 = f32::MAX; /// One greater than the minimum possible normal power of 2 exponent. +/// Use [`f32::MIN_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_EXP: i32 = f32::MIN_EXP; /// Maximum possible power of 2 exponent. +/// Use [`f32::MAX_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_EXP: i32 = f32::MAX_EXP; /// Minimum possible normal power of 10 exponent. +/// Use [`f32::MIN_10_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_10_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_10_EXP: i32 = f32::MIN_10_EXP; /// Maximum possible power of 10 exponent. +/// Use [`f32::MAX_10_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_10_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_10_EXP: i32 = f32::MAX_10_EXP; /// Not a Number (NaN). +/// Use [`f32::NAN`](../../std/primitive.f32.html#associatedconstant.NAN) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const NAN: f32 = f32::NAN; /// Infinity (∞). +/// Use [`f32::INFINITY`](../../std/primitive.f32.html#associatedconstant.INFINITY) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const INFINITY: f32 = f32::INFINITY; /// Negative infinity (−∞). +/// Use [`f32::NEG_INFINITY`](../../std/primitive.f32.html#associatedconstant.NEG_INFINITY) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const NEG_INFINITY: f32 = f32::NEG_INFINITY; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index ca81f98a6b505..121ed149294a3 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -17,17 +17,21 @@ use crate::mem; use crate::num::FpCategory; /// The radix or base of the internal representation of `f64`. +/// Use [`f64::RADIX`](../../std/primitive.f64.html#associatedconstant.RADIX) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const RADIX: u32 = f64::RADIX; /// Number of significant digits in base 2. +/// Use [`f64::MANTISSA_DIGITS`](../../std/primitive.f64.html#associatedconstant.MANTISSA_DIGITS) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS; /// Approximate number of significant digits in base 10. +/// Use [`f64::DIGITS`](../../std/primitive.f64.html#associatedconstant.DIGITS) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const DIGITS: u32 = f64::DIGITS; /// [Machine epsilon] value for `f64`. +/// Use [`f64::EPSILON`](../../std/primitive.f64.html#associatedconstant.EPSILON) instead. /// /// This is the difference between `1.0` and the next larger representable number. /// @@ -36,36 +40,46 @@ pub const DIGITS: u32 = f64::DIGITS; pub const EPSILON: f64 = f64::EPSILON; /// Smallest finite `f64` value. +/// Use [`f64::MIN`](../../std/primitive.f64.html#associatedconstant.MIN) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN: f64 = f64::MIN; /// Smallest positive normal `f64` value. +/// Use [`f64::MIN_POSITIVE`](../../std/primitive.f64.html#associatedconstant.MIN_POSITIVE) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_POSITIVE: f64 = f64::MIN_POSITIVE; /// Largest finite `f64` value. +/// Use [`f64::MAX`](../../std/primitive.f64.html#associatedconstant.MAX) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: f64 = f64::MAX; /// One greater than the minimum possible normal power of 2 exponent. +/// Use [`f64::MIN_EXP`](../../std/primitive.f64.html#associatedconstant.MIN_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_EXP: i32 = f64::MIN_EXP; /// Maximum possible power of 2 exponent. +/// Use [`f64::MAX_EXP`](../../std/primitive.f64.html#associatedconstant.MAX_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_EXP: i32 = f64::MAX_EXP; /// Minimum possible normal power of 10 exponent. +/// Use [`f64::MIN_10_EXP`](../../std/primitive.f64.html#associatedconstant.MIN_10_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_10_EXP: i32 = f64::MIN_10_EXP; /// Maximum possible power of 10 exponent. +/// Use [`f64::MAX_10_EXP`](../../std/primitive.f64.html#associatedconstant.MAX_10_EXP) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_10_EXP: i32 = f64::MAX_10_EXP; /// Not a Number (NaN). +/// Use [`f64::NAN`](../../std/primitive.f64.html#associatedconstant.NAN) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const NAN: f64 = f64::NAN; /// Infinity (∞). +/// Use [`f64::INFINITY`](../../std/primitive.f64.html#associatedconstant.INFINITY) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const INFINITY: f64 = f64::INFINITY; /// Negative infinity (−∞). +/// Use [`f64::NEG_INFINITY`](../../std/primitive.f64.html#associatedconstant.NEG_INFINITY) instead. #[stable(feature = "rust1", since = "1.0.0")] pub const NEG_INFINITY: f64 = f64::NEG_INFINITY;