File tree Expand file tree Collapse file tree 3 files changed +17
-19
lines changed
rustc_codegen_ssa/src/traits Expand file tree Collapse file tree 3 files changed +17
-19
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,10 @@ pub trait DerivedTypeCodegenMethods<'tcx>:
4444 BaseTypeCodegenMethods + MiscCodegenMethods < ' tcx > + HasTyCtxt < ' tcx > + HasTypingEnv < ' tcx >
4545{
4646 fn type_int ( & self ) -> Self :: Type {
47- match & self . sess ( ) . target . c_int_width [ .. ] {
48- "16" => self . type_i16 ( ) ,
49- "32" => self . type_i32 ( ) ,
50- "64" => self . type_i64 ( ) ,
47+ match & self . sess ( ) . target . c_int_width {
48+ 16 => self . type_i16 ( ) ,
49+ 32 => self . type_i32 ( ) ,
50+ 64 => self . type_i64 ( ) ,
5151 width => bug ! ( "Unsupported c_int_width: {}" , width) ,
5252 }
5353 }
Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ impl Target {
8080 base. $key_name = s;
8181 }
8282 } ) ;
83+ ( $key_name: ident = $json_name: expr, u64 as $int_ty: ty) => ( {
84+ let name = $json_name;
85+ if let Some ( s) = obj. remove( name) . and_then( |b| b. as_u64( ) ) {
86+ base. $key_name = s as $int_ty;
87+ }
88+ } ) ;
8389 ( $key_name: ident, bool ) => ( {
8490 let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
8591 if let Some ( s) = obj. remove( & name) . and_then( |b| b. as_bool( ) ) {
@@ -554,7 +560,7 @@ impl Target {
554560 }
555561 }
556562
557- key ! ( c_int_width = "target-c-int-width" ) ;
563+ key ! ( c_int_width = "target-c-int-width" , u64 as u16 ) ;
558564 key ! ( c_enum_min_bits, Option <u64 >) ; // if None, matches c_int_width
559565 key ! ( os) ;
560566 key ! ( env) ;
Original file line number Diff line number Diff line change @@ -2213,18 +2213,10 @@ impl Target {
22132213 } ) ;
22142214 }
22152215
2216- dl. c_enum_min_size = self
2217- . c_enum_min_bits
2218- . map_or_else (
2219- || {
2220- self . c_int_width
2221- . parse ( )
2222- . map_err ( |_| String :: from ( "failed to parse c_int_width" ) )
2223- } ,
2224- Ok ,
2225- )
2226- . and_then ( |i| Integer :: from_size ( Size :: from_bits ( i) ) )
2227- . map_err ( |err| TargetDataLayoutErrors :: InvalidBitsSize { err } ) ?;
2216+ dl. c_enum_min_size = Integer :: from_size ( Size :: from_bits (
2217+ self . c_enum_min_bits . unwrap_or ( self . c_int_width as _ ) ,
2218+ ) )
2219+ . map_err ( |err| TargetDataLayoutErrors :: InvalidBitsSize { err } ) ?;
22282220
22292221 Ok ( dl)
22302222 }
@@ -2286,7 +2278,7 @@ pub struct TargetOptions {
22862278 /// Used as the `target_endian` `cfg` variable. Defaults to little endian.
22872279 pub endian : Endian ,
22882280 /// Width of c_int type. Defaults to "32".
2289- pub c_int_width : StaticCow < str > ,
2281+ pub c_int_width : u16 ,
22902282 /// OS name to use for conditional compilation (`target_os`). Defaults to "none".
22912283 /// "none" implies a bare metal target without `std` library.
22922284 /// A couple of targets having `std` also use "unknown" as an `os` value,
@@ -2783,7 +2775,7 @@ impl Default for TargetOptions {
27832775 fn default ( ) -> TargetOptions {
27842776 TargetOptions {
27852777 endian : Endian :: Little ,
2786- c_int_width : "32" . into ( ) ,
2778+ c_int_width : 32 ,
27872779 os : "none" . into ( ) ,
27882780 env : "" . into ( ) ,
27892781 abi : "" . into ( ) ,
You can’t perform that action at this time.
0 commit comments