Skip to content

Commit 4c12881

Browse files
authored
Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obk
Require const stability attribute on all stable functions that are `const` This PR requires all stable functions (of all kinds) that are `const fn` to have a `#[rustc_const_stable]` or `#[rustc_const_unstable]` attribute. Stability was previously implied if omitted; a follow-up PR is planned to change the fallback to be unstable.
2 parents aef8c95 + 3be9a1b commit 4c12881

File tree

5 files changed

+5
-0
lines changed

5 files changed

+5
-0
lines changed

core/src/array/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ impl<T, const N: usize> [T; N] {
512512

513513
/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
514514
#[stable(feature = "array_as_slice", since = "1.57.0")]
515+
#[rustc_const_stable(feature = "array_as_slice", since = "1.57.0")]
515516
pub const fn as_slice(&self) -> &[T] {
516517
self
517518
}

core/src/cell.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ impl<T: ?Sized> UnsafeCell<T> {
19591959
/// ```
19601960
#[inline(always)]
19611961
#[stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
1962+
#[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
19621963
pub const fn raw_get(this: *const Self) -> *mut T {
19631964
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
19641965
// #[repr(transparent)]. This exploits libstd's special status, there is

core/src/num/int_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ macro_rules! int_impl {
10641064
///
10651065
/// ```
10661066
#[stable(feature = "saturating_div", since = "1.58.0")]
1067+
#[rustc_const_stable(feature = "saturating_div", since = "1.58.0")]
10671068
#[must_use = "this returns the result of the operation, \
10681069
without modifying the original"]
10691070
#[inline]

core/src/num/nonzero.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ macro_rules! nonzero_unsigned_is_power_of_two {
972972
/// ```
973973
#[must_use]
974974
#[stable(feature = "nonzero_is_power_of_two", since = "1.59.0")]
975+
#[rustc_const_stable(feature = "nonzero_is_power_of_two", since = "1.59.0")]
975976
#[inline]
976977
pub const fn is_power_of_two(self) -> bool {
977978
// LLVM 11 normalizes `unchecked_sub(x, 1) & x == 0` to the implementation seen here.

core/src/num/uint_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@ macro_rules! uint_impl {
11321132
///
11331133
/// ```
11341134
#[stable(feature = "saturating_div", since = "1.58.0")]
1135+
#[rustc_const_stable(feature = "saturating_div", since = "1.58.0")]
11351136
#[must_use = "this returns the result of the operation, \
11361137
without modifying the original"]
11371138
#[inline]

0 commit comments

Comments
 (0)