]> git.lizzy.rs Git - rust.git/commitdiff
constify parts of libcore.
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 23 Oct 2018 00:04:14 +0000 (02:04 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sat, 10 Nov 2018 00:07:32 +0000 (01:07 +0100)
33 files changed:
src/libcore/alloc.rs
src/libcore/array.rs
src/libcore/benches/iter.rs
src/libcore/cell.rs
src/libcore/char/decode.rs
src/libcore/char/methods.rs
src/libcore/convert.rs
src/libcore/fmt/mod.rs
src/libcore/iter/mod.rs
src/libcore/iter/sources.rs
src/libcore/lib.rs
src/libcore/mem.rs
src/libcore/num/dec2flt/mod.rs
src/libcore/num/dec2flt/parse.rs
src/libcore/num/dec2flt/rawfp.rs
src/libcore/num/flt2dec/estimator.rs
src/libcore/num/flt2dec/mod.rs
src/libcore/num/wrapping.rs
src/libcore/ops/range.rs
src/libcore/panic.rs
src/libcore/pin.rs
src/libcore/ptr.rs
src/libcore/slice/memchr.rs
src/libcore/slice/mod.rs
src/libcore/str/lossy.rs
src/libcore/str/mod.rs
src/libcore/task/wake.rs
src/libcore/unicode/bool_trie.rs
src/libcore/unicode/tables.rs
src/test/ui/consts/const-eval/duration_conversion.rs
src/test/ui/rfc-2306/convert-id-const-no-gate.rs [deleted file]
src/test/ui/rfc-2306/convert-id-const-no-gate.stderr [deleted file]
src/test/ui/rfc-2306/convert-id-const-with-gate.rs

index 113a85abecbef4613163b79d0056cde77513faf8..8b9f7f2c816515af463ff67c70edfabfe1ef3848 100644 (file)
@@ -25,7 +25,7 @@
 #[derive(Debug)]
 pub struct Excess(pub NonNull<u8>, pub usize);
 
-fn size_align<T>() -> (usize, usize) {
+const fn size_align<T>() -> (usize, usize) {
     (mem::size_of::<T>(), mem::align_of::<T>())
 }
 
@@ -116,7 +116,7 @@ pub unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
     /// The minimum size in bytes for a memory block of this layout.
     #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
-    pub fn size(&self) -> usize { self.size_ }
+    pub const fn size(&self) -> usize { self.size_ }
 
     /// The minimum byte alignment for a memory block of this layout.
     #[stable(feature = "alloc_layout", since = "1.28.0")]
index 3d24f8902bd83827be8aee45f393f9cf9f9e33a6..0bea541e16349d2a586e9df8b8b4b1214f65735d 100644 (file)
@@ -77,7 +77,7 @@ impl TryFromSliceError {
            issue = "0")]
     #[inline]
     #[doc(hidden)]
-    pub fn __description(&self) -> &str {
+    pub const fn __description(&self) -> &str {
         "could not convert slice to array"
     }
 }
index 6c597301ac2045cfeea0158268455c9d6eb19364..c8b8c2eff97b1f549e9ffec460a3fe2b406208c4 100644 (file)
@@ -39,7 +39,7 @@ fn bench_multiple_take(b: &mut Bencher) {
     });
 }
 
-fn scatter(x: i32) -> i32 { (x * 31) % 127 }
+const fn scatter(x: i32) -> i32 { (x * 31) % 127 }
 
 #[bench]
 fn bench_max_by_key(b: &mut Bencher) {
index 689cf319bd750bd1c710e135c4ee0bd2f54d157d..3fe77fe688fa88b5c2ba6f6bb831b4c84afe48fd 100644 (file)
@@ -474,7 +474,7 @@ impl<T: ?Sized> Cell<T> {
     /// ```
     #[inline]
     #[stable(feature = "cell_as_ptr", since = "1.12.0")]
-    pub fn as_ptr(&self) -> *mut T {
+    pub const fn as_ptr(&self) -> *mut T {
         self.value.get()
     }
 
@@ -636,12 +636,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 const UNUSED: BorrowFlag = 0;
 
 #[inline(always)]
-fn is_writing(x: BorrowFlag) -> bool {
+const fn is_writing(x: BorrowFlag) -> bool {
     x < UNUSED
 }
 
 #[inline(always)]
-fn is_reading(x: BorrowFlag) -> bool {
+const fn is_reading(x: BorrowFlag) -> bool {
     x > UNUSED
 }
 
@@ -1508,7 +1508,7 @@ impl<T: ?Sized> UnsafeCell<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn get(&self) -> *mut T {
+    pub const fn get(&self) -> *mut T {
         &self.value as *const T as *mut T
     }
 }
index cc52f048b891b578f258dd47bf2f4b03de2d5f93..bcd1e92c6d86ef28d7a12a3de4ad3407b2dd7fb0 100644 (file)
@@ -130,7 +130,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
 impl DecodeUtf16Error {
     /// Returns the unpaired surrogate which caused this error.
     #[stable(feature = "decode_utf16", since = "1.9.0")]
-    pub fn unpaired_surrogate(&self) -> u16 {
+    pub const fn unpaired_surrogate(&self) -> u16 {
         self.code
     }
 }
index 64a17786b0a6b1b7bb92ec7df180190c2458bc1f..35181afea3da6ce72b6a5d83722737984f953fb3 100644 (file)
@@ -903,7 +903,7 @@ pub fn to_uppercase(self) -> ToUppercase {
     /// ```
     #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
     #[inline]
-    pub fn is_ascii(&self) -> bool {
+    pub const fn is_ascii(&self) -> bool {
         *self as u32 <= 0x7F
     }
 
index b900990d0a7266a90a1abb983cb697ea7148c0c7..dbc28ef7cf6a9ce8f3826bf21a3e9065ad809acd 100644 (file)
 /// assert_eq!(vec![1, 3], filtered);
 /// ```
 #[unstable(feature = "convert_id", issue = "53500")]
-#[rustc_const_unstable(feature = "const_convert_id")]
 #[inline]
 pub const fn identity<T>(x: T) -> T { x }
 
index 75ec0d7d50be6e7398d190b9e551918b0b5152cc..56576f8334b85c9aac007cd72ac86a6c0fab5737 100644 (file)
@@ -341,7 +341,7 @@ impl<'a> Arguments<'a> {
     #[doc(hidden)] #[inline]
     #[unstable(feature = "fmt_internals", reason = "internal to format_args!",
                issue = "0")]
-    pub fn new_v1(pieces: &'a [&'a str],
+    pub const fn new_v1(pieces: &'a [&'a str],
                   args: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
         Arguments {
             pieces,
@@ -359,7 +359,7 @@ pub fn new_v1(pieces: &'a [&'a str],
     #[doc(hidden)] #[inline]
     #[unstable(feature = "fmt_internals", reason = "internal to format_args!",
                issue = "0")]
-    pub fn new_v1_formatted(pieces: &'a [&'a str],
+    pub const fn new_v1_formatted(pieces: &'a [&'a str],
                             args: &'a [ArgumentV1<'a>],
                             fmt: &'a [rt::v1::Argument]) -> Arguments<'a> {
         Arguments {
@@ -1492,7 +1492,7 @@ pub fn flags(&self) -> u32 { self.flags }
     /// assert_eq!(&format!("{:t>6}", Foo), "tttttt");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn fill(&self) -> char { self.fill }
+    pub const fn fill(&self) -> char { self.fill }
 
     /// Flag indicating what form of alignment was requested.
     ///
@@ -1562,7 +1562,7 @@ pub fn align(&self) -> Option<Alignment> {
     /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn width(&self) -> Option<usize> { self.width }
+    pub const fn width(&self) -> Option<usize> { self.width }
 
     /// Optionally specified precision for numeric types.
     ///
@@ -1589,7 +1589,7 @@ pub fn width(&self) -> Option<usize> { self.width }
     /// assert_eq!(&format!("{}", Foo(23.2)), "Foo(23.20)");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn precision(&self) -> Option<usize> { self.precision }
+    pub const fn precision(&self) -> Option<usize> { self.precision }
 
     /// Determines if the `+` flag was specified.
     ///
@@ -1617,7 +1617,9 @@ pub fn precision(&self) -> Option<usize> { self.precision }
     /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn sign_plus(&self) -> bool { self.flags & (1 << FlagV1::SignPlus as u32) != 0 }
+    pub const fn sign_plus(&self) -> bool {
+        self.flags & (1 << FlagV1::SignPlus as u32) != 0
+    }
 
     /// Determines if the `-` flag was specified.
     ///
@@ -1643,7 +1645,9 @@ pub fn sign_plus(&self) -> bool { self.flags & (1 << FlagV1::SignPlus as u32) !=
     /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn sign_minus(&self) -> bool { self.flags & (1 << FlagV1::SignMinus as u32) != 0 }
+    pub const fn sign_minus(&self) -> bool {
+        self.flags & (1 << FlagV1::SignMinus as u32) != 0
+    }
 
     /// Determines if the `#` flag was specified.
     ///
@@ -1668,7 +1672,9 @@ pub fn sign_minus(&self) -> bool { self.flags & (1 << FlagV1::SignMinus as u32)
     /// assert_eq!(&format!("{}", Foo(23)), "23");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn alternate(&self) -> bool { self.flags & (1 << FlagV1::Alternate as u32) != 0 }
+    pub const fn alternate(&self) -> bool {
+        self.flags & (1 << FlagV1::Alternate as u32) != 0
+    }
 
     /// Determines if the `0` flag was specified.
     ///
@@ -1691,15 +1697,19 @@ pub fn alternate(&self) -> bool { self.flags & (1 << FlagV1::Alternate as u32) !
     /// assert_eq!(&format!("{:04}", Foo(23)), "23");
     /// ```
     #[stable(feature = "fmt_flags", since = "1.5.0")]
-    pub fn sign_aware_zero_pad(&self) -> bool {
+    pub const fn sign_aware_zero_pad(&self) -> bool {
         self.flags & (1 << FlagV1::SignAwareZeroPad as u32) != 0
     }
 
     // FIXME: Decide what public API we want for these two flags.
     // https://github.com/rust-lang/rust/issues/48584
-    fn debug_lower_hex(&self) -> bool { self.flags & (1 << FlagV1::DebugLowerHex as u32) != 0 }
+    const fn debug_lower_hex(&self) -> bool {
+        self.flags & (1 << FlagV1::DebugLowerHex as u32) != 0
+    }
 
-    fn debug_upper_hex(&self) -> bool { self.flags & (1 << FlagV1::DebugUpperHex as u32) != 0 }
+    const fn debug_upper_hex(&self) -> bool {
+        self.flags & (1 << FlagV1::DebugUpperHex as u32) != 0
+    }
 
     /// Creates a [`DebugStruct`] builder designed to assist with creation of
     /// [`fmt::Debug`] implementations for structs.
index c42fb7019c77108f2f79d262aade754e71bf33ae..72a032b57d09fab45cd86a13a90e86dfcffa9d89 100644 (file)
@@ -2658,7 +2658,7 @@ impl<I, U> FusedIterator for Flatten<I>
           I::Item: IntoIterator<IntoIter = U, Item = U::Item> {}
 
 /// Adapts an iterator by flattening it, for use in `flatten()` and `flat_map()`.
-fn flatten_compat<I, U>(iter: I) -> FlattenCompat<I, U> {
+const fn flatten_compat<I, U>(iter: I) -> FlattenCompat<I, U> {
     FlattenCompat { iter, frontiter: None, backiter: None }
 }
 
index d500cc99fa13c2641dabc0e3bfc3d898e4fd194e..7fa3a4bcce7bb2357ae1c1e05952c83e89844b24 100644 (file)
@@ -283,7 +283,7 @@ fn default() -> Empty<T> {
 /// assert_eq!(None, nope.next());
 /// ```
 #[stable(feature = "iter_empty", since = "1.2.0")]
-pub fn empty<T>() -> Empty<T> {
+pub const fn empty<T>() -> Empty<T> {
     Empty(marker::PhantomData)
 }
 
index 1bbc7892c6bef664ca4c91524252b436d1c36083..2445d93692748beea584d1730821740fda11bf48 100644 (file)
@@ -82,7 +82,6 @@
 #![feature(const_fn)]
 #![feature(const_int_ops)]
 #![feature(const_fn_union)]
-#![feature(const_manually_drop_new)]
 #![feature(custom_attribute)]
 #![feature(doc_cfg)]
 #![feature(doc_spotlight)]
index 1d0b194487e68d9bc9d65ef6841421544dffe5c9..0aa374c7a64464a3b66a02ceb4affd135680ddf4 100644 (file)
 /// [ub]: ../../reference/behavior-considered-undefined.html
 #[inline]
 #[stable(feature = "rust1", since = "1.0.0")]
-pub fn forget<T>(t: T) {
+pub const fn forget<T>(t: T) {
     ManuallyDrop::new(t);
 }
 
@@ -942,7 +942,6 @@ impl<T> ManuallyDrop<T> {
     /// ManuallyDrop::new(Box::new(()));
     /// ```
     #[stable(feature = "manually_drop", since = "1.20.0")]
-    #[rustc_const_unstable(feature = "const_manually_drop_new")]
     #[inline]
     pub const fn new(value: T) -> ManuallyDrop<T> {
         ManuallyDrop { value }
@@ -961,7 +960,7 @@ pub const fn new(value: T) -> ManuallyDrop<T> {
     /// ```
     #[stable(feature = "manually_drop", since = "1.20.0")]
     #[inline]
-    pub fn into_inner(slot: ManuallyDrop<T>) -> T {
+    pub const fn into_inner(slot: ManuallyDrop<T>) -> T {
         slot.value
     }
 
index f93564c2849f5613ca499649793c8b2abdd990d1..0e1f6664d965622506e331f14bde8d6d4ee8c76d 100644 (file)
@@ -187,11 +187,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-fn pfe_empty() -> ParseFloatError {
+const fn pfe_empty() -> ParseFloatError {
     ParseFloatError { kind: FloatErrorKind::Empty }
 }
 
-fn pfe_invalid() -> ParseFloatError {
+const fn pfe_invalid() -> ParseFloatError {
     ParseFloatError { kind: FloatErrorKind::Invalid }
 }
 
index e7ed94d4d91c2a0646dc7545849108bc4ae36582..8d8f357425ef02fc22c112cb7488b6fccc99cca4 100644 (file)
@@ -39,7 +39,7 @@ pub struct Decimal<'a> {
 }
 
 impl<'a> Decimal<'a> {
-    pub fn new(integral: &'a [u8], fractional: &'a [u8], exp: i64) -> Decimal<'a> {
+    pub const fn new(integral: &'a [u8], fractional: &'a [u8], exp: i64) -> Decimal<'a> {
         Decimal { integral, fractional, exp }
     }
 }
index 38f4e4687a99b6358b946eb7ced49fd7796bcb2e..c5d4aa689583c97bca5bcdd1ce49cfbc8d909402 100644 (file)
@@ -44,7 +44,7 @@ pub struct Unpacked {
 }
 
 impl Unpacked {
-    pub fn new(sig: u64, k: i16) -> Self {
+    pub const fn new(sig: u64, k: i16) -> Self {
         Unpacked { sig, k }
     }
 }
index d42e05a91f140f2f150c297914a93faf147f4fb9..2a87bf436646d344cd200a83e0e16c6e9643bd82 100644 (file)
 /// This is used to approximate `k = ceil(log_10 (mant * 2^exp))`;
 /// the true `k` is either `k_0` or `k_0+1`.
 #[doc(hidden)]
-pub fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 {
+pub const fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 {
     // 2^(nbits-1) < mant <= 2^nbits if mant > 0
     let nbits = 64 - (mant - 1).leading_zeros() as i64;
     // 1292913986 = floor(2^32 * log_10 2)
     // therefore this always underestimates (or is exact), but not much.
     (((nbits + exp as i64) * 1292913986) >> 32) as i16
 }
-
index 21a2e72dac8c37f7411b18841087689a37bc1b24..d58015beecb1e7172f38cf54706dfe5d3411cf13 100644 (file)
@@ -658,4 +658,3 @@ pub fn to_exact_fixed_str<'a, T, F>(mut format_exact: F, v: T,
         }
     }
 }
-
index 1c826c2fa76bdd6c08fd13096cd269e70ba5ac79..00134a58d30f1c2e00a5917b4db3a25a0516fbaa 100644 (file)
@@ -387,7 +387,7 @@ pub const fn max_value() -> Self {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn count_ones(self) -> u32 {
+                pub const fn count_ones(self) -> u32 {
                     self.0.count_ones()
                 }
             }
@@ -407,7 +407,7 @@ pub fn count_ones(self) -> u32 {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn count_zeros(self) -> u32 {
+                pub const fn count_zeros(self) -> u32 {
                     self.0.count_zeros()
                 }
             }
@@ -430,7 +430,7 @@ pub fn count_zeros(self) -> u32 {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn trailing_zeros(self) -> u32 {
+                pub const fn trailing_zeros(self) -> u32 {
                     self.0.trailing_zeros()
                 }
             }
@@ -456,7 +456,7 @@ pub fn trailing_zeros(self) -> u32 {
             /// ```
             #[inline]
             #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-            pub fn rotate_left(self, n: u32) -> Self {
+            pub const fn rotate_left(self, n: u32) -> Self {
                 Wrapping(self.0.rotate_left(n))
             }
 
@@ -481,7 +481,7 @@ pub fn rotate_left(self, n: u32) -> Self {
             /// ```
             #[inline]
             #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-            pub fn rotate_right(self, n: u32) -> Self {
+            pub const fn rotate_right(self, n: u32) -> Self {
                 Wrapping(self.0.rotate_right(n))
             }
 
@@ -505,7 +505,7 @@ pub fn rotate_right(self, n: u32) -> Self {
             /// ```
             #[inline]
             #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-            pub fn swap_bytes(self) -> Self {
+            pub const fn swap_bytes(self) -> Self {
                 Wrapping(self.0.swap_bytes())
             }
 
@@ -532,7 +532,7 @@ pub fn swap_bytes(self) -> Self {
             /// ```
             #[unstable(feature = "reverse_bits", issue = "48763")]
             #[inline]
-            pub fn reverse_bits(self) -> Self {
+            pub const fn reverse_bits(self) -> Self {
                 Wrapping(self.0.reverse_bits())
             }
 
@@ -560,7 +560,7 @@ pub fn reverse_bits(self) -> Self {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn from_be(x: Self) -> Self {
+                pub const fn from_be(x: Self) -> Self {
                     Wrapping(<$t>::from_be(x.0))
                 }
             }
@@ -589,7 +589,7 @@ pub fn from_be(x: Self) -> Self {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn from_le(x: Self) -> Self {
+                pub const fn from_le(x: Self) -> Self {
                     Wrapping(<$t>::from_le(x.0))
                 }
             }
@@ -618,7 +618,7 @@ pub fn from_le(x: Self) -> Self {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn to_be(self) -> Self {
+                pub const fn to_be(self) -> Self {
                     Wrapping(self.0.to_be())
                 }
             }
@@ -647,7 +647,7 @@ pub fn to_be(self) -> Self {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn to_le(self) -> Self {
+                pub const fn to_le(self) -> Self {
                     Wrapping(self.0.to_le())
                 }
             }
@@ -707,7 +707,7 @@ impl Wrapping<$t> {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn leading_zeros(self) -> u32 {
+                pub const fn leading_zeros(self) -> u32 {
                     self.0.leading_zeros()
                 }
             }
@@ -784,7 +784,7 @@ pub fn signum(self) -> Wrapping<$t> {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn is_positive(self) -> bool {
+                pub const fn is_positive(self) -> bool {
                     self.0.is_positive()
                 }
             }
@@ -806,7 +806,7 @@ pub fn is_positive(self) -> bool {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn is_negative(self) -> bool {
+                pub const fn is_negative(self) -> bool {
                     self.0.is_negative()
                 }
             }
@@ -836,7 +836,7 @@ impl Wrapping<$t> {
 ```"),
                 #[inline]
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
-                pub fn leading_zeros(self) -> u32 {
+                pub const fn leading_zeros(self) -> u32 {
                     self.0.leading_zeros()
                 }
             }
index 6cfb1005325ba644223311f773bcdcfc4cd0033c..908490e1c839e5eb53d9eee6acf6ea2a414686f5 100644 (file)
@@ -416,7 +416,7 @@ pub const fn new(start: Idx, end: Idx) -> Self {
     /// ```
     #[stable(feature = "inclusive_range_methods", since = "1.27.0")]
     #[inline]
-    pub fn start(&self) -> &Idx {
+    pub const fn start(&self) -> &Idx {
         &self.start
     }
 
@@ -440,7 +440,7 @@ pub fn start(&self) -> &Idx {
     /// ```
     #[stable(feature = "inclusive_range_methods", since = "1.27.0")]
     #[inline]
-    pub fn end(&self) -> &Idx {
+    pub const fn end(&self) -> &Idx {
         &self.end
     }
 
index f0efeb59e8d6e12225366c7ac19b1e6a6e6f28ab..af9d1596938e095c0b335e77a18151cdf86941d9 100644 (file)
@@ -55,7 +55,7 @@ impl<'a> PanicInfo<'a> {
                 issue = "0")]
     #[doc(hidden)]
     #[inline]
-    pub fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>,
+    pub const fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>,
                                 location: Location<'a>)
                                 -> Self {
         struct NoPayload;
@@ -96,7 +96,7 @@ pub fn payload(&self) -> &(dyn Any + Send) {
     ///
     /// [`fmt::write`]: ../fmt/fn.write.html
     #[unstable(feature = "panic_info_message", issue = "44489")]
-    pub fn message(&self) -> Option<&fmt::Arguments> {
+    pub const fn message(&self) -> Option<&fmt::Arguments> {
         self.message
     }
 
@@ -125,7 +125,7 @@ pub fn message(&self) -> Option<&fmt::Arguments> {
     /// panic!("Normal panic");
     /// ```
     #[stable(feature = "panic_hooks", since = "1.10.0")]
-    pub fn location(&self) -> Option<&Location> {
+    pub const fn location(&self) -> Option<&Location> {
         // NOTE: If this is changed to sometimes return None,
         // deal with that case in std::panicking::default_hook and std::panicking::begin_panic_fmt.
         Some(&self.location)
@@ -186,7 +186,7 @@ impl<'a> Location<'a> {
                           and related macros",
                 issue = "0")]
     #[doc(hidden)]
-    pub fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self {
+    pub const fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self {
         Location { file, line, col }
     }
 
@@ -208,7 +208,7 @@ pub fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self {
     /// panic!("Normal panic");
     /// ```
     #[stable(feature = "panic_hooks", since = "1.10.0")]
-    pub fn file(&self) -> &str {
+    pub const fn file(&self) -> &str {
         self.file
     }
 
@@ -230,7 +230,7 @@ pub fn file(&self) -> &str {
     /// panic!("Normal panic");
     /// ```
     #[stable(feature = "panic_hooks", since = "1.10.0")]
-    pub fn line(&self) -> u32 {
+    pub const fn line(&self) -> u32 {
         self.line
     }
 
@@ -252,7 +252,7 @@ pub fn line(&self) -> u32 {
     /// panic!("Normal panic");
     /// ```
     #[stable(feature = "panic_col", since = "1.25.0")]
-    pub fn column(&self) -> u32 {
+    pub const fn column(&self) -> u32 {
         self.col
     }
 }
index 68de82d294529e5cefa0d3eae3159a00674849f3..63a433a8b230179e802ede5f8672c9ab537188e2 100644 (file)
@@ -207,7 +207,7 @@ pub unsafe fn map_unchecked<U, F>(this: Pin<&'a T>, func: F) -> Pin<&'a U> where
     /// with the same lifetime as the original `Pin`.
     #[unstable(feature = "pin", issue = "49150")]
     #[inline(always)]
-    pub fn get_ref(this: Pin<&'a T>) -> &'a T {
+    pub const fn get_ref(this: Pin<&'a T>) -> &'a T {
         this.pointer
     }
 }
@@ -216,7 +216,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
     /// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
     #[unstable(feature = "pin", issue = "49150")]
     #[inline(always)]
-    pub fn into_ref(this: Pin<&'a mut T>) -> Pin<&'a T> {
+    pub const fn into_ref(this: Pin<&'a mut T>) -> Pin<&'a T> {
         Pin { pointer: this.pointer }
     }
 
index 62ccf6c865cd96735a92bf30969e5be5de08f815..c06e580e30eb53b4d13f9bb25d8e71eea08fdfce 100644 (file)
@@ -2759,7 +2759,7 @@ pub fn new(ptr: *mut T) -> Option<Self> {
     }
 
     /// Acquires the underlying `*mut` pointer.
-    pub fn as_ptr(self) -> *mut T {
+    pub const fn as_ptr(self) -> *mut T {
         self.pointer.0 as *mut T
     }
 
@@ -2905,7 +2905,7 @@ pub fn new(ptr: *mut T) -> Option<Self> {
     /// Acquires the underlying `*mut` pointer.
     #[stable(feature = "nonnull", since = "1.25.0")]
     #[inline]
-    pub fn as_ptr(self) -> *mut T {
+    pub const fn as_ptr(self) -> *mut T {
         self.pointer.0 as *mut T
     }
 
index cf95333af9cbb1622a69244f25d4dba61b269b01..deaeb53e84a3a6248e2f8b54fb8cc2f0f49abafd 100644 (file)
 /// bytes where the borrow propagated all the way to the most significant
 /// bit."
 #[inline]
-fn contains_zero_byte(x: usize) -> bool {
+const fn contains_zero_byte(x: usize) -> bool {
     x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0
 }
 
 #[cfg(target_pointer_width = "16")]
 #[inline]
-fn repeat_byte(b: u8) -> usize {
+const fn repeat_byte(b: u8) -> usize {
     (b as usize) << 8 | b as usize
 }
 
 #[cfg(not(target_pointer_width = "16"))]
 #[inline]
-fn repeat_byte(b: u8) -> usize {
+const fn repeat_byte(b: u8) -> usize {
     (b as usize) * (::usize::MAX / 255)
 }
 
index 8a6b212020b4e4a0d74f661d675a604bafce40b1..f8dee5370621d55b601e6c5ded43085592a04ba4 100644 (file)
@@ -385,7 +385,6 @@ pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
-    #[rustc_const_unstable(feature = "const_slice_as_ptr")]
     pub const fn as_ptr(&self) -> *const T {
         self as *const [T] as *const T
     }
@@ -2738,7 +2737,7 @@ fn into_iter(self) -> IterMut<'a, T> {
 
 // Macro helper functions
 #[inline(always)]
-fn size_from_ptr<T>(_: *const T) -> usize {
+const fn size_from_ptr<T>(_: *const T) -> usize {
     mem::size_of::<T>()
 }
 
@@ -4022,7 +4021,7 @@ impl<'a, T> ChunksExact<'a, T> {
     /// returned by the iterator. The returned slice has at most `chunk_size-1`
     /// elements.
     #[stable(feature = "chunks_exact", since = "1.31.0")]
-    pub fn remainder(&self) -> &'a [T] {
+    pub const fn remainder(&self) -> &'a [T] {
         self.rem
     }
 }
@@ -4518,7 +4517,7 @@ impl<'a, T> RChunksExact<'a, T> {
     /// returned by the iterator. The returned slice has at most `chunk_size-1`
     /// elements.
     #[stable(feature = "rchunks", since = "1.31.0")]
-    pub fn remainder(&self) -> &'a [T] {
+    pub const fn remainder(&self) -> &'a [T] {
         self.rem
     }
 }
index 186d6adbc91cf67ecb6c88df1acf286c943cebf4..950552fc6b172accb3e07c79e2dbd01b3ac00eeb 100644 (file)
@@ -29,7 +29,7 @@ pub fn from_bytes(bytes: &[u8]) -> &Utf8Lossy {
         unsafe { mem::transmute(bytes) }
     }
 
-    pub fn chunks(&self) -> Utf8LossyChunksIter {
+    pub const fn chunks(&self) -> Utf8LossyChunksIter {
         Utf8LossyChunksIter { source: &self.bytes }
     }
 }
index a2782dd8e2e430f7905c0049d335101bdcadf9b6..d73e5db727c91ad9af1e32381aec51bb09629f5d 100644 (file)
@@ -231,7 +231,7 @@ impl Utf8Error {
     /// assert_eq!(1, error.valid_up_to());
     /// ```
     #[stable(feature = "utf8_error", since = "1.5.0")]
-    pub fn valid_up_to(&self) -> usize { self.valid_up_to }
+    pub const fn valid_up_to(&self) -> usize { self.valid_up_to }
 
     /// Provide more information about the failure:
     ///
@@ -476,16 +476,16 @@ pub struct Chars<'a> {
 /// The first byte is special, only want bottom 5 bits for width 2, 4 bits
 /// for width 3, and 3 bits for width 4.
 #[inline]
-fn utf8_first_byte(byte: u8, width: u32) -> u32 { (byte & (0x7F >> width)) as u32 }
+const fn utf8_first_byte(byte: u8, width: u32) -> u32 { (byte & (0x7F >> width)) as u32 }
 
 /// Returns the value of `ch` updated with continuation byte `byte`.
 #[inline]
-fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 { (ch << 6) | (byte & CONT_MASK) as u32 }
+const fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 { (ch << 6) | (byte & CONT_MASK) as u32 }
 
 /// Checks whether the byte is a UTF-8 continuation byte (i.e. starts with the
 /// bits `10`).
 #[inline]
-fn utf8_is_cont_byte(byte: u8) -> bool { (byte & !CONT_MASK) == TAG_CONT_U8 }
+const fn utf8_is_cont_byte(byte: u8) -> bool { (byte & !CONT_MASK) == TAG_CONT_U8 }
 
 #[inline]
 fn unwrap_or_0(opt: Option<&u8>) -> u8 {
@@ -1420,7 +1420,7 @@ impl FusedIterator for LinesAny<'_> {}
 
 /// Returns `true` if any byte in the word `x` is nonascii (>= 128).
 #[inline]
-fn contains_nonascii(x: usize) -> bool {
+const fn contains_nonascii(x: usize) -> bool {
     (x & NONASCII_MASK) != 0
 }
 
@@ -2277,7 +2277,6 @@ pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
-    #[rustc_const_unstable(feature = "const_str_as_ptr")]
     pub const fn as_ptr(&self) -> *const u8 {
         self as *const str as *const u8
     }
index c9fb22e0080dd1c2efc2531e8fcdfaed53336e19..1db3a290e046f2854805e8e96e07c6b756308f58 100644 (file)
@@ -141,7 +141,7 @@ pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
     /// `Waker` is nearly identical to `LocalWaker`, but is threadsafe
     /// (implements `Send` and `Sync`).
     #[inline]
-    pub fn as_waker(&self) -> &Waker {
+    pub const fn as_waker(&self) -> &Waker {
         &self.0
     }
 
index 0e6437fded594c3a18a8a5a5ed6b0fc474026ab3..995795839b7d8f1d3123cafb4e12c7de22106a69 100644 (file)
@@ -71,6 +71,6 @@ pub fn lookup(&self, c: char) -> bool {
     }
 }
 
-fn trie_range_leaf(c: u32, bitmap_chunk: u64) -> bool {
+const fn trie_range_leaf(c: u32, bitmap_chunk: u64) -> bool {
     ((bitmap_chunk >> (c & 63)) & 1) != 0
 }
index 3de855ac943157091696c035096c70399d5bd96e..e525c0574002b2d83e96d9007dcf289ee16b31ca 100644 (file)
@@ -2598,4 +2598,3 @@ pub mod conversions {
     ];
 
 }
-
index 4481b75840487440d363502b2ec0f832fce9164e..c8bed4a2b77e147c29913c9477b1edb6a9339e58 100644 (file)
@@ -10,8 +10,6 @@
 
 // compile-pass
 
-#![feature(duration_getters)]
-
 use std::time::Duration;
 
 fn main() {
diff --git a/src/test/ui/rfc-2306/convert-id-const-no-gate.rs b/src/test/ui/rfc-2306/convert-id-const-no-gate.rs
deleted file mode 100644 (file)
index 545c179..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This test should fail since identity is not stable as a const fn yet.
-
-#![feature(convert_id)]
-
-fn main() {
-    const _FOO: u8 = ::std::convert::identity(42u8);
-}
diff --git a/src/test/ui/rfc-2306/convert-id-const-no-gate.stderr b/src/test/ui/rfc-2306/convert-id-const-no-gate.stderr
deleted file mode 100644 (file)
index dfd8619..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-error: `std::convert::identity` is not yet stable as a const fn
-  --> $DIR/convert-id-const-no-gate.rs:16:22
-   |
-LL |     const _FOO: u8 = ::std::convert::identity(42u8);
-   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: in Nightly builds, add `#![feature(const_convert_id)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
index c546f11914f814eacf7e734a1bedaf632a6ed031..2e71aee57c2f18abcf1b5f014b0537cf2310c2cd 100644 (file)
@@ -8,12 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// This test should pass since we've opted into 'identity' as an
-// unstable const fn.
+// This test should pass since 'identity' is const fn.
 
 // compile-pass
 
-#![feature(convert_id, const_convert_id)]
+#![feature(convert_id)]
 
 fn main() {
     const _FOO: u8 = ::std::convert::identity(42u8);