@@ -546,6 +546,7 @@ mod imp {
546546 impl_Exp ! ( i8 , u8 , i16 , u16 , i32 , u32 , isize , usize as u32 via to_u32 named exp_u32) ;
547547 impl_Exp ! ( i64 , u64 as u64 via to_u64 named exp_u64) ;
548548}
549+ #[ cfg( not( no_iu128_fmt) ) ]
549550impl_Exp ! ( i128 , u128 as u128 via to_u128 named exp_u128) ;
550551
551552/// Helper function for writing a u64 into `buf` going from last to first, with `curr`.
@@ -638,21 +639,29 @@ fn parse_u64_into<const N: usize>(mut n: u64, buf: &mut [MaybeUninit<u8>; N], cu
638639#[ stable( feature = "rust1" , since = "1.0.0" ) ]
639640impl fmt:: Display for u128 {
640641 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
641- fmt_u128 ( * self , true , f)
642+ if cfg ! ( no_iu128_fmt) {
643+ panic ! ( "u128 formatting support is turned off" )
644+ } else {
645+ fmt_u128 ( * self , true , f)
646+ }
642647 }
643648}
644649
645650#[ stable( feature = "rust1" , since = "1.0.0" ) ]
646651impl fmt:: Display for i128 {
647652 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
648- let is_nonnegative = * self >= 0 ;
649- let n = if is_nonnegative {
650- self . to_u128 ( )
653+ if cfg ! ( no_iu128_fmt) {
654+ panic ! ( "u128 formatting support is turned off" )
651655 } else {
652- // convert the negative num to positive by summing 1 to its 2s complement
653- ( !self . to_u128 ( ) ) . wrapping_add ( 1 )
654- } ;
655- fmt_u128 ( n, is_nonnegative, f)
656+ let is_nonnegative = * self >= 0 ;
657+ let n = if is_nonnegative {
658+ self . to_u128 ( )
659+ } else {
660+ // convert the negative num to positive by summing 1 to its 2s complement
661+ ( !self . to_u128 ( ) ) . wrapping_add ( 1 )
662+ } ;
663+ fmt_u128 ( n, is_nonnegative, f)
664+ }
656665 }
657666}
658667
0 commit comments