@@ -211,6 +211,7 @@ const fn u128_ilog2(v: u128) -> u32 {
211
211
pub struct Hexf < F > ( pub F ) ;
212
212
213
213
// Adapted from https://github.com/ericseppanen/hexfloat2/blob/a5c27932f0ff/src/format.rs
214
+ #[ cfg( not( feature = "compiler-builtins" ) ) ]
214
215
fn fmt_any_hex < F : Float > ( x : & F , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
215
216
if x. is_sign_negative ( ) {
216
217
write ! ( f, "-" ) ?;
@@ -244,6 +245,11 @@ fn fmt_any_hex<F: Float>(x: &F, f: &mut fmt::Formatter<'_>) -> fmt::Result {
244
245
write ! ( f, "0x{leading}{sig:0mwidth$x}p{exponent:+}" )
245
246
}
246
247
248
+ #[ cfg( feature = "compiler-builtins" ) ]
249
+ fn fmt_any_hex < F : Float > ( _x : & F , _f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
250
+ unimplemented ! ( )
251
+ }
252
+
247
253
impl < F : Float > fmt:: LowerHex for Hexf < F > {
248
254
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
249
255
cfg_if ! {
@@ -259,13 +265,27 @@ impl<F: Float> fmt::LowerHex for Hexf<F> {
259
265
260
266
impl < F : Float > fmt:: LowerHex for Hexf < ( F , F ) > {
261
267
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
262
- write ! ( f, "({:x}, {:x})" , Hexf ( self . 0.0 ) , Hexf ( self . 0.1 ) )
268
+ cfg_if ! {
269
+ if #[ cfg( feature = "compiler-builtins" ) ] {
270
+ let _ = f;
271
+ unimplemented!( )
272
+ } else {
273
+ write!( f, "({:x}, {:x})" , Hexf ( self . 0.0 ) , Hexf ( self . 0.1 ) )
274
+ }
275
+ }
263
276
}
264
277
}
265
278
266
279
impl < F : Float > fmt:: LowerHex for Hexf < ( F , i32 ) > {
267
280
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
268
- write ! ( f, "({:x}, {:x})" , Hexf ( self . 0.0 ) , Hexf ( self . 0.1 ) )
281
+ cfg_if ! {
282
+ if #[ cfg( feature = "compiler-builtins" ) ] {
283
+ let _ = f;
284
+ unimplemented!( )
285
+ } else {
286
+ write!( f, "({:x}, {:x})" , Hexf ( self . 0.0 ) , Hexf ( self . 0.1 ) )
287
+ }
288
+ }
269
289
}
270
290
}
271
291
@@ -287,7 +307,14 @@ where
287
307
Hexf < T > : fmt:: LowerHex ,
288
308
{
289
309
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
290
- fmt:: LowerHex :: fmt ( self , f)
310
+ cfg_if ! {
311
+ if #[ cfg( feature = "compiler-builtins" ) ] {
312
+ let _ = f;
313
+ unimplemented!( )
314
+ } else {
315
+ fmt:: LowerHex :: fmt( self , f)
316
+ }
317
+ }
291
318
}
292
319
}
293
320
@@ -296,7 +323,14 @@ where
296
323
Hexf < T > : fmt:: LowerHex ,
297
324
{
298
325
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
299
- fmt:: LowerHex :: fmt ( self , f)
326
+ cfg_if ! {
327
+ if #[ cfg( feature = "compiler-builtins" ) ] {
328
+ let _ = f;
329
+ unimplemented!( )
330
+ } else {
331
+ fmt:: LowerHex :: fmt( self , f)
332
+ }
333
+ }
300
334
}
301
335
}
302
336
0 commit comments