@@ -2,11 +2,10 @@ use std::num::NonZero;
2
2
use std:: ops:: Bound ;
3
3
use std:: { cmp, fmt} ;
4
4
5
- use rustc_abi:: Primitive :: { self , Float , Int , Pointer } ;
6
5
use rustc_abi:: {
7
- AddressSpace , Align , BackendRepr , FieldsShape , HasDataLayout , Integer , LayoutCalculator ,
8
- LayoutData , PointeeInfo , PointerKind , ReprOptions , Scalar , Size , TagEncoding , TargetDataLayout ,
9
- Variants ,
6
+ AddressSpace , Align , BackendRepr , ExternAbi , FieldIdx , FieldsShape , HasDataLayout , LayoutData ,
7
+ PointeeInfo , PointerKind , Primitive , ReprOptions , Scalar , Size , TagEncoding , TargetDataLayout ,
8
+ TyAbiInterface , VariantIdx , Variants ,
10
9
} ;
11
10
use rustc_error_messages:: DiagMessage ;
12
11
use rustc_errors:: {
@@ -19,9 +18,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension};
19
18
use rustc_session:: config:: OptLevel ;
20
19
use rustc_span:: symbol:: { Symbol , sym} ;
21
20
use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
22
- use rustc_target:: abi:: call:: FnAbi ;
23
- use rustc_target:: abi:: { FieldIdx , TyAbiInterface , VariantIdx , call} ;
24
- use rustc_target:: spec:: abi:: Abi as SpecAbi ;
21
+ use rustc_target:: callconv:: FnAbi ;
25
22
use rustc_target:: spec:: {
26
23
HasTargetSpec , HasWasmCAbiOpt , HasX86AbiOpt , PanicStrategy , Target , WasmCAbi , X86Abi ,
27
24
} ;
@@ -86,16 +83,16 @@ impl abi::Integer {
86
83
repr : & ReprOptions ,
87
84
min : i128 ,
88
85
max : i128 ,
89
- ) -> ( Integer , bool ) {
86
+ ) -> ( abi :: Integer , bool ) {
90
87
// Theoretically, negative values could be larger in unsigned representation
91
88
// than the unsigned representation of the signed minimum. However, if there
92
89
// are any negative values, the only valid unsigned representation is u128
93
90
// which can fit all i128 values, so the result remains unaffected.
94
- let unsigned_fit = Integer :: fit_unsigned ( cmp:: max ( min as u128 , max as u128 ) ) ;
95
- let signed_fit = cmp:: max ( Integer :: fit_signed ( min) , Integer :: fit_signed ( max) ) ;
91
+ let unsigned_fit = abi :: Integer :: fit_unsigned ( cmp:: max ( min as u128 , max as u128 ) ) ;
92
+ let signed_fit = cmp:: max ( abi :: Integer :: fit_signed ( min) , abi :: Integer :: fit_signed ( max) ) ;
96
93
97
94
if let Some ( ity) = repr. int {
98
- let discr = Integer :: from_attr ( & tcx, ity) ;
95
+ let discr = abi :: Integer :: from_attr ( & tcx, ity) ;
99
96
let fit = if ity. is_signed ( ) { signed_fit } else { unsigned_fit } ;
100
97
if discr < fit {
101
98
bug ! (
@@ -113,7 +110,7 @@ impl abi::Integer {
113
110
tcx. data_layout ( ) . c_enum_min_size
114
111
} else {
115
112
// repr(Rust) enums try to be as small as possible
116
- Integer :: I8
113
+ abi :: Integer :: I8
117
114
} ;
118
115
119
116
// If there are no negative values, we can use the unsigned fit.
@@ -154,10 +151,10 @@ impl Primitive {
154
151
#[ inline]
155
152
fn to_ty < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
156
153
match * self {
157
- Int ( i, signed) => i. to_ty ( tcx, signed) ,
158
- Float ( f) => f. to_ty ( tcx) ,
154
+ Primitive :: Int ( i, signed) => i. to_ty ( tcx, signed) ,
155
+ Primitive :: Float ( f) => f. to_ty ( tcx) ,
159
156
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
160
- Pointer ( _) => Ty :: new_mut_ptr ( tcx, tcx. types . unit ) ,
157
+ Primitive :: Pointer ( _) => Ty :: new_mut_ptr ( tcx, tcx. types . unit ) ,
161
158
}
162
159
}
163
160
@@ -166,13 +163,13 @@ impl Primitive {
166
163
#[ inline]
167
164
fn to_int_ty < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
168
165
match * self {
169
- Int ( i, signed) => i. to_ty ( tcx, signed) ,
166
+ Primitive :: Int ( i, signed) => i. to_ty ( tcx, signed) ,
170
167
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
171
- Pointer ( _) => {
168
+ Primitive :: Pointer ( _) => {
172
169
let signed = false ;
173
170
tcx. data_layout ( ) . ptr_sized_integer ( ) . to_ty ( tcx, signed)
174
171
}
175
- Float ( _) => bug ! ( "floats do not have an int type" ) ,
172
+ Primitive :: Float ( _) => bug ! ( "floats do not have an int type" ) ,
176
173
}
177
174
}
178
175
}
@@ -299,13 +296,13 @@ impl<'tcx> IntoDiagArg for LayoutError<'tcx> {
299
296
300
297
#[ derive( Clone , Copy ) ]
301
298
pub struct LayoutCx < ' tcx > {
302
- pub calc : LayoutCalculator < TyCtxt < ' tcx > > ,
299
+ pub calc : abi :: LayoutCalculator < TyCtxt < ' tcx > > ,
303
300
pub param_env : ty:: ParamEnv < ' tcx > ,
304
301
}
305
302
306
303
impl < ' tcx > LayoutCx < ' tcx > {
307
304
pub fn new ( tcx : TyCtxt < ' tcx > , param_env : ty:: ParamEnv < ' tcx > ) -> Self {
308
- Self { calc : LayoutCalculator :: new ( tcx) , param_env }
305
+ Self { calc : abi :: LayoutCalculator :: new ( tcx) , param_env }
309
306
}
310
307
}
311
308
@@ -645,7 +642,7 @@ impl<T, E> MaybeResult<T> for Result<T, E> {
645
642
}
646
643
}
647
644
648
- pub type TyAndLayout < ' tcx > = rustc_target :: abi :: TyAndLayout < ' tcx , Ty < ' tcx > > ;
645
+ pub type TyAndLayout < ' tcx > = rustc_abi :: TyAndLayout < ' tcx , Ty < ' tcx > > ;
649
646
650
647
/// Trait for contexts that want to be able to compute layouts of types.
651
648
/// This automatically gives access to `LayoutOf`, through a blanket `impl`.
@@ -1048,7 +1045,7 @@ where
1048
1045
if let Some ( variant) = data_variant {
1049
1046
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
1050
1047
// (requires passing in the expected address space from the caller)
1051
- let ptr_end = offset + Pointer ( AddressSpace :: DATA ) . size ( cx) ;
1048
+ let ptr_end = offset + Primitive :: Pointer ( AddressSpace :: DATA ) . size ( cx) ;
1052
1049
for i in 0 ..variant. fields . count ( ) {
1053
1050
let field_start = variant. fields . offset ( i) ;
1054
1051
if field_start <= offset {
@@ -1163,7 +1160,7 @@ where
1163
1160
/// affects various optimizations and codegen.
1164
1161
#[ inline]
1165
1162
#[ tracing:: instrument( level = "debug" , skip( tcx) ) ]
1166
- pub fn fn_can_unwind ( tcx : TyCtxt < ' _ > , fn_def_id : Option < DefId > , abi : SpecAbi ) -> bool {
1163
+ pub fn fn_can_unwind ( tcx : TyCtxt < ' _ > , fn_def_id : Option < DefId > , abi : ExternAbi ) -> bool {
1167
1164
if let Some ( did) = fn_def_id {
1168
1165
// Special attribute for functions which can't unwind.
1169
1166
if tcx. codegen_fn_attrs ( did) . flags . contains ( CodegenFnAttrFlags :: NEVER_UNWIND ) {
@@ -1195,7 +1192,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
1195
1192
// ABIs have such an option. Otherwise the only other thing here is Rust
1196
1193
// itself, and those ABIs are determined by the panic strategy configured
1197
1194
// for this compilation.
1198
- use SpecAbi :: * ;
1195
+ use ExternAbi :: * ;
1199
1196
match abi {
1200
1197
C { unwind }
1201
1198
| System { unwind }
@@ -1231,17 +1228,16 @@ pub enum FnAbiError<'tcx> {
1231
1228
Layout ( LayoutError < ' tcx > ) ,
1232
1229
1233
1230
/// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI.
1234
- AdjustForForeignAbi ( call :: AdjustForForeignAbiError ) ,
1231
+ AdjustForForeignAbi ( rustc_target :: callconv :: AdjustForForeignAbiError ) ,
1235
1232
}
1236
1233
1237
1234
impl < ' a , ' b , G : EmissionGuarantee > Diagnostic < ' a , G > for FnAbiError < ' b > {
1238
1235
fn into_diag ( self , dcx : DiagCtxtHandle < ' a > , level : Level ) -> Diag < ' a , G > {
1239
1236
match self {
1240
1237
Self :: Layout ( e) => e. into_diagnostic ( ) . into_diag ( dcx, level) ,
1241
- Self :: AdjustForForeignAbi ( call:: AdjustForForeignAbiError :: Unsupported {
1242
- arch,
1243
- abi,
1244
- } ) => UnsupportedFnAbi { arch, abi : abi. name ( ) } . into_diag ( dcx, level) ,
1238
+ Self :: AdjustForForeignAbi (
1239
+ rustc_target:: callconv:: AdjustForForeignAbiError :: Unsupported { arch, abi } ,
1240
+ ) => UnsupportedFnAbi { arch, abi : abi. name ( ) } . into_diag ( dcx, level) ,
1245
1241
}
1246
1242
}
1247
1243
}
0 commit comments