@@ -25,10 +25,7 @@ impl Target {
2525 let mut base = Target {
2626 llvm_target : json. llvm_target ,
2727 metadata : Default :: default ( ) ,
28- pointer_width : json
29- . target_pointer_width
30- . parse ( )
31- . map_err ( |err| format ! ( "invalid target-pointer-width: {err}" ) ) ?,
28+ pointer_width : json. target_pointer_width ,
3229 data_layout : json. data_layout ,
3330 arch : json. arch ,
3431 options : Default :: default ( ) ,
@@ -245,19 +242,17 @@ impl ToJson for Target {
245242 target. update_to_cli ( ) ;
246243
247244 macro_rules! target_val {
248- ( $attr: ident) => { {
249- let name = ( stringify!( $attr) ) . replace( "_" , "-" ) ;
250- d. insert( name, target. $attr. to_json( ) ) ;
245+ ( $attr: ident) => {
246+ target_val!( $attr, ( stringify!( $attr) ) . replace( "_" , "-" ) )
247+ } ;
248+ ( $attr: ident, $json_name: expr) => { {
249+ let name = $json_name;
250+ d. insert( name. into( ) , target. $attr. to_json( ) ) ;
251251 } } ;
252252 }
253253
254254 macro_rules! target_option_val {
255- ( $attr: ident) => { {
256- let name = ( stringify!( $attr) ) . replace( "_" , "-" ) ;
257- if default . $attr != target. $attr {
258- d. insert( name, target. $attr. to_json( ) ) ;
259- }
260- } } ;
255+ ( $attr: ident) => { { target_option_val!( $attr, ( stringify!( $attr) ) . replace( "_" , "-" ) ) } } ;
261256 ( $attr: ident, $json_name: expr) => { {
262257 let name = $json_name;
263258 if default . $attr != target. $attr {
@@ -290,7 +285,7 @@ impl ToJson for Target {
290285
291286 target_val ! ( llvm_target) ;
292287 target_val ! ( metadata) ;
293- d . insert ( "target-pointer-width" . to_string ( ) , self . pointer_width . to_string ( ) . to_json ( ) ) ;
288+ target_val ! ( pointer_width , "target-pointer-width" ) ;
294289 target_val ! ( arch) ;
295290 target_val ! ( data_layout) ;
296291
@@ -463,7 +458,7 @@ struct TargetSpecJsonMetadata {
463458#[ serde( deny_unknown_fields) ]
464459struct TargetSpecJson {
465460 llvm_target : StaticCow < str > ,
466- target_pointer_width : String ,
461+ target_pointer_width : u16 ,
467462 data_layout : StaticCow < str > ,
468463 arch : StaticCow < str > ,
469464
0 commit comments