Skip to content

Commit 033dc29

Browse files
authored
Rollup merge of #143046 - RalfJung:zst-unsafe-cell, r=lcnr,oli-obk
const validation: properly ignore zero-sized UnsafeCell Fixes rust-lang/rust#142948 r? `@oli-obk`
2 parents 1535e1d + 6448e83 commit 033dc29

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
814814
info: RetagInfo, // diagnostics info about this retag
815815
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
816816
let this = self.eval_context_mut();
817-
let size = this.size_and_align_of_mplace(place)?.map(|(size, _)| size);
817+
let size = this.size_and_align_of_val(place)?.map(|(size, _)| size);
818818
// FIXME: If we cannot determine the size (because the unsized tail is an `extern type`),
819819
// bail out -- we cannot reasonably figure out which memory range to reborrow.
820820
// See https://github.com/rust-lang/unsafe-code-guidelines/issues/276.

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
469469
// - if the pointer is not reborrowed (raw pointer) then we override the size
470470
// to do a zero-length reborrow.
471471
let reborrow_size = this
472-
.size_and_align_of_mplace(place)?
472+
.size_and_align_of_val(place)?
473473
.map(|(size, _)| size)
474474
.unwrap_or(place.layout.size);
475475
trace!("Creating new permission: {:?} with size {:?}", new_perm, reborrow_size);

src/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
489489
trace!("visit_frozen(place={:?}, size={:?})", *place, size);
490490
debug_assert_eq!(
491491
size,
492-
this.size_and_align_of_mplace(place)?
492+
this.size_and_align_of_val(place)?
493493
.map(|(size, _)| size)
494494
.unwrap_or_else(|| place.layout.size)
495495
);
@@ -530,7 +530,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
530530
trace!("unsafe_cell_action on {:?}", place.ptr());
531531
// We need a size to go on.
532532
let unsafe_cell_size = this
533-
.size_and_align_of_mplace(place)?
533+
.size_and_align_of_val(place)?
534534
.map(|(size, _)| size)
535535
// for extern types, just cover what we can
536536
.unwrap_or_else(|| place.layout.size);

0 commit comments

Comments
 (0)