@@ -10,10 +10,10 @@ trait GeneralFormat: PartialOrd {
1010}
1111
1212macro_rules! impl_general_format {
13- ( $( $t : ident ) * ) => {
14- $( impl GeneralFormat for $t {
13+ ( $( $ty : ty ) * ) => {
14+ $( impl GeneralFormat for $ty {
1515 fn already_rounded_value_should_use_exponential( & self ) -> bool {
16- let abs = $t :: abs( * self ) ;
16+ let abs = $ty :: abs( * self ) ;
1717 ( abs != 0.0 && abs < 1e-4 ) || abs >= 1e+16
1818 }
1919 } ) *
@@ -23,6 +23,8 @@ macro_rules! impl_general_format {
2323#[ cfg( target_has_reliable_f16) ]
2424impl_general_format ! { f16 }
2525impl_general_format ! { f32 f64 }
26+ #[ cfg( target_has_reliable_f128) ]
27+ impl_general_format ! { f128 }
2628
2729// Don't inline this so callers don't use the stack space this function
2830// requires unless they have to.
@@ -198,31 +200,31 @@ where
198200}
199201
200202macro_rules! floating {
201- ( $( $ty : ident ) * ) => {
203+ ( $( $tyy : ty ) * ) => {
202204 $(
203205 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
204- impl Debug for $ty {
206+ impl Debug for $tyy {
205207 fn fmt( & self , fmt: & mut Formatter <' _>) -> Result {
206208 float_to_general_debug( fmt, self )
207209 }
208210 }
209211
210212 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
211- impl Display for $ty {
213+ impl Display for $tyy {
212214 fn fmt( & self , fmt: & mut Formatter <' _>) -> Result {
213215 float_to_decimal_display( fmt, self )
214216 }
215217 }
216218
217219 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
218- impl LowerExp for $ty {
220+ impl LowerExp for $tyy {
219221 fn fmt( & self , fmt: & mut Formatter <' _>) -> Result {
220222 float_to_exponential_common( fmt, self , false )
221223 }
222224 }
223225
224226 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
225- impl UpperExp for $ty {
227+ impl UpperExp for $tyy {
226228 fn fmt( & self , fmt: & mut Formatter <' _>) -> Result {
227229 float_to_exponential_common( fmt, self , true )
228230 }
@@ -231,10 +233,11 @@ macro_rules! floating {
231233 } ;
232234}
233235
234- floating ! { f32 f64 }
235-
236236#[ cfg( target_has_reliable_f16) ]
237237floating ! { f16 }
238+ floating ! { f32 f64 }
239+ #[ cfg( target_has_reliable_f128) ]
240+ floating ! { f128 }
238241
239242// FIXME(f16_f128): A fallback is used when the backend+target does not support f16 well, in order
240243// to avoid ICEs.
@@ -275,10 +278,38 @@ impl UpperExp for f16 {
275278 }
276279}
277280
281+ #[ cfg( not( target_has_reliable_f128) ) ]
278282#[ stable( feature = "rust1" , since = "1.0.0" ) ]
279283impl Debug for f128 {
280284 #[ inline]
281285 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result {
282286 write ! ( f, "{:#034x}" , self . to_bits( ) )
283287 }
284288}
289+
290+ #[ cfg( not( target_has_reliable_f128) ) ]
291+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
292+ impl Display for f128 {
293+ #[ inline]
294+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result {
295+ Debug :: fmt ( self , fmt)
296+ }
297+ }
298+
299+ #[ cfg( not( target_has_reliable_f128) ) ]
300+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
301+ impl LowerExp for f128 {
302+ #[ inline]
303+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result {
304+ Debug :: fmt ( self , fmt)
305+ }
306+ }
307+
308+ #[ cfg( not( target_has_reliable_f128) ) ]
309+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
310+ impl UpperExp for f128 {
311+ #[ inline]
312+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result {
313+ Debug :: fmt ( self , fmt)
314+ }
315+ }
0 commit comments