diff options
| author | Ralf Jung <post@ralfj.de> | 2024-08-09 18:08:34 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-09 18:48:45 +0200 |
| commit | 9a233bb9dd0783b4819650ed87112dbaf944f353 (patch) | |
| tree | a77d320ad746f35a5224ae7336beb7764b0a561e /compiler/rustc_const_eval/src/interpret | |
| parent | dec5b463fbe506302d7a63fa8c52dfc22b4b110f (diff) | |
interpret: make identity upcasts a NOP again to avoid them generating a new random vtable
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/cast.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index b2f07de0ac4..f6428104e7a 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -400,6 +400,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } (ty::Dynamic(data_a, _, ty::Dyn), ty::Dynamic(data_b, _, ty::Dyn)) => { let val = self.read_immediate(src)?; + // MIR building generates odd NOP casts, prevent them from causing unexpected trouble. + // See <https://github.com/rust-lang/rust/issues/128880>. + // FIXME: ideally we wouldn't have to do this. + if data_a == data_b { + return self.write_immediate(*val, dest); + } // Take apart the old pointer, and find the dynamic type. let (old_data, old_vptr) = val.to_scalar_pair(); let old_data = old_data.to_pointer(self)?; |
