Skip to content

Commit 901b340

Browse files
committed
unchecked_shifts, unchecked_neg are safe-to-const-expose-on-stable, so we can get rid of a bunch of attributes
1 parent a8e1186 commit 901b340

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

library/core/src/num/int_macros.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ macro_rules! int_impl {
11611161
)]
11621162
#[must_use = "this returns the result of the operation, \
11631163
without modifying the original"]
1164-
#[rustc_const_unstable(feature = "unchecked_neg", issue = "85122")]
1164+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_neg", issue = "85122"))]
11651165
#[inline(always)]
11661166
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
11671167
pub const unsafe fn unchecked_neg(self) -> Self {
@@ -1227,8 +1227,7 @@ macro_rules! int_impl {
12271227
/// ```
12281228
#[stable(feature = "wrapping", since = "1.7.0")]
12291229
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
1230-
// We could always go back to wrapping
1231-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
1230+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
12321231
#[must_use = "this returns the result of the operation, \
12331232
without modifying the original"]
12341233
#[inline]
@@ -1294,7 +1293,7 @@ macro_rules! int_impl {
12941293
)]
12951294
#[must_use = "this returns the result of the operation, \
12961295
without modifying the original"]
1297-
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
1296+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))]
12981297
#[inline(always)]
12991298
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
13001299
pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self {
@@ -1353,8 +1352,7 @@ macro_rules! int_impl {
13531352
/// ```
13541353
#[stable(feature = "wrapping", since = "1.7.0")]
13551354
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
1356-
// We could always go back to wrapping
1357-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
1355+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
13581356
#[must_use = "this returns the result of the operation, \
13591357
without modifying the original"]
13601358
#[inline]
@@ -1420,7 +1418,7 @@ macro_rules! int_impl {
14201418
)]
14211419
#[must_use = "this returns the result of the operation, \
14221420
without modifying the original"]
1423-
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
1421+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))]
14241422
#[inline(always)]
14251423
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14261424
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
@@ -2151,7 +2149,7 @@ macro_rules! int_impl {
21512149
#[must_use = "this returns the result of the operation, \
21522150
without modifying the original"]
21532151
#[inline(always)]
2154-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
2152+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
21552153
pub const fn wrapping_shl(self, rhs: u32) -> Self {
21562154
// SAFETY: the masking by the bitsize of the type ensures that we do not shift
21572155
// out of bounds
@@ -2181,7 +2179,7 @@ macro_rules! int_impl {
21812179
#[must_use = "this returns the result of the operation, \
21822180
without modifying the original"]
21832181
#[inline(always)]
2184-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
2182+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
21852183
pub const fn wrapping_shr(self, rhs: u32) -> Self {
21862184
// SAFETY: the masking by the bitsize of the type ensures that we do not shift
21872185
// out of bounds

library/core/src/num/uint_macros.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,7 @@ macro_rules! uint_impl {
14161416
/// ```
14171417
#[stable(feature = "wrapping", since = "1.7.0")]
14181418
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
1419-
// We could always go back to wrapping
1420-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
1419+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
14211420
#[must_use = "this returns the result of the operation, \
14221421
without modifying the original"]
14231422
#[inline]
@@ -1483,7 +1482,7 @@ macro_rules! uint_impl {
14831482
)]
14841483
#[must_use = "this returns the result of the operation, \
14851484
without modifying the original"]
1486-
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
1485+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))]
14871486
#[inline(always)]
14881487
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14891488
pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self {
@@ -1542,8 +1541,7 @@ macro_rules! uint_impl {
15421541
/// ```
15431542
#[stable(feature = "wrapping", since = "1.7.0")]
15441543
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
1545-
// We could always go back to wrapping
1546-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
1544+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
15471545
#[must_use = "this returns the result of the operation, \
15481546
without modifying the original"]
15491547
#[inline]
@@ -1609,7 +1607,7 @@ macro_rules! uint_impl {
16091607
)]
16101608
#[must_use = "this returns the result of the operation, \
16111609
without modifying the original"]
1612-
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
1610+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "unchecked_shifts", issue = "85122"))]
16131611
#[inline(always)]
16141612
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
16151613
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
@@ -2132,7 +2130,7 @@ macro_rules! uint_impl {
21322130
#[must_use = "this returns the result of the operation, \
21332131
without modifying the original"]
21342132
#[inline(always)]
2135-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
2133+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
21362134
pub const fn wrapping_shl(self, rhs: u32) -> Self {
21372135
// SAFETY: the masking by the bitsize of the type ensures that we do not shift
21382136
// out of bounds
@@ -2165,7 +2163,7 @@ macro_rules! uint_impl {
21652163
#[must_use = "this returns the result of the operation, \
21662164
without modifying the original"]
21672165
#[inline(always)]
2168-
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
2166+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_shifts))]
21692167
pub const fn wrapping_shr(self, rhs: u32) -> Self {
21702168
// SAFETY: the masking by the bitsize of the type ensures that we do not shift
21712169
// out of bounds

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ impl<T: ?Sized> *const T {
10051005
#[stable(feature = "pointer_methods", since = "1.26.0")]
10061006
#[must_use = "returns a new pointer rather than modifying its argument"]
10071007
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
1008-
#[rustc_allow_const_fn_unstable(unchecked_neg)]
1008+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_neg))]
10091009
#[inline(always)]
10101010
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10111011
pub const unsafe fn sub(self, count: usize) -> Self

library/core/src/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ impl<T: ?Sized> *mut T {
10851085
#[stable(feature = "pointer_methods", since = "1.26.0")]
10861086
#[must_use = "returns a new pointer rather than modifying its argument"]
10871087
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
1088-
#[rustc_allow_const_fn_unstable(unchecked_neg)]
1088+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_neg))]
10891089
#[inline(always)]
10901090
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10911091
pub const unsafe fn sub(self, count: usize) -> Self

library/core/src/ptr/non_null.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ impl<T: ?Sized> NonNull<T> {
635635
#[must_use = "returns a new pointer rather than modifying its argument"]
636636
#[stable(feature = "non_null_convenience", since = "1.80.0")]
637637
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
638-
#[rustc_allow_const_fn_unstable(unchecked_neg)]
638+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(unchecked_neg))]
639639
pub const unsafe fn sub(self, count: usize) -> Self
640640
where
641641
T: Sized,

0 commit comments

Comments
 (0)