diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-06-12 15:44:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 15:44:59 +0200 |
| commit | 51a58c59f3ff8ec39da77c1c3d0b780568b9c202 (patch) | |
| tree | cda215bf270a33269c8010ce2a735b1b818d9294 /compiler/rustc_const_eval/src/interpret/cast.rs | |
| parent | c21de3c91eeb9fbb70ef616bf30ed31962c11e90 (diff) | |
| parent | 3757136d8e0d8ddca294453e5a5ce70cfa3417e9 (diff) | |
| download | rust-51a58c59f3ff8ec39da77c1c3d0b780568b9c202.tar.gz rust-51a58c59f3ff8ec39da77c1c3d0b780568b9c202.zip | |
Rollup merge of #126232 - RalfJung:dyn-trait-equality, r=oli-obk
interpret: dyn trait metadata check: equate traits in a proper way Hopefully fixes https://github.com/rust-lang/miri/issues/3541... unfortunately we don't have a testcase. The first commit is just a refactor without functional change. r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/cast.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/cast.rs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index 0a45bbb3edb..6961e13c239 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -387,7 +387,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { match (&src_pointee_ty.kind(), &dest_pointee_ty.kind()) { (&ty::Array(_, length), &ty::Slice(_)) => { let ptr = self.read_pointer(src)?; - // u64 cast is from usize to u64, which is always good let val = Immediate::new_slice( ptr, length.eval_target_usize(*self.tcx, self.param_env), @@ -405,13 +404,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let (old_data, old_vptr) = val.to_scalar_pair(); let old_data = old_data.to_pointer(self)?; let old_vptr = old_vptr.to_pointer(self)?; - let (ty, old_trait) = self.get_ptr_vtable(old_vptr)?; - if old_trait != data_a.principal() { - throw_ub!(InvalidVTableTrait { - expected_trait: data_a, - vtable_trait: old_trait, - }); - } + let ty = self.get_ptr_vtable_ty(old_vptr, Some(data_a))?; let new_vptr = self.get_vtable_ptr(ty, data_b.principal())?; self.write_immediate(Immediate::new_dyn_trait(old_data, new_vptr, self), dest) } |
