1
1
use libffi:: { high:: call as ffi, low:: CodePtr } ;
2
2
use std:: ops:: Deref ;
3
3
4
- use rustc_middle:: ty:: { IntTy , Ty , TyKind , UintTy } ;
4
+ use rustc_middle:: ty:: { self as ty , IntTy , Ty , UintTy } ;
5
5
use rustc_span:: Symbol ;
6
6
use rustc_target:: abi:: HasDataLayout ;
7
7
@@ -14,44 +14,44 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
14
14
/// and convert it to a `CArg`.
15
15
fn scalar_to_carg (
16
16
k : ScalarMaybeUninit < Provenance > ,
17
- arg_type : & Ty < ' tcx > ,
17
+ arg_type : Ty < ' tcx > ,
18
18
cx : & impl HasDataLayout ,
19
19
) -> InterpResult < ' tcx , CArg > {
20
20
match arg_type. kind ( ) {
21
21
// If the primitive provided can be converted to a type matching the type pattern
22
22
// then create a `CArg` of this primitive value with the corresponding `CArg` constructor.
23
23
// the ints
24
- TyKind :: Int ( IntTy :: I8 ) => {
24
+ ty :: Int ( IntTy :: I8 ) => {
25
25
return Ok ( CArg :: Int8 ( k. to_i8 ( ) ?) ) ;
26
26
}
27
- TyKind :: Int ( IntTy :: I16 ) => {
27
+ ty :: Int ( IntTy :: I16 ) => {
28
28
return Ok ( CArg :: Int16 ( k. to_i16 ( ) ?) ) ;
29
29
}
30
- TyKind :: Int ( IntTy :: I32 ) => {
30
+ ty :: Int ( IntTy :: I32 ) => {
31
31
return Ok ( CArg :: Int32 ( k. to_i32 ( ) ?) ) ;
32
32
}
33
- TyKind :: Int ( IntTy :: I64 ) => {
33
+ ty :: Int ( IntTy :: I64 ) => {
34
34
return Ok ( CArg :: Int64 ( k. to_i64 ( ) ?) ) ;
35
35
}
36
- TyKind :: Int ( IntTy :: Isize ) => {
36
+ ty :: Int ( IntTy :: Isize ) => {
37
37
// This will fail if host != target, but then the entire FFI thing probably won't work well
38
38
// in that situation.
39
39
return Ok ( CArg :: ISize ( k. to_machine_isize ( cx) ?. try_into ( ) . unwrap ( ) ) ) ;
40
40
}
41
41
// the uints
42
- TyKind :: Uint ( UintTy :: U8 ) => {
42
+ ty :: Uint ( UintTy :: U8 ) => {
43
43
return Ok ( CArg :: UInt8 ( k. to_u8 ( ) ?) ) ;
44
44
}
45
- TyKind :: Uint ( UintTy :: U16 ) => {
45
+ ty :: Uint ( UintTy :: U16 ) => {
46
46
return Ok ( CArg :: UInt16 ( k. to_u16 ( ) ?) ) ;
47
47
}
48
- TyKind :: Uint ( UintTy :: U32 ) => {
48
+ ty :: Uint ( UintTy :: U32 ) => {
49
49
return Ok ( CArg :: UInt32 ( k. to_u32 ( ) ?) ) ;
50
50
}
51
- TyKind :: Uint ( UintTy :: U64 ) => {
51
+ ty :: Uint ( UintTy :: U64 ) => {
52
52
return Ok ( CArg :: UInt64 ( k. to_u64 ( ) ?) ) ;
53
53
}
54
- TyKind :: Uint ( UintTy :: Usize ) => {
54
+ ty :: Uint ( UintTy :: Usize ) => {
55
55
// This will fail if host != target, but then the entire FFI thing probably won't work well
56
56
// in that situation.
57
57
return Ok ( CArg :: USize ( k. to_machine_usize ( cx) ?. try_into ( ) . unwrap ( ) ) ) ;
@@ -85,55 +85,55 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
85
85
// primitive integer type, and then write this value out to the miri memory as an integer.
86
86
match dest. layout . ty . kind ( ) {
87
87
// ints
88
- TyKind :: Int ( IntTy :: I8 ) => {
88
+ ty :: Int ( IntTy :: I8 ) => {
89
89
let x = ffi:: call :: < i8 > ( ptr, libffi_args. as_slice ( ) ) ;
90
90
this. write_int ( x, dest) ?;
91
91
return Ok ( ( ) ) ;
92
92
}
93
- TyKind :: Int ( IntTy :: I16 ) => {
93
+ ty :: Int ( IntTy :: I16 ) => {
94
94
let x = ffi:: call :: < i16 > ( ptr, libffi_args. as_slice ( ) ) ;
95
95
this. write_int ( x, dest) ?;
96
96
return Ok ( ( ) ) ;
97
97
}
98
- TyKind :: Int ( IntTy :: I32 ) => {
98
+ ty :: Int ( IntTy :: I32 ) => {
99
99
let x = ffi:: call :: < i32 > ( ptr, libffi_args. as_slice ( ) ) ;
100
100
this. write_int ( x, dest) ?;
101
101
return Ok ( ( ) ) ;
102
102
}
103
- TyKind :: Int ( IntTy :: I64 ) => {
103
+ ty :: Int ( IntTy :: I64 ) => {
104
104
let x = ffi:: call :: < i64 > ( ptr, libffi_args. as_slice ( ) ) ;
105
105
this. write_int ( x, dest) ?;
106
106
return Ok ( ( ) ) ;
107
107
}
108
- TyKind :: Int ( IntTy :: Isize ) => {
108
+ ty :: Int ( IntTy :: Isize ) => {
109
109
let x = ffi:: call :: < isize > ( ptr, libffi_args. as_slice ( ) ) ;
110
110
// `isize` doesn't `impl Into<i128>`, so convert manually.
111
111
// Convert to `i64` since this covers both 32- and 64-bit machines.
112
112
this. write_int ( i64:: try_from ( x) . unwrap ( ) , dest) ?;
113
113
return Ok ( ( ) ) ;
114
114
}
115
115
// uints
116
- TyKind :: Uint ( UintTy :: U8 ) => {
116
+ ty :: Uint ( UintTy :: U8 ) => {
117
117
let x = ffi:: call :: < u8 > ( ptr, libffi_args. as_slice ( ) ) ;
118
118
this. write_int ( x, dest) ?;
119
119
return Ok ( ( ) ) ;
120
120
}
121
- TyKind :: Uint ( UintTy :: U16 ) => {
121
+ ty :: Uint ( UintTy :: U16 ) => {
122
122
let x = ffi:: call :: < u16 > ( ptr, libffi_args. as_slice ( ) ) ;
123
123
this. write_int ( x, dest) ?;
124
124
return Ok ( ( ) ) ;
125
125
}
126
- TyKind :: Uint ( UintTy :: U32 ) => {
126
+ ty :: Uint ( UintTy :: U32 ) => {
127
127
let x = ffi:: call :: < u32 > ( ptr, libffi_args. as_slice ( ) ) ;
128
128
this. write_int ( x, dest) ?;
129
129
return Ok ( ( ) ) ;
130
130
}
131
- TyKind :: Uint ( UintTy :: U64 ) => {
131
+ ty :: Uint ( UintTy :: U64 ) => {
132
132
let x = ffi:: call :: < u64 > ( ptr, libffi_args. as_slice ( ) ) ;
133
133
this. write_int ( x, dest) ?;
134
134
return Ok ( ( ) ) ;
135
135
}
136
- TyKind :: Uint ( UintTy :: Usize ) => {
136
+ ty :: Uint ( UintTy :: Usize ) => {
137
137
let x = ffi:: call :: < usize > ( ptr, libffi_args. as_slice ( ) ) ;
138
138
// `usize` doesn't `impl Into<i128>`, so convert manually.
139
139
// Convert to `u64` since this covers both 32- and 64-bit machines.
@@ -142,7 +142,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
142
142
}
143
143
// Functions with no declared return type (i.e., the default return)
144
144
// have the output_type `Tuple([])`.
145
- TyKind :: Tuple ( t_list) =>
145
+ ty :: Tuple ( t_list) =>
146
146
if t_list. len ( ) == 0 {
147
147
ffi:: call :: < ( ) > ( ptr, libffi_args. as_slice ( ) ) ;
148
148
return Ok ( ( ) ) ;
@@ -226,7 +226,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
226
226
for cur_arg in args. iter ( ) {
227
227
libffi_args. push ( Self :: scalar_to_carg (
228
228
this. read_scalar ( cur_arg) ?,
229
- & cur_arg. layout . ty ,
229
+ cur_arg. layout . ty ,
230
230
this,
231
231
) ?) ;
232
232
}
0 commit comments