@@ -2,11 +2,15 @@ use std::num::NonZero;
22use std:: ops:: Bound ;
33use std:: { cmp, fmt} ;
44
5+ use rustc_abi:: Primitive :: { self , Float , Int , Pointer } ;
6+ use rustc_abi:: {
7+ Abi , AddressSpace , Align , FieldsShape , HasDataLayout , Integer , LayoutCalculator , LayoutS ,
8+ PointeeInfo , PointerKind , ReprOptions , Scalar , Size , TagEncoding , TargetDataLayout , Variants ,
9+ } ;
510use rustc_error_messages:: DiagMessage ;
611use rustc_errors:: {
712 Diag , DiagArgValue , DiagCtxtHandle , Diagnostic , EmissionGuarantee , IntoDiagArg , Level ,
813} ;
9- use rustc_hir as hir;
1014use rustc_hir:: LangItem ;
1115use rustc_hir:: def_id:: DefId ;
1216use rustc_index:: IndexVec ;
@@ -15,10 +19,11 @@ use rustc_session::config::OptLevel;
1519use rustc_span:: symbol:: { Symbol , sym} ;
1620use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
1721use rustc_target:: abi:: call:: FnAbi ;
18- use rustc_target:: abi:: * ;
22+ use rustc_target:: abi:: { FieldIdx , TyAbiInterface , VariantIdx , call } ;
1923use rustc_target:: spec:: abi:: Abi as SpecAbi ;
2024use rustc_target:: spec:: { HasTargetSpec , HasWasmCAbiOpt , PanicStrategy , Target , WasmCAbi } ;
2125use tracing:: debug;
26+ use { rustc_abi as abi, rustc_hir as hir} ;
2227
2328use crate :: error:: UnsupportedFnAbi ;
2429use crate :: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
@@ -27,9 +32,10 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
2732use crate :: ty:: { self , CoroutineArgsExt , Ty , TyCtxt , TypeVisitableExt } ;
2833
2934#[ extension( pub trait IntegerExt ) ]
30- impl Integer {
35+ impl abi :: Integer {
3136 #[ inline]
3237 fn to_ty < ' tcx > ( & self , tcx : TyCtxt < ' tcx > , signed : bool ) -> Ty < ' tcx > {
38+ use abi:: Integer :: { I8 , I16 , I32 , I64 , I128 } ;
3339 match ( * self , signed) {
3440 ( I8 , false ) => tcx. types . u8 ,
3541 ( I16 , false ) => tcx. types . u16 ,
@@ -44,7 +50,8 @@ impl Integer {
4450 }
4551 }
4652
47- fn from_int_ty < C : HasDataLayout > ( cx : & C , ity : ty:: IntTy ) -> Integer {
53+ fn from_int_ty < C : HasDataLayout > ( cx : & C , ity : ty:: IntTy ) -> abi:: Integer {
54+ use abi:: Integer :: { I8 , I16 , I32 , I64 , I128 } ;
4855 match ity {
4956 ty:: IntTy :: I8 => I8 ,
5057 ty:: IntTy :: I16 => I16 ,
@@ -54,7 +61,8 @@ impl Integer {
5461 ty:: IntTy :: Isize => cx. data_layout ( ) . ptr_sized_integer ( ) ,
5562 }
5663 }
57- fn from_uint_ty < C : HasDataLayout > ( cx : & C , ity : ty:: UintTy ) -> Integer {
64+ fn from_uint_ty < C : HasDataLayout > ( cx : & C , ity : ty:: UintTy ) -> abi:: Integer {
65+ use abi:: Integer :: { I8 , I16 , I32 , I64 , I128 } ;
5866 match ity {
5967 ty:: UintTy :: U8 => I8 ,
6068 ty:: UintTy :: U16 => I16 ,
@@ -102,7 +110,7 @@ impl Integer {
102110 tcx. data_layout ( ) . c_enum_min_size
103111 } else {
104112 // repr(Rust) enums try to be as small as possible
105- I8
113+ Integer :: I8
106114 } ;
107115
108116 // If there are no negative values, we can use the unsigned fit.
@@ -115,9 +123,10 @@ impl Integer {
115123}
116124
117125#[ extension( pub trait FloatExt ) ]
118- impl Float {
126+ impl abi :: Float {
119127 #[ inline]
120128 fn to_ty < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
129+ use abi:: Float :: * ;
121130 match * self {
122131 F16 => tcx. types . f16 ,
123132 F32 => tcx. types . f32 ,
@@ -127,6 +136,7 @@ impl Float {
127136 }
128137
129138 fn from_float_ty ( fty : ty:: FloatTy ) -> Self {
139+ use abi:: Float :: * ;
130140 match fty {
131141 ty:: FloatTy :: F16 => F16 ,
132142 ty:: FloatTy :: F32 => F32 ,
0 commit comments