From 98e52c2a273c923a4e43eeee6a0c3d1a6d91dbce Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 28 Jul 2022 16:59:55 -0400 Subject: [PATCH] check 'size multiple of align' for all layouts --- compiler/rustc_middle/src/ty/layout.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 833edd22805..ad78d24e954 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -232,6 +232,10 @@ fn sanity_check_layout<'tcx>( assert!(layout.abi.is_uninhabited()); } + if layout.size.bytes() % layout.align.abi.bytes() != 0 { + bug!("size is not a multiple of align, in the following layout:\n{layout:#?}"); + } + if cfg!(debug_assertions) { fn check_layout_abi<'tcx>(tcx: TyCtxt<'tcx>, layout: Layout<'tcx>) { match layout.abi() {