Skip to content

Commit 246d126

Browse files
committed
Add more size assertions for MIR types.
And move them into a module, as has been done previously for AST, HIR, etc.
1 parent b44197a commit 246d126

File tree

1 file changed

+14
-8
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+14
-8
lines changed

compiler/rustc_middle/src/mir/mod.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -839,10 +839,6 @@ pub struct LocalDecl<'tcx> {
839839
pub source_info: SourceInfo,
840840
}
841841

842-
// `LocalDecl` is used a lot. Make sure it doesn't unintentionally get bigger.
843-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
844-
static_assert_size!(LocalDecl<'_>, 56);
845-
846842
/// Extra information about a some locals that's used for diagnostics and for
847843
/// classifying variables into local variables, statics, etc, which is needed e.g.
848844
/// for unsafety checking.
@@ -1317,10 +1313,6 @@ pub struct Statement<'tcx> {
13171313
pub kind: StatementKind<'tcx>,
13181314
}
13191315

1320-
// `Statement` is used a lot. Make sure it doesn't unintentionally get bigger.
1321-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
1322-
static_assert_size!(Statement<'_>, 32);
1323-
13241316
impl Statement<'_> {
13251317
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
13261318
/// invalidating statement indices in `Location`s.
@@ -2900,3 +2892,17 @@ impl Location {
29002892
}
29012893
}
29022894
}
2895+
2896+
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
2897+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
2898+
mod size_asserts {
2899+
use super::*;
2900+
use rustc_data_structures::static_assert_size;
2901+
// These are in alphabetical order, which is easy to maintain.
2902+
static_assert_size!(BasicBlockData<'_>, 144);
2903+
static_assert_size!(LocalDecl<'_>, 56);
2904+
static_assert_size!(Statement<'_>, 32);
2905+
static_assert_size!(StatementKind<'_>, 16);
2906+
static_assert_size!(Terminator<'_>, 112);
2907+
static_assert_size!(TerminatorKind<'_>, 96);
2908+
}

0 commit comments

Comments
 (0)