fix: ensure expr and type enum are not too big (#811)

This commit is contained in:
Myriad-Dreamin 2024-11-14 11:47:34 +08:00 committed by GitHub
parent 3469e215eb
commit 7ab125bbc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -1180,3 +1180,12 @@ fn extract_ref(step: Option<Expr>) -> (Option<Expr>, Option<Expr>) {
fn none_expr() -> Expr {
Expr::Type(Ty::Builtin(BuiltinTy::None))
}
#[cfg(test)]
mod tests {
#[test]
fn test_expr_size() {
use super::*;
assert!(size_of::<Expr>() <= size_of::<usize>() * 2);
}
}

View file

@ -1198,7 +1198,7 @@ mod tests {
#[test]
fn test_ty_size() {
use super::*;
assert!(size_of::<Ty>() == 16);
assert!(size_of::<Ty>() <= size_of::<usize>() * 2);
}
#[test]