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>:
44
44
BaseTypeCodegenMethods + MiscCodegenMethods < ' tcx > + HasTyCtxt < ' tcx > + HasTypingEnv < ' tcx >
45
45
{
46
46
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 ( ) ,
51
51
width => bug ! ( "Unsupported c_int_width: {}" , width) ,
52
52
}
53
53
}
Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ impl Target {
80
80
base. $key_name = s;
81
81
}
82
82
} ) ;
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
+ } ) ;
83
89
( $key_name: ident, bool ) => ( {
84
90
let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
85
91
if let Some ( s) = obj. remove( & name) . and_then( |b| b. as_bool( ) ) {
@@ -554,7 +560,7 @@ impl Target {
554
560
}
555
561
}
556
562
557
- key ! ( c_int_width = "target-c-int-width" ) ;
563
+ key ! ( c_int_width = "target-c-int-width" , u64 as u16 ) ;
558
564
key ! ( c_enum_min_bits, Option <u64 >) ; // if None, matches c_int_width
559
565
key ! ( os) ;
560
566
key ! ( env) ;
Original file line number Diff line number Diff line change @@ -2213,18 +2213,10 @@ impl Target {
2213
2213
} ) ;
2214
2214
}
2215
2215
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 } ) ?;
2228
2220
2229
2221
Ok ( dl)
2230
2222
}
@@ -2286,7 +2278,7 @@ pub struct TargetOptions {
2286
2278
/// Used as the `target_endian` `cfg` variable. Defaults to little endian.
2287
2279
pub endian : Endian ,
2288
2280
/// Width of c_int type. Defaults to "32".
2289
- pub c_int_width : StaticCow < str > ,
2281
+ pub c_int_width : u16 ,
2290
2282
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
2291
2283
/// "none" implies a bare metal target without `std` library.
2292
2284
/// A couple of targets having `std` also use "unknown" as an `os` value,
@@ -2783,7 +2775,7 @@ impl Default for TargetOptions {
2783
2775
fn default ( ) -> TargetOptions {
2784
2776
TargetOptions {
2785
2777
endian : Endian :: Little ,
2786
- c_int_width : "32" . into ( ) ,
2778
+ c_int_width : 32 ,
2787
2779
os : "none" . into ( ) ,
2788
2780
env : "" . into ( ) ,
2789
2781
abi : "" . into ( ) ,
You can’t perform that action at this time.
0 commit comments