@@ -1002,11 +1002,12 @@ macro_rules! int_impl {
1002
1002
///
1003
1003
/// ```
1004
1004
/// #![feature(saturating_bit_shifts)]
1005
+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS), 0);" ) ]
1005
1006
#[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS - 2), 1_" , stringify!( $SelfT) , " << " , stringify!( $SelfT) , "::BITS - 2);" ) ]
1006
1007
#[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS - 1), " , stringify!( $SelfT) , "::MAX);" ) ]
1007
1008
#[ doc = concat!( "assert_eq!(-1_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS - 2), -1_" , stringify!( $SelfT) , " << " , stringify!( $SelfT) , "::BITS - 2);" ) ]
1008
1009
#[ doc = concat!( "assert_eq!(-1_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS - 1), " , stringify!( $SelfT) , "::MIN);" ) ]
1009
- #[ doc = concat!( "assert_eq!(-1_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS), " , stringify!( $SelfT) , "::MIN);" ) ]
1010
+ #[ doc = concat!( "assert_eq!(-1_" , stringify!( $SelfT) , ".saturating_shl(" , stringify!( $SelfT) , "::BITS), " , stringify!( $SelfT) , "::MIN, \" -1_" , stringify! ( $SelfT ) , ".saturating_shl(" , stringify! ( $SelfT ) , "::BITS), " , stringify! ( $SelfT ) , "::MIN \" );") ]
1010
1011
/// ```
1011
1012
#[ unstable( feature = "saturating_bit_shifts" , issue = "103440" ) ]
1012
1013
#[ rustc_const_unstable( feature = "saturating_bit_shifts" , issue = "103440" ) ]
@@ -1022,10 +1023,10 @@ macro_rules! int_impl {
1022
1023
let leading_ones = ( self << 1 ) . leading_ones( ) ;
1023
1024
1024
1025
// would overflow => MIN / MAX depending on whether the value is negative or not
1025
- if self >= 0 && leading_zeros < rhs {
1026
- <$SelfT> :: MAX
1026
+ if self > 0 && leading_zeros < rhs {
1027
+ Self :: MAX
1027
1028
} else if self < 0 && leading_ones < rhs {
1028
- <$SelfT> :: MIN
1029
+ Self :: MIN
1029
1030
} else {
1030
1031
// normal shift left
1031
1032
self << rhs
@@ -1046,7 +1047,7 @@ macro_rules! int_impl {
1046
1047
///
1047
1048
/// ```
1048
1049
/// #![feature(saturating_bit_shifts)]
1049
- #[ doc = concat!( "assert_eq!(0b1000_0000_u8 .saturating_shr(u8 ::BITS), 0b0000_0000_u8 );" ) ]
1050
+ #[ doc = concat!( "assert_eq!(" , stringify! ( $SelfT ) , "::MAX .saturating_shr(" , stringify! ( $SelfT ) , " ::BITS - 1 ), 0 );") ]
1050
1051
/// ```
1051
1052
#[ unstable( feature = "saturating_bit_shifts" , issue = "103440" ) ]
1052
1053
#[ rustc_const_unstable( feature = "saturating_bit_shifts" , issue = "103440" ) ]
0 commit comments