Skip to content

Commit fb3dd9f

Browse files
committed
Add a static assertion about the size of ast::Expr.
1 parent 49f482f commit fb3dd9f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libsyntax/ast.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use print::pprust;
2020
use ptr::P;
2121
use rustc_data_structures::indexed_vec;
2222
use rustc_data_structures::indexed_vec::Idx;
23+
use rustc_data_structures::static_assert;
2324
use rustc_target::spec::abi::Abi;
2425
use source_map::{dummy_spanned, respan, Spanned};
2526
use symbol::{keywords, Symbol};
@@ -924,6 +925,10 @@ pub struct Expr {
924925
pub attrs: ThinVec<Attribute>,
925926
}
926927

928+
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
929+
#[cfg(target_arch = "x86_64")]
930+
static_assert!(MEM_SIZE_OF_EXPR: std::mem::size_of::<Expr>() == 88);
931+
927932
impl Expr {
928933
/// Whether this expression would be valid somewhere that expects a value, for example, an `if`
929934
/// condition.

0 commit comments

Comments
 (0)