@@ -32,6 +32,8 @@ pub struct MemPlace {
3232 pub ptr : Scalar ,
3333 pub align : Align ,
3434 /// 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`).
3537 pub extra : Option < Scalar > ,
3638}
3739
@@ -236,11 +238,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
236238 ) -> EvalResult < ' tcx , MPlaceTy < ' tcx > > {
237239 let pointee_type = val. layout . ty . builtin_deref ( true ) . unwrap ( ) . ty ;
238240 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 ( ) ?) } ,
244247 } ;
245248 Ok ( MPlaceTy { mplace, layout } )
246249 }
0 commit comments