Skip to content

Commit ac8961f

Browse files
committed
Add assertions on HIR enum sizes.
1 parent 21b0cdc commit ac8961f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,10 +1413,6 @@ pub struct Expr<'hir> {
14131413
pub span: Span,
14141414
}
14151415

1416-
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
1417-
#[cfg(target_arch = "x86_64")]
1418-
rustc_data_structures::static_assert_size!(Expr<'static>, 72);
1419-
14201416
impl Expr<'_> {
14211417
pub fn precedence(&self) -> ExprPrecedence {
14221418
match self.kind {
@@ -2897,3 +2893,18 @@ impl<'hir> Node<'hir> {
28972893
}
28982894
}
28992895
}
2896+
2897+
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
2898+
#[cfg(target_arch = "x86_64")]
2899+
mod size_asserts {
2900+
rustc_data_structures::static_assert_size!(super::Block<'static>, 48);
2901+
rustc_data_structures::static_assert_size!(super::Expr<'static>, 72);
2902+
rustc_data_structures::static_assert_size!(super::Pat<'static>, 88);
2903+
rustc_data_structures::static_assert_size!(super::QPath<'static>, 24);
2904+
rustc_data_structures::static_assert_size!(super::Ty<'static>, 72);
2905+
2906+
rustc_data_structures::static_assert_size!(super::Item<'static>, 208);
2907+
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 152);
2908+
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168);
2909+
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 160);
2910+
}

0 commit comments

Comments
 (0)