Skip to content

Commit 8f867c5

Browse files
committed
finally enable Scalar layout sanity checks
1 parent f342bea commit 8f867c5

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/operand.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
306306
s.is_ptr() || (number_may_have_provenance && size == self.pointer_size())
307307
};
308308
if let Some(s) = scalar_layout {
309-
//FIXME(#96185): let size = s.size(self);
310-
//FIXME(#96185): assert_eq!(size, mplace.layout.size, "abi::Scalar size does not match layout size");
311-
let size = mplace.layout.size; //FIXME(#96185): remove this line
309+
let size = s.size(self);
310+
assert_eq!(size, mplace.layout.size, "abi::Scalar size does not match layout size");
312311
let scalar =
313312
alloc.read_scalar(alloc_range(Size::ZERO, size), read_provenance(s, size))?;
314313
return Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout }));

Diff for: compiler/rustc_const_eval/src/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ where
793793
)
794794
};
795795
let size = s.size(&tcx);
796-
//FIXME(#96185): assert_eq!(dest.layout.size, size, "abi::Scalar size does not match layout size");
796+
assert_eq!(size, dest.layout.size, "abi::Scalar size does not match layout size");
797797
alloc.write_scalar(alloc_range(Size::ZERO, size), scalar)
798798
}
799799
Immediate::ScalarPair(a_val, b_val) => {

Diff for: compiler/rustc_middle/src/ty/layout.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,8 @@ fn sanity_check_layout<'tcx>(
235235
if cfg!(debug_assertions) {
236236
fn check_layout_abi<'tcx>(tcx: TyCtxt<'tcx>, layout: Layout<'tcx>) {
237237
match layout.abi() {
238-
Abi::Scalar(_scalar) => {
238+
Abi::Scalar(scalar) => {
239239
// No padding in scalars.
240-
/* FIXME(#96185):
241240
assert_eq!(
242241
layout.align().abi,
243242
scalar.align(&tcx).abi,
@@ -247,7 +246,7 @@ fn sanity_check_layout<'tcx>(
247246
layout.size(),
248247
scalar.size(&tcx),
249248
"size mismatch between ABI and layout in {layout:#?}"
250-
);*/
249+
);
251250
}
252251
Abi::Vector { count, element } => {
253252
// No padding in vectors. Alignment can be strengthened, though.

0 commit comments

Comments
 (0)