Skip to content

Commit

Permalink
check 'size multiple of align' for all layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 31, 2022
1 parent a231865 commit 98e52c2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 98e52c2

Please sign in to comment.