Skip to content

Commit

Permalink
Add static assertions to nodes (#6228)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Aug 1, 2023
1 parent 07468f8 commit ecfdd8d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/ruff_python_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ once_cell = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true, optional = true }
smallvec = { workspace = true }
static_assertions = "1.1.0"

[dev-dependencies]
insta = { workspace = true }
Expand Down
13 changes: 13 additions & 0 deletions crates/ruff_python_ast/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3044,3 +3044,16 @@ impl Ranged for crate::nodes::ArgWithDefault {
self.range
}
}

#[cfg(target_pointer_width = "64")]
mod size_assertions {
#[allow(clippy::wildcard_imports)]
use super::*;
use static_assertions::assert_eq_size;

assert_eq_size!(Stmt, [u8; 168]);
assert_eq_size!(Expr, [u8; 80]);
assert_eq_size!(Constant, [u8; 32]);
assert_eq_size!(Pattern, [u8; 96]);
assert_eq_size!(Mod, [u8; 64]);
}

0 comments on commit ecfdd8d

Please sign in to comment.