Add a static assertion about the size of ast::Expr.

This commit is contained in:
Nicholas Nethercote 2018-11-09 10:10:46 +11:00
parent 49f482f537
commit fb3dd9f64e

View File

@ -20,6 +20,7 @@ use print::pprust;
use ptr::P;
use rustc_data_structures::indexed_vec;
use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::static_assert;
use rustc_target::spec::abi::Abi;
use source_map::{dummy_spanned, respan, Spanned};
use symbol::{keywords, Symbol};
@ -924,6 +925,10 @@ pub struct Expr {
pub attrs: ThinVec<Attribute>,
}
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_EXPR: std::mem::size_of::<Expr>() == 88);
impl Expr {
/// Whether this expression would be valid somewhere that expects a value, for example, an `if`
/// condition.