@@ -310,7 +310,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
310
310
operands : & IndexSlice < FieldIdx , mir:: Operand < ' tcx > > ,
311
311
dest : & PlaceTy < ' tcx , M :: Provenance > ,
312
312
) -> InterpResult < ' tcx > {
313
- self . write_uninit ( dest) ?; // make sure all the padding ends up as uninit
314
313
let ( variant_index, variant_dest, active_field_index) = match * kind {
315
314
mir:: AggregateKind :: Adt ( _, variant_index, _, _, active_field_index) => {
316
315
let variant_dest = self . project_downcast ( dest, variant_index) ?;
@@ -346,9 +345,18 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
346
345
let field_index = active_field_index. unwrap_or ( field_index) ;
347
346
let field_dest = self . project_field ( & variant_dest, field_index) ?;
348
347
let op = self . eval_operand ( operand, Some ( field_dest. layout ) ) ?;
349
- self . copy_op ( & op, & field_dest) ?;
348
+ // We validate manually below so we don't have to do it here.
349
+ self . copy_op_no_validate ( & op, & field_dest, /*allow_transmute*/ false ) ?;
350
350
}
351
- self . write_discriminant ( variant_index, dest)
351
+ self . write_discriminant ( variant_index, dest) ?;
352
+ // Validate that the entire thing is valid, and reset padding that might be in between the
353
+ // fields.
354
+ self . validate_operand (
355
+ dest,
356
+ M :: enforce_validity_recursively ( self , dest. layout ( ) ) ,
357
+ /*reset_provenance_and_padding*/ true ,
358
+ ) ?;
359
+ interp_ok ( ( ) )
352
360
}
353
361
354
362
/// Repeats `operand` into the destination. `dest` must have array type, and that type
0 commit comments