@@ -2,11 +2,15 @@ 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
+ use rustc_abi:: {
7
+ Abi , AddressSpace , Align , FieldsShape , HasDataLayout , Integer , LayoutCalculator , LayoutS ,
8
+ PointeeInfo , PointerKind , ReprOptions , Scalar , Size , TagEncoding , TargetDataLayout , Variants ,
9
+ } ;
5
10
use rustc_error_messages:: DiagMessage ;
6
11
use rustc_errors:: {
7
12
Diag , DiagArgValue , DiagCtxtHandle , Diagnostic , EmissionGuarantee , IntoDiagArg , Level ,
8
13
} ;
9
- use rustc_hir as hir;
10
14
use rustc_hir:: LangItem ;
11
15
use rustc_hir:: def_id:: DefId ;
12
16
use rustc_index:: IndexVec ;
@@ -15,10 +19,11 @@ use rustc_session::config::OptLevel;
15
19
use rustc_span:: symbol:: { Symbol , sym} ;
16
20
use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
17
21
use rustc_target:: abi:: call:: FnAbi ;
18
- use rustc_target:: abi:: * ;
22
+ use rustc_target:: abi:: { FieldIdx , TyAbiInterface , VariantIdx , call } ;
19
23
use rustc_target:: spec:: abi:: Abi as SpecAbi ;
20
24
use rustc_target:: spec:: { HasTargetSpec , HasWasmCAbiOpt , PanicStrategy , Target , WasmCAbi } ;
21
25
use tracing:: debug;
26
+ use { rustc_abi as abi, rustc_hir as hir} ;
22
27
23
28
use crate :: error:: UnsupportedFnAbi ;
24
29
use crate :: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
@@ -27,9 +32,10 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
27
32
use crate :: ty:: { self , CoroutineArgsExt , Ty , TyCtxt , TypeVisitableExt } ;
28
33
29
34
#[ extension( pub trait IntegerExt ) ]
30
- impl Integer {
35
+ impl abi :: Integer {
31
36
#[ inline]
32
37
fn to_ty < ' tcx > ( & self , tcx : TyCtxt < ' tcx > , signed : bool ) -> Ty < ' tcx > {
38
+ use abi:: Integer :: { I8 , I16 , I32 , I64 , I128 } ;
33
39
match ( * self , signed) {
34
40
( I8 , false ) => tcx. types . u8 ,
35
41
( I16 , false ) => tcx. types . u16 ,
@@ -44,7 +50,8 @@ impl Integer {
44
50
}
45
51
}
46
52
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 } ;
48
55
match ity {
49
56
ty:: IntTy :: I8 => I8 ,
50
57
ty:: IntTy :: I16 => I16 ,
@@ -54,7 +61,8 @@ impl Integer {
54
61
ty:: IntTy :: Isize => cx. data_layout ( ) . ptr_sized_integer ( ) ,
55
62
}
56
63
}
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 } ;
58
66
match ity {
59
67
ty:: UintTy :: U8 => I8 ,
60
68
ty:: UintTy :: U16 => I16 ,
@@ -102,7 +110,7 @@ impl Integer {
102
110
tcx. data_layout ( ) . c_enum_min_size
103
111
} else {
104
112
// repr(Rust) enums try to be as small as possible
105
- I8
113
+ Integer :: I8
106
114
} ;
107
115
108
116
// If there are no negative values, we can use the unsigned fit.
@@ -115,9 +123,10 @@ impl Integer {
115
123
}
116
124
117
125
#[ extension( pub trait FloatExt ) ]
118
- impl Float {
126
+ impl abi :: Float {
119
127
#[ inline]
120
128
fn to_ty < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Ty < ' tcx > {
129
+ use abi:: Float :: * ;
121
130
match * self {
122
131
F16 => tcx. types . f16 ,
123
132
F32 => tcx. types . f32 ,
@@ -127,6 +136,7 @@ impl Float {
127
136
}
128
137
129
138
fn from_float_ty ( fty : ty:: FloatTy ) -> Self {
139
+ use abi:: Float :: * ;
130
140
match fty {
131
141
ty:: FloatTy :: F16 => F16 ,
132
142
ty:: FloatTy :: F32 => F32 ,
0 commit comments