]> git.lizzy.rs Git - rust.git/commitdiff
Add a static assertion about the size of `ast::Expr`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 8 Nov 2018 23:10:46 +0000 (10:10 +1100)
committerNicholas Nethercote <nnethercote@mozilla.com>
Mon, 12 Nov 2018 19:37:16 +0000 (06:37 +1100)
src/libsyntax/ast.rs

index 2f17bc0548cad75c77fa58445fff0e92e99ffea5..fa6fe3478338956b19c2ed8d42937a8fe7d73602 100644 (file)
@@ -20,6 +20,7 @@
 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.