@@ -283,31 +283,32 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
283
283
} ;
284
284
// the only way conversion can fail if is this is an array (otherwise we already panicked
285
285
// above). In that case, all fields are equal.
286
- let field = base. layout . field ( self , usize:: try_from ( field) . unwrap_or ( 0 ) ) ?;
286
+ let field_layout = base. layout . field ( self , usize:: try_from ( field) . unwrap_or ( 0 ) ) ?;
287
287
288
288
// Adjust offset
289
- let offset = if field. is_unsized ( ) {
290
- let vtable = match base. extra {
291
- PlaceExtra :: Vtable ( tab) => tab,
292
- _ => bug ! ( "Unsized place with unsized field must come with vtable" ) ,
293
- } ;
294
- let ( _, align) = self . read_size_and_align_from_vtable ( vtable) ?;
295
- offset. abi_align ( align)
296
- } else {
297
- // No adjustment needed
298
- offset
289
+ let offset = match base. extra {
290
+ PlaceExtra :: Vtable ( vtable) => {
291
+ let ( _, align) = self . read_size_and_align_from_vtable ( vtable) ?;
292
+ // FIXME: Is this right? Should we always do this, or only when actually
293
+ // accessing the field to which the vtable applies?
294
+ offset. abi_align ( align)
295
+ }
296
+ _ => {
297
+ // No adjustment needed
298
+ offset
299
+ }
299
300
} ;
300
301
301
302
let ptr = base. ptr . ptr_offset ( offset, self ) ?;
302
- let align = base. align . min ( field . align ) ;
303
- let extra = if !field . is_unsized ( ) {
303
+ let align = base. align . min ( field_layout . align ) ;
304
+ let extra = if !field_layout . is_unsized ( ) {
304
305
PlaceExtra :: None
305
306
} else {
306
307
assert ! ( base. extra != PlaceExtra :: None , "Expected fat ptr" ) ;
307
308
base. extra
308
309
} ;
309
310
310
- Ok ( MPlaceTy { mplace : MemPlace { ptr, align, extra } , layout : field } )
311
+ Ok ( MPlaceTy { mplace : MemPlace { ptr, align, extra } , layout : field_layout } )
311
312
}
312
313
313
314
pub fn mplace_subslice (
0 commit comments