]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/num/mod.rs
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
[rust.git] / src / libcore / num / mod.rs
index 0ebac027c39acd1046cbf4abf58251e6bedef3ae..bf31deae7a62576330f198c04ee8f62cb973a4a7 100644 (file)
@@ -109,6 +109,7 @@ macro_rules! int_impl {
         /// assert_eq!(i8::min_value(), -128);
         /// ```
         #[stable(feature = "rust1", since = "1.0.0")]
+        #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))]
         #[inline]
         pub const fn min_value() -> Self {
             !0 ^ ((!0 as $UnsignedT) >> 1) as Self
@@ -122,6 +123,7 @@ pub const fn min_value() -> Self {
         /// assert_eq!(i8::max_value(), 127);
         /// ```
         #[stable(feature = "rust1", since = "1.0.0")]
+        #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))]
         #[inline]
         pub const fn max_value() -> Self {
             !Self::min_value()
@@ -131,6 +133,10 @@ pub const fn max_value() -> Self {
         ///
         /// Leading and trailing whitespace represent an error.
         ///
+        /// # Panics
+        ///
+        /// This function panics if `radix` is not in the range from 2 to 36.
+        ///
         /// # Examples
         ///
         /// Basic usage:
@@ -1276,6 +1282,7 @@ macro_rules! uint_impl {
         /// assert_eq!(u8::min_value(), 0);
         /// ```
         #[stable(feature = "rust1", since = "1.0.0")]
+        #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))]
         #[inline]
         pub const fn min_value() -> Self { 0 }
 
@@ -1287,6 +1294,7 @@ pub const fn min_value() -> Self { 0 }
         /// assert_eq!(u8::max_value(), 255);
         /// ```
         #[stable(feature = "rust1", since = "1.0.0")]
+        #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))]
         #[inline]
         pub const fn max_value() -> Self { !0 }
 
@@ -2238,17 +2246,12 @@ pub fn checked_next_power_of_two(self) -> Option<Self> {
     }
 }
 
-#[cfg(stage0)]
-unsafe fn ctlz_nonzero<T>(x: T) -> T { intrinsics::ctlz(x) }
-#[cfg(not(stage0))]
-unsafe fn ctlz_nonzero<T>(x: T) -> T { intrinsics::ctlz_nonzero(x) }
-
 #[lang = "u8"]
 impl u8 {
     uint_impl! { u8, u8, 8,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2261,7 +2264,7 @@ impl u16 {
     uint_impl! { u16, u16, 16,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2274,7 +2277,7 @@ impl u32 {
     uint_impl! { u32, u32, 32,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2287,7 +2290,7 @@ impl u64 {
     uint_impl! { u64, u64, 64,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2300,7 +2303,7 @@ impl u128 {
     uint_impl! { u128, u128, 128,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2314,7 +2317,7 @@ impl usize {
     uint_impl! { usize, u16, 16,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2327,7 +2330,7 @@ impl usize {
     uint_impl! { usize, u32, 32,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2341,7 +2344,7 @@ impl usize {
     uint_impl! { usize, u64, 64,
         intrinsics::ctpop,
         intrinsics::ctlz,
-        ctlz_nonzero,
+        intrinsics::ctlz_nonzero,
         intrinsics::cttz,
         intrinsics::bswap,
         intrinsics::add_with_overflow,
@@ -2627,8 +2630,11 @@ macro_rules! rev {
 try_from_both_bounded!(i64, u32, u16, u8);
 try_from_both_bounded!(i128, u64, u32, u16, u8);
 
-#[unstable(feature = "try_from", issue = "33417")]
-pub use self::ptr_try_from_impls::*;
+// usize/isize
+try_from_unbounded!(usize, usize);
+try_from_upper_bounded!(usize, isize);
+try_from_lower_bounded!(isize, usize);
+try_from_unbounded!(isize, isize);
 
 #[cfg(target_pointer_width = "16")]
 mod ptr_try_from_impls {
@@ -2636,12 +2642,12 @@ mod ptr_try_from_impls {
     use convert::TryFrom;
 
     try_from_upper_bounded!(usize, u8);
-    try_from_unbounded!(usize, usize, u16, u32, u64, u128);
-    try_from_upper_bounded!(usize, i8, i16, isize);
+    try_from_unbounded!(usize, u16, u32, u64, u128);
+    try_from_upper_bounded!(usize, i8, i16);
     try_from_unbounded!(usize, i32, i64, i128);
 
     try_from_both_bounded!(isize, u8);
-    try_from_lower_bounded!(isize, usize, u16, u32, u64, u128);
+    try_from_lower_bounded!(isize, u16, u32, u64, u128);
     try_from_both_bounded!(isize, i8);
     try_from_unbounded!(isize, i16, i32, i64, i128);
 
@@ -2662,12 +2668,12 @@ mod ptr_try_from_impls {
     use convert::TryFrom;
 
     try_from_upper_bounded!(usize, u8, u16);
-    try_from_unbounded!(usize, usize, u32, u64, u128);
-    try_from_upper_bounded!(usize, i8, i16, i32, isize);
+    try_from_unbounded!(usize, u32, u64, u128);
+    try_from_upper_bounded!(usize, i8, i16, i32);
     try_from_unbounded!(usize, i64, i128);
 
     try_from_both_bounded!(isize, u8, u16);
-    try_from_lower_bounded!(isize, usize, u32, u64, u128);
+    try_from_lower_bounded!(isize, u32, u64, u128);
     try_from_both_bounded!(isize, i8, i16);
     try_from_unbounded!(isize, i32, i64, i128);
 
@@ -2688,12 +2694,12 @@ mod ptr_try_from_impls {
     use convert::TryFrom;
 
     try_from_upper_bounded!(usize, u8, u16, u32);
-    try_from_unbounded!(usize, usize, u64, u128);
-    try_from_upper_bounded!(usize, i8, i16, i32, i64, isize);
+    try_from_unbounded!(usize, u64, u128);
+    try_from_upper_bounded!(usize, i8, i16, i32, i64);
     try_from_unbounded!(usize, i128);
 
     try_from_both_bounded!(isize, u8, u16, u32);
-    try_from_lower_bounded!(isize, usize, u64, u128);
+    try_from_lower_bounded!(isize, u64, u128);
     try_from_both_bounded!(isize, i8, i16, i32);
     try_from_unbounded!(isize, i64, i128);