@@ -115,7 +115,7 @@ unsafe fn bswap8(x: u8) -> u8 { x }
115
115
116
116
// `Int` + `SignedInt` implemented for signed integers
117
117
macro_rules! int_impl {
118
- ( $ActualT: ty, $UnsignedT: ty, $BITS: expr,
118
+ ( $SelfT : ty , $ ActualT: ty, $UnsignedT: ty, $BITS: expr,
119
119
$add_with_overflow: path,
120
120
$sub_with_overflow: path,
121
121
$mul_with_overflow: path) => {
@@ -139,13 +139,13 @@ macro_rules! int_impl {
139
139
// calling the `Bounded::min_value` function.
140
140
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
141
141
#[ allow( missing_docs) ]
142
- pub const MIN : $ActualT = ( -1 as $ActualT ) << ( $BITS - 1 ) ;
142
+ pub const MIN : $SelfT = ( -1 as $SelfT ) << ( $BITS - 1 ) ;
143
143
// FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0.
144
144
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
145
145
// calling the `Bounded::max_value` function.
146
146
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
147
147
#[ allow( missing_docs) ]
148
- pub const MAX : $ActualT = !<$ActualT >:: MIN ;
148
+ pub const MAX : $SelfT = !<$SelfT >:: MIN ;
149
149
150
150
/// Returns the smallest value that can be represented by this integer type.
151
151
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -639,31 +639,31 @@ macro_rules! int_impl {
639
639
640
640
#[ lang = "i8" ]
641
641
impl i8 {
642
- int_impl ! { i8 , u8 , 8 ,
642
+ int_impl ! { i8 , i8 , u8 , 8 ,
643
643
intrinsics:: i8_add_with_overflow,
644
644
intrinsics:: i8_sub_with_overflow,
645
645
intrinsics:: i8_mul_with_overflow }
646
646
}
647
647
648
648
#[ lang = "i16" ]
649
649
impl i16 {
650
- int_impl ! { i16 , u16 , 16 ,
650
+ int_impl ! { i16 , i16 , u16 , 16 ,
651
651
intrinsics:: i16_add_with_overflow,
652
652
intrinsics:: i16_sub_with_overflow,
653
653
intrinsics:: i16_mul_with_overflow }
654
654
}
655
655
656
656
#[ lang = "i32" ]
657
657
impl i32 {
658
- int_impl ! { i32 , u32 , 32 ,
658
+ int_impl ! { i32 , i32 , u32 , 32 ,
659
659
intrinsics:: i32_add_with_overflow,
660
660
intrinsics:: i32_sub_with_overflow,
661
661
intrinsics:: i32_mul_with_overflow }
662
662
}
663
663
664
664
#[ lang = "i64" ]
665
665
impl i64 {
666
- int_impl ! { i64 , u64 , 64 ,
666
+ int_impl ! { i64 , i64 , u64 , 64 ,
667
667
intrinsics:: i64_add_with_overflow,
668
668
intrinsics:: i64_sub_with_overflow,
669
669
intrinsics:: i64_mul_with_overflow }
@@ -672,7 +672,7 @@ impl i64 {
672
672
#[ cfg( target_pointer_width = "32" ) ]
673
673
#[ lang = "isize" ]
674
674
impl isize {
675
- int_impl ! { i32 , u32 , 32 ,
675
+ int_impl ! { isize , i32 , u32 , 32 ,
676
676
intrinsics:: i32_add_with_overflow,
677
677
intrinsics:: i32_sub_with_overflow,
678
678
intrinsics:: i32_mul_with_overflow }
@@ -681,15 +681,15 @@ impl isize {
681
681
#[ cfg( target_pointer_width = "64" ) ]
682
682
#[ lang = "isize" ]
683
683
impl isize {
684
- int_impl ! { i64 , u64 , 64 ,
684
+ int_impl ! { isize , i64 , u64 , 64 ,
685
685
intrinsics:: i64_add_with_overflow,
686
686
intrinsics:: i64_sub_with_overflow,
687
687
intrinsics:: i64_mul_with_overflow }
688
688
}
689
689
690
690
// `Int` + `UnsignedInt` implemented for signed integers
691
691
macro_rules! uint_impl {
692
- ( $ActualT: ty, $BITS: expr,
692
+ ( $SelfT : ty , $ ActualT: ty, $BITS: expr,
693
693
$ctpop: path,
694
694
$ctlz: path,
695
695
$cttz: path,
@@ -711,10 +711,10 @@ macro_rules! uint_impl {
711
711
712
712
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
713
713
#[ allow( missing_docs) ]
714
- pub const MIN : $ActualT = 0 as $ActualT ;
714
+ pub const MIN : $SelfT = 0 as $SelfT ;
715
715
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
716
716
#[ allow( missing_docs) ]
717
- pub const MAX : $ActualT = !0 as $ActualT ;
717
+ pub const MAX : $SelfT = !0 as $SelfT ;
718
718
719
719
/// Returns the smallest value that can be represented by this integer type.
720
720
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1210,7 +1210,7 @@ macro_rules! uint_impl {
1210
1210
1211
1211
#[ lang = "u8" ]
1212
1212
impl u8 {
1213
- uint_impl ! { u8 , 8 ,
1213
+ uint_impl ! { u8 , u8 , 8 ,
1214
1214
intrinsics:: ctpop8,
1215
1215
intrinsics:: ctlz8,
1216
1216
intrinsics:: cttz8,
@@ -1222,7 +1222,7 @@ impl u8 {
1222
1222
1223
1223
#[ lang = "u16" ]
1224
1224
impl u16 {
1225
- uint_impl ! { u16 , 16 ,
1225
+ uint_impl ! { u16 , u16 , 16 ,
1226
1226
intrinsics:: ctpop16,
1227
1227
intrinsics:: ctlz16,
1228
1228
intrinsics:: cttz16,
@@ -1234,7 +1234,7 @@ impl u16 {
1234
1234
1235
1235
#[ lang = "u32" ]
1236
1236
impl u32 {
1237
- uint_impl ! { u32 , 32 ,
1237
+ uint_impl ! { u32 , u32 , 32 ,
1238
1238
intrinsics:: ctpop32,
1239
1239
intrinsics:: ctlz32,
1240
1240
intrinsics:: cttz32,
@@ -1247,7 +1247,7 @@ impl u32 {
1247
1247
1248
1248
#[ lang = "u64" ]
1249
1249
impl u64 {
1250
- uint_impl ! { u64 , 64 ,
1250
+ uint_impl ! { u64 , u64 , 64 ,
1251
1251
intrinsics:: ctpop64,
1252
1252
intrinsics:: ctlz64,
1253
1253
intrinsics:: cttz64,
@@ -1260,7 +1260,7 @@ impl u64 {
1260
1260
#[ cfg( target_pointer_width = "32" ) ]
1261
1261
#[ lang = "usize" ]
1262
1262
impl usize {
1263
- uint_impl ! { u32 , 32 ,
1263
+ uint_impl ! { usize , u32 , 32 ,
1264
1264
intrinsics:: ctpop32,
1265
1265
intrinsics:: ctlz32,
1266
1266
intrinsics:: cttz32,
@@ -1273,7 +1273,7 @@ impl usize {
1273
1273
#[ cfg( target_pointer_width = "64" ) ]
1274
1274
#[ lang = "usize" ]
1275
1275
impl usize {
1276
- uint_impl ! { u64 , 64 ,
1276
+ uint_impl ! { usize , u64 , 64 ,
1277
1277
intrinsics:: ctpop64,
1278
1278
intrinsics:: ctlz64,
1279
1279
intrinsics:: cttz64,
0 commit comments