Skip to content

Commit 3220c0c

Browse files
committed
Explain why vtable generation needs no alignment checks
1 parent 2287219 commit 3220c0c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustc_mir/interpret/traits.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
5959

6060
let drop = ::monomorphize::resolve_drop_in_place(*tcx, ty);
6161
let drop = self.memory.create_fn_alloc(drop).with_default_tag();
62+
// no need to do any alignment checks on the memory accesses below, because we know the
63+
// allocation is correctly aligned as we created it above. Also we're only offsetting by
64+
// multiples of `ptr_align`, which means that it will stay aligned to `ptr_align`.
6265
self.memory
6366
.get_mut(vtable.alloc_id)?
6467
.write_ptr_sized(tcx, vtable, Scalar::Ptr(drop).into())?;

0 commit comments

Comments
 (0)