Skip to content

Commit 8eea2f4

Browse files
committed
interpret: make identity upcasts a NOP again to avoid them generating a new random vtable
1 parent dec5b46 commit 8eea2f4

File tree

1 file changed

+6
-0
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+6
-0
lines changed

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
400400
}
401401
(ty::Dynamic(data_a, _, ty::Dyn), ty::Dynamic(data_b, _, ty::Dyn)) => {
402402
let val = self.read_immediate(src)?;
403+
// MIR building generates odd NOP casts, prevent them from causing unexpected trouble.
404+
// See <https://github.com/rust-lang/rust/issues/128880>.
405+
// FIXME: ideally we wouldn't have to do this.
406+
if data_a == data_b {
407+
return self.write_immediate(*val, dest);
408+
}
403409
// Take apart the old pointer, and find the dynamic type.
404410
let (old_data, old_vptr) = val.to_scalar_pair();
405411
let old_data = old_data.to_pointer(self)?;

0 commit comments

Comments
 (0)