@@ -32,6 +32,8 @@ pub struct MemPlace {
32
32
pub ptr : Scalar ,
33
33
pub align : Align ,
34
34
/// Metadata for unsized places. Interpretation is up to the type.
35
+ /// Must not be present for sized types, but can be missing for unsized types
36
+ /// (e.g. `extern type`).
35
37
pub extra : Option < Scalar > ,
36
38
}
37
39
@@ -236,11 +238,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
236
238
) -> EvalResult < ' tcx , MPlaceTy < ' tcx > > {
237
239
let pointee_type = val. layout . ty . builtin_deref ( true ) . unwrap ( ) . ty ;
238
240
let layout = self . layout_of ( pointee_type) ?;
239
- let mplace = if layout. is_unsized ( ) {
240
- let ( ptr, extra) = val. to_scalar_pair ( ) ?;
241
- MemPlace { ptr, align : layout. align , extra : Some ( extra) }
242
- } else {
243
- MemPlace { ptr : val. to_scalar ( ) ?, align : layout. align , extra : None }
241
+ let align = layout. align ;
242
+ let mplace = match * val {
243
+ Value :: Scalar ( ptr) =>
244
+ MemPlace { ptr : ptr. not_undef ( ) ?, align, extra : None } ,
245
+ Value :: ScalarPair ( ptr, extra) =>
246
+ MemPlace { ptr : ptr. not_undef ( ) ?, align, extra : Some ( extra. not_undef ( ) ?) } ,
244
247
} ;
245
248
Ok ( MPlaceTy { mplace, layout } )
246
249
}
0 commit comments