@@ -4,7 +4,7 @@ use rustc_apfloat::ieee::{Double, Single};
4
4
use rustc_apfloat:: { Float , FloatConvert } ;
5
5
use rustc_middle:: mir:: interpret:: { InterpResult , PointerArithmetic , Scalar } ;
6
6
use rustc_middle:: mir:: CastKind ;
7
- use rustc_middle:: ty:: adjustment:: PointerCast ;
7
+ use rustc_middle:: ty:: adjustment:: PointerCoercion ;
8
8
use rustc_middle:: ty:: layout:: { IntegerExt , LayoutOf , TyAndLayout } ;
9
9
use rustc_middle:: ty:: { self , FloatTy , Ty , TypeAndMut } ;
10
10
use rustc_target:: abi:: Integer ;
@@ -24,51 +24,52 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
24
24
cast_ty : Ty < ' tcx > ,
25
25
dest : & PlaceTy < ' tcx , M :: Provenance > ,
26
26
) -> InterpResult < ' tcx > {
27
- use rustc_middle:: mir:: CastKind :: * ;
28
27
// FIXME: In which cases should we trigger UB when the source is uninit?
29
28
match cast_kind {
30
- Pointer ( PointerCast :: Unsize ) => {
29
+ CastKind :: PointerCoercion ( PointerCoercion :: Unsize ) => {
31
30
let cast_ty = self . layout_of ( cast_ty) ?;
32
31
self . unsize_into ( src, cast_ty, dest) ?;
33
32
}
34
33
35
- PointerExposeAddress => {
34
+ CastKind :: PointerExposeAddress => {
36
35
let src = self . read_immediate ( src) ?;
37
36
let res = self . pointer_expose_address_cast ( & src, cast_ty) ?;
38
37
self . write_immediate ( res, dest) ?;
39
38
}
40
39
41
- PointerFromExposedAddress => {
40
+ CastKind :: PointerFromExposedAddress => {
42
41
let src = self . read_immediate ( src) ?;
43
42
let res = self . pointer_from_exposed_address_cast ( & src, cast_ty) ?;
44
43
self . write_immediate ( res, dest) ?;
45
44
}
46
45
47
- IntToInt | IntToFloat => {
46
+ CastKind :: IntToInt | CastKind :: IntToFloat => {
48
47
let src = self . read_immediate ( src) ?;
49
48
let res = self . int_to_int_or_float ( & src, cast_ty) ?;
50
49
self . write_immediate ( res, dest) ?;
51
50
}
52
51
53
- FloatToFloat | FloatToInt => {
52
+ CastKind :: FloatToFloat | CastKind :: FloatToInt => {
54
53
let src = self . read_immediate ( src) ?;
55
54
let res = self . float_to_float_or_int ( & src, cast_ty) ?;
56
55
self . write_immediate ( res, dest) ?;
57
56
}
58
57
59
- FnPtrToPtr | PtrToPtr => {
58
+ CastKind :: FnPtrToPtr | CastKind :: PtrToPtr => {
60
59
let src = self . read_immediate ( & src) ?;
61
60
let res = self . ptr_to_ptr ( & src, cast_ty) ?;
62
61
self . write_immediate ( res, dest) ?;
63
62
}
64
63
65
- Pointer ( PointerCast :: MutToConstPointer | PointerCast :: ArrayToPointer ) => {
64
+ CastKind :: PointerCoercion (
65
+ PointerCoercion :: MutToConstPointer | PointerCoercion :: ArrayToPointer ,
66
+ ) => {
66
67
// These are NOPs, but can be wide pointers.
67
68
let v = self . read_immediate ( src) ?;
68
69
self . write_immediate ( * v, dest) ?;
69
70
}
70
71
71
- Pointer ( PointerCast :: ReifyFnPointer ) => {
72
+ CastKind :: PointerCoercion ( PointerCoercion :: ReifyFnPointer ) => {
72
73
// All reifications must be monomorphic, bail out otherwise.
73
74
ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
74
75
@@ -90,7 +91,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
90
91
}
91
92
}
92
93
93
- Pointer ( PointerCast :: UnsafeFnPointer ) => {
94
+ CastKind :: PointerCoercion ( PointerCoercion :: UnsafeFnPointer ) => {
94
95
let src = self . read_immediate ( src) ?;
95
96
match cast_ty. kind ( ) {
96
97
ty:: FnPtr ( _) => {
@@ -101,7 +102,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
101
102
}
102
103
}
103
104
104
- Pointer ( PointerCast :: ClosureFnPointer ( _) ) => {
105
+ CastKind :: PointerCoercion ( PointerCoercion :: ClosureFnPointer ( _) ) => {
105
106
// All reifications must be monomorphic, bail out otherwise.
106
107
ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
107
108
@@ -122,7 +123,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
122
123
}
123
124
}
124
125
125
- DynStar => {
126
+ CastKind :: DynStar => {
126
127
if let ty:: Dynamic ( data, _, ty:: DynStar ) = cast_ty. kind ( ) {
127
128
// Initial cast from sized to dyn trait
128
129
let vtable = self . get_vtable_ptr ( src. layout . ty , data. principal ( ) ) ?;
@@ -136,7 +137,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
136
137
}
137
138
}
138
139
139
- Transmute => {
140
+ CastKind :: Transmute => {
140
141
assert ! ( src. layout. is_sized( ) ) ;
141
142
assert ! ( dest. layout. is_sized( ) ) ;
142
143
if src. layout . size != dest. layout . size {
0 commit comments