@@ -103,10 +103,6 @@ trait FloatRepr: Copy + Default + Eq + fmt::Display + fmt::Debug {
103103
104104 const KIND : FpKind ;
105105
106- // HACK(eddyb) this has to be overwritable because we have more than one
107- // format with the same `BIT_WIDTH`, so it's not unambiguous on its own.
108- const REPR_TAG : u8 = Self :: BIT_WIDTH as u8 ;
109-
110106 fn short_lowercase_name ( ) -> String {
111107 Self :: NAME . to_ascii_lowercase ( ) . replace ( "ieee" , "f" )
112108 }
@@ -137,20 +133,13 @@ macro_rules! float_reprs {
137133 extern fn = $cxx_apf_eval_fuzz_op: ident;
138134 $( type HardFloat = $hard_float_ty: ty; ) ?
139135 } ) +) => {
140- // HACK(eddyb) helper macro used to actually handle all types uniformly.
141- macro_rules! dispatch_any_float_repr_by_repr_tag {
142- ( match $repr_tag_value: ident { for <$ty_var: ident: FloatRepr > => $e: expr } ) => {
143- // NOTE(eddyb) this doubles as an overlap check: `REPR_TAG`
144- // values across *all* `FloatRepr` `impl` *must* be unique.
145- #[ deny( unreachable_patterns) ]
146- match $repr_tag_value {
147- $( $name:: REPR_TAG => {
148- type $ty_var = $name;
149- $e;
150- } ) +
151- _ => { }
152- }
153- }
136+ macro_rules! for_each_repr {
137+ ( for $ty_var: ident in all_floats!( ) $block: block) => {
138+ $( {
139+ type $ty_var = $crate:: $name;
140+ $block
141+ } ) +
142+ } ;
154143 }
155144
156145 #[ allow( non_camel_case_types) ]
@@ -185,8 +174,6 @@ macro_rules! float_reprs {
185174 const NAME : & ' static str = stringify!( $name) ;
186175 const KIND : FpKind = FpKind :: $name;
187176
188- const REPR_TAG : u8 = $repr_tag;
189-
190177 fn to_ap( self ) -> Self :: RustcApFloat {
191178 Self :: RustcApFloat :: from_bits( self . to_bits_u128( ) )
192179 }
@@ -313,6 +300,8 @@ float_reprs! {
313300 }
314301}
315302
303+ pub ( crate ) use for_each_repr;
304+
316305fn main ( ) {
317306 let cli_args = Args :: parse ( ) ;
318307
@@ -333,20 +322,7 @@ fn main() {
333322 }
334323 }
335324 Commands :: Decode { files } => run_decode_subcmd ( files, & cli_args) ,
336- Commands :: Bruteforce { .. } => {
337- let mut any_mismatches = false ;
338- for repr_tag in 0 ..=u8:: MAX {
339- dispatch_any_float_repr_by_repr_tag ! ( match repr_tag {
340- for <F : FloatRepr > => {
341- any_mismatches |= exhaustive:: run_exhaustive:: <F >( & cli_args) . is_err( ) ;
342- }
343- } ) ;
344- }
345- if any_mismatches {
346- // FIXME(eddyb) use `fn main() -> ExitStatus`.
347- std:: process:: exit ( 1 ) ;
348- }
349- }
325+ Commands :: Bruteforce { .. } => exhaustive:: run_for_all_floats ( & cli_args) ,
350326 }
351327 return ;
352328 }
0 commit comments