Rollup merge of #58615 - RalfJung:ref-to-place-alignment, r=oli-obk
miri: explain why we use static alignment in ref-to-place conversion @eddyb @oli-obk do you think this makes sense? Or should we use the run-time alignment (`align_of_val`)? I am a bit worried about custom DSTs, but that affects way more areas of Miri so I'd ignore them for now. r? @oli-obk
This commit is contained in:
commit
9695b80647
1 changed files with 8 additions and 2 deletions
|
@ -326,6 +326,10 @@ where
|
|||
|
||||
let mplace = MemPlace {
|
||||
ptr: val.to_scalar_ptr()?,
|
||||
// We could use the run-time alignment here. For now, we do not, because
|
||||
// the point of tracking the alignment here is to make sure that the *static*
|
||||
// alignment information emitted with the loads is correct. The run-time
|
||||
// alignment can only be more restrictive.
|
||||
align: layout.align.abi,
|
||||
meta: val.to_meta()?,
|
||||
};
|
||||
|
@ -385,9 +389,11 @@ where
|
|||
// above). In that case, all fields are equal.
|
||||
let field_layout = base.layout.field(self, usize::try_from(field).unwrap_or(0))?;
|
||||
|
||||
// Offset may need adjustment for unsized fields
|
||||
// Offset may need adjustment for unsized fields.
|
||||
let (meta, offset) = if field_layout.is_unsized() {
|
||||
// re-use parent metadata to determine dynamic field layout
|
||||
// Re-use parent metadata to determine dynamic field layout.
|
||||
// With custom DSTS, this *will* execute user-defined code, but the same
|
||||
// happens at run-time so that's okay.
|
||||
let align = match self.size_and_align_of(base.meta, field_layout)? {
|
||||
Some((_, align)) => align,
|
||||
None if offset == Size::ZERO =>
|
||||
|
|
Loading…
Reference in a new issue