Skip to content

Commit

Permalink
finally enable Scalar layout sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 6, 2022
1 parent f342bea commit 8f867c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
s.is_ptr() || (number_may_have_provenance && size == self.pointer_size())
};
if let Some(s) = scalar_layout {
//FIXME(#96185): let size = s.size(self);
//FIXME(#96185): assert_eq!(size, mplace.layout.size, "abi::Scalar size does not match layout size");
let size = mplace.layout.size; //FIXME(#96185): remove this line
let size = s.size(self);
assert_eq!(size, mplace.layout.size, "abi::Scalar size does not match layout size");
let scalar =
alloc.read_scalar(alloc_range(Size::ZERO, size), read_provenance(s, size))?;
return Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout }));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ where
)
};
let size = s.size(&tcx);
//FIXME(#96185): assert_eq!(dest.layout.size, size, "abi::Scalar size does not match layout size");
assert_eq!(size, dest.layout.size, "abi::Scalar size does not match layout size");
alloc.write_scalar(alloc_range(Size::ZERO, size), scalar)
}
Immediate::ScalarPair(a_val, b_val) => {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ fn sanity_check_layout<'tcx>(
if cfg!(debug_assertions) {
fn check_layout_abi<'tcx>(tcx: TyCtxt<'tcx>, layout: Layout<'tcx>) {
match layout.abi() {
Abi::Scalar(_scalar) => {
Abi::Scalar(scalar) => {
// No padding in scalars.
/* FIXME(#96185):
assert_eq!(
layout.align().abi,
scalar.align(&tcx).abi,
Expand All @@ -247,7 +246,7 @@ fn sanity_check_layout<'tcx>(
layout.size(),
scalar.size(&tcx),
"size mismatch between ABI and layout in {layout:#?}"
);*/
);
}
Abi::Vector { count, element } => {
// No padding in vectors. Alignment can be strengthened, though.
Expand Down

0 comments on commit 8f867c5

Please sign in to comment.