@@ -211,6 +211,7 @@ const fn u128_ilog2(v: u128) -> u32 {
211211pub struct Hexf < F > ( pub F ) ;
212212
213213// Adapted from https://github.com/ericseppanen/hexfloat2/blob/a5c27932f0ff/src/format.rs
214+ #[ cfg( not( feature = "compiler-builtins" ) ) ]
214215fn fmt_any_hex < F : Float > ( x : & F , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
215216 if x. is_sign_negative ( ) {
216217 write ! ( f, "-" ) ?;
@@ -244,6 +245,11 @@ fn fmt_any_hex<F: Float>(x: &F, f: &mut fmt::Formatter<'_>) -> fmt::Result {
244245 write ! ( f, "0x{leading}{sig:0mwidth$x}p{exponent:+}" )
245246}
246247
248+ #[ cfg( feature = "compiler-builtins" ) ]
249+ fn fmt_any_hex < F : Float > ( _x : & F , _f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
250+ unimplemented ! ( )
251+ }
252+
247253impl < F : Float > fmt:: LowerHex for Hexf < F > {
248254 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
249255 cfg_if ! {
@@ -259,13 +265,27 @@ impl<F: Float> fmt::LowerHex for Hexf<F> {
259265
260266impl < F : Float > fmt:: LowerHex for Hexf < ( F , F ) > {
261267 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+ }
263276 }
264277}
265278
266279impl < F : Float > fmt:: LowerHex for Hexf < ( F , i32 ) > {
267280 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+ }
269289 }
270290}
271291
@@ -287,7 +307,14 @@ where
287307 Hexf < T > : fmt:: LowerHex ,
288308{
289309 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+ }
291318 }
292319}
293320
@@ -296,7 +323,14 @@ where
296323 Hexf < T > : fmt:: LowerHex ,
297324{
298325 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+ }
300334 }
301335}
302336
0 commit comments