@@ -97,7 +97,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
97
97
Ok ( ( ) )
98
98
}
99
99
100
- fn misc_cast (
100
+ pub fn misc_cast (
101
101
& self ,
102
102
src : & ImmTy < ' tcx , M :: PointerTag > ,
103
103
cast_ty : Ty < ' tcx > ,
@@ -139,7 +139,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
139
139
if let Some ( discr) = src. layout . ty . discriminant_for_variant ( * self . tcx , index) {
140
140
assert ! ( src. layout. is_zst( ) ) ;
141
141
let discr_layout = self . layout_of ( discr. ty ) ?;
142
- return Ok ( self . cast_from_scalar ( discr. val , discr_layout, cast_ty) . into ( ) ) ;
142
+ return Ok ( self . cast_from_int_like ( discr. val , discr_layout, cast_ty) . into ( ) ) ;
143
143
}
144
144
}
145
145
Variants :: Multiple { .. } => { }
@@ -169,17 +169,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
169
169
}
170
170
}
171
171
172
- // # The remaining source values are scalar.
172
+ // # The remaining source values are scalar and "int-like" .
173
173
174
174
// For all remaining casts, we either
175
175
// (a) cast a raw ptr to usize, or
176
176
// (b) cast from an integer-like (including bool, char, enums).
177
177
// In both cases we want the bits.
178
178
let bits = src. to_scalar ( ) ?. to_bits ( src. layout . size ) ?;
179
- Ok ( self . cast_from_scalar ( bits, src. layout , cast_ty) . into ( ) )
179
+ Ok ( self . cast_from_int_like ( bits, src. layout , cast_ty) . into ( ) )
180
180
}
181
181
182
- pub ( super ) fn cast_from_scalar (
182
+ fn cast_from_int_like (
183
183
& self ,
184
184
v : u128 , // raw bits (there is no ScalarTy so we separate data+layout)
185
185
src_layout : TyAndLayout < ' tcx > ,
0 commit comments