@@ -1377,8 +1377,7 @@ macro_rules! int_impl {
1377
1377
#[ rustc_allow_const_fn_unstable( is_val_statically_known, const_int_unchecked_arith) ]
1378
1378
#[ inline]
1379
1379
pub const fn checked_pow( self , mut exp: u32 ) -> Option <Self > {
1380
- // SAFETY: This path has the same behavior as the other.
1381
- if unsafe { intrinsics:: is_val_statically_known( self ) }
1380
+ if intrinsics:: is_val_statically_known( self )
1382
1381
&& self . unsigned_abs( ) . is_power_of_two( )
1383
1382
{
1384
1383
if self == 1 { // Avoid divide by zero
@@ -2094,8 +2093,7 @@ macro_rules! int_impl {
2094
2093
#[ rustc_allow_const_fn_unstable( is_val_statically_known, const_int_unchecked_arith) ]
2095
2094
#[ inline]
2096
2095
pub const fn wrapping_pow( self , mut exp: u32 ) -> Self {
2097
- // SAFETY: This path has the same behavior as the other.
2098
- if unsafe { intrinsics:: is_val_statically_known( self ) }
2096
+ if intrinsics:: is_val_statically_known( self )
2099
2097
&& self . unsigned_abs( ) . is_power_of_two( )
2100
2098
{
2101
2099
if self == 1 { // Avoid divide by zero
@@ -2628,8 +2626,7 @@ macro_rules! int_impl {
2628
2626
#[ rustc_allow_const_fn_unstable( is_val_statically_known, const_int_unchecked_arith) ]
2629
2627
#[ inline]
2630
2628
pub const fn overflowing_pow( self , mut exp: u32 ) -> ( Self , bool ) {
2631
- // SAFETY: This path has the same behavior as the other.
2632
- if unsafe { intrinsics:: is_val_statically_known( self ) }
2629
+ if intrinsics:: is_val_statically_known( self )
2633
2630
&& self . unsigned_abs( ) . is_power_of_two( )
2634
2631
{
2635
2632
if self == 1 { // Avoid divide by zero
@@ -2709,8 +2706,7 @@ macro_rules! int_impl {
2709
2706
#[ rustc_inherit_overflow_checks]
2710
2707
#[ track_caller] // Hides the hackish overflow check for powers of two.
2711
2708
pub const fn pow( self , mut exp: u32 ) -> Self {
2712
- // SAFETY: This path has the same behavior as the other.
2713
- if unsafe { intrinsics:: is_val_statically_known( self ) }
2709
+ if intrinsics:: is_val_statically_known( self )
2714
2710
&& self . unsigned_abs( ) . is_power_of_two( )
2715
2711
{
2716
2712
if self == 1 { // Avoid divide by zero
0 commit comments