diff --git a/Cargo.lock b/Cargo.lock index c3767cca9..593cbad02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1102,6 +1102,7 @@ name = "oxc_index" version = "0.0.0" dependencies = [ "index_vec", + "static_assertions", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d218b5e88..f2b4e1257 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,45 +36,46 @@ oxc_semantic2 = { version = "0.0.0", path = "crates/oxc_semantic2" } oxc_tasks_common = { path = "tasks/common" } -bitflags = { version = "2.2.1" } -bumpalo = { version = "3.12.2" } -clap = { version = "4.2.7", default-features = false, features = ["std"] } -compact_str = { version = "0.7.0" } -convert_case = { version = "0.6.0" } -criterion = { version = "0.4.0", default-features = false } -flate2 = { version = "1.0.26" } -glob = { version = "0.3.1" } -ignore = { version = "0.4.20" } -indextree = { version = "4.6.0" } -itertools = { version = "0.10.5" } -jemallocator = { version = "0.5.0" } -lazy_static = { version = "1.4.0" } -miette = { version = "5.8.0" } -mimalloc = { version = "0.1.37" } -num-bigint = { version = "0.4.3" } -num-traits = { version = "0.2.15" } -num_cpus = { version = "1.15.0" } -once_cell = { version = "1.17.1" } -phf = { version = "0.11" } -pico-args = { version = "0.5.0" } -proc-macro2 = { version = "1.0.56" } -project-root = { version = "0.2.2" } -quote = { version = "1.0.27" } -rayon = { version = "1.7.0" } -regex = { version = "1.8.1" } -rustc-hash = { version = "1.1.0", default-features = false, features = ["std"] } -ryu-js = { version = "0.2.2" } -serde = { version = "1.0.163" } -serde_json = { version = "1.0.96" } -syn = { version = "1.0.109" } -thiserror = { version = "1.0.40" } -tokio = { version = "1" } -unicode-id-start = { version = "1.1.0" } -ureq = { version = "2.6.2", default-features = false } -url = { version = "2.3.1" } -walkdir = { version = "2.3.3" } -indexmap = { version = "1.0.3" } -index_vec = { version = "0.1.3" } +bitflags = { version = "2.2.1" } +bumpalo = { version = "3.12.2" } +clap = { version = "4.2.7", default-features = false, features = ["std"] } +compact_str = { version = "0.7.0" } +convert_case = { version = "0.6.0" } +criterion = { version = "0.4.0", default-features = false } +flate2 = { version = "1.0.26" } +glob = { version = "0.3.1" } +ignore = { version = "0.4.20" } +indextree = { version = "4.6.0" } +itertools = { version = "0.10.5" } +jemallocator = { version = "0.5.0" } +lazy_static = { version = "1.4.0" } +miette = { version = "5.8.0" } +mimalloc = { version = "0.1.37" } +num-bigint = { version = "0.4.3" } +num-traits = { version = "0.2.15" } +num_cpus = { version = "1.15.0" } +once_cell = { version = "1.17.1" } +phf = { version = "0.11" } +pico-args = { version = "0.5.0" } +proc-macro2 = { version = "1.0.56" } +project-root = { version = "0.2.2" } +quote = { version = "1.0.27" } +rayon = { version = "1.7.0" } +regex = { version = "1.8.1" } +rustc-hash = { version = "1.1.0", default-features = false, features = ["std"] } +ryu-js = { version = "0.2.2" } +serde = { version = "1.0.163" } +serde_json = { version = "1.0.96" } +syn = { version = "1.0.109" } +thiserror = { version = "1.0.40" } +tokio = { version = "1" } +unicode-id-start = { version = "1.1.0" } +ureq = { version = "2.6.2", default-features = false } +url = { version = "2.3.1" } +walkdir = { version = "2.3.3" } +indexmap = { version = "1.0.3" } +index_vec = { version = "0.1.3" } +static_assertions = { version = "1.1.0" } [workspace.metadata.workspaces] allow_branch = "main" diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index b4af187bb..ae62dff46 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -19,9 +19,9 @@ oxc_span = { workspace = true } oxc_syntax = { workspace = true } oxc_index = { workspace = true } -bitflags = { workspace = true } -rustc-hash = { workspace = true } -num-bigint = { workspace = true } +bitflags = { workspace = true } +rustc-hash = { workspace = true } +num-bigint = { workspace = true } serde = { workspace = true, features = ["derive"], optional = true } serde_json = { workspace = true, optional = true } diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 4c782b63d..6b035d54b 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -52,21 +52,18 @@ pub use crate::{ // Read `https://nnethercote.github.io/perf-book/type-sizes.html` for more details. #[cfg(target_pointer_width = "64")] mod size_asserts { - use oxc_index::static_assert_size; + use oxc_index::assert_eq_size; - #[allow(clippy::wildcard_imports)] - use crate::ast::*; - - static_assert_size!(Statement, 16); - static_assert_size!(Expression, 16); - static_assert_size!(Declaration, 16); - static_assert_size!(BindingPatternKind, 16); - static_assert_size!(ModuleDeclaration, 16); - static_assert_size!(ClassElement, 16); - static_assert_size!(ExportDefaultDeclarationKind, 16); - static_assert_size!(AssignmentTargetPattern, 16); - static_assert_size!(AssignmentTargetMaybeDefault, 24); - static_assert_size!(AssignmentTargetProperty, 16); - static_assert_size!(TSLiteral, 16); - static_assert_size!(TSType, 16); + assert_eq_size!(crate::ast::Statement, [u8; 16]); + assert_eq_size!(crate::ast::Expression, [u8; 16]); + assert_eq_size!(crate::ast::Declaration, [u8; 16]); + assert_eq_size!(crate::ast::BindingPatternKind, [u8; 16]); + assert_eq_size!(crate::ast::ModuleDeclaration, [u8; 16]); + assert_eq_size!(crate::ast::ClassElement, [u8; 16]); + assert_eq_size!(crate::ast::ExportDefaultDeclarationKind, [u8; 16]); + assert_eq_size!(crate::ast::AssignmentTargetPattern, [u8; 16]); + assert_eq_size!(crate::ast::AssignmentTargetMaybeDefault, [u8; 24]); + assert_eq_size!(crate::ast::AssignmentTargetProperty, [u8; 16]); + assert_eq_size!(crate::ast::TSLiteral, [u8; 16]); + assert_eq_size!(crate::ast::TSType, [u8; 16]); } diff --git a/crates/oxc_hir/Cargo.toml b/crates/oxc_hir/Cargo.toml index f61f95669..c3961301d 100644 --- a/crates/oxc_hir/Cargo.toml +++ b/crates/oxc_hir/Cargo.toml @@ -21,8 +21,8 @@ oxc_syntax = { workspace = true } oxc_index = { workspace = true } oxc_semantic2 = { workspace = true } -bitflags = { workspace = true } -num-bigint = { workspace = true } +bitflags = { workspace = true } +num-bigint = { workspace = true } serde = { workspace = true, features = ["derive"], optional = true } serde_json = { workspace = true, optional = true } diff --git a/crates/oxc_index/Cargo.toml b/crates/oxc_index/Cargo.toml index 1a25dddc5..f3e27dea7 100644 --- a/crates/oxc_index/Cargo.toml +++ b/crates/oxc_index/Cargo.toml @@ -11,4 +11,5 @@ license.workspace = true repository.workspace = true [dependencies] -index_vec = { workspace = true } +index_vec = { workspace = true } +static_assertions = { workspace = true } diff --git a/crates/oxc_index/src/lib.rs b/crates/oxc_index/src/lib.rs index e018e724e..b03ed1e50 100644 --- a/crates/oxc_index/src/lib.rs +++ b/crates/oxc_index/src/lib.rs @@ -3,13 +3,4 @@ //! pub use index_vec::{define_index_type, index_vec, IndexSlice, IndexVec}; - -/// Type size assertion. The first argument is a type and the second argument is its expected size. -/// -/// -#[macro_export] -macro_rules! static_assert_size { - ($ty:ty, $size:expr) => { - const _: [(); $size] = [(); std::mem::size_of::<$ty>()]; - }; -} +pub use static_assertions::*; diff --git a/crates/oxc_minifier/Cargo.toml b/crates/oxc_minifier/Cargo.toml index 7dc15a854..5bef1d987 100644 --- a/crates/oxc_minifier/Cargo.toml +++ b/crates/oxc_minifier/Cargo.toml @@ -21,7 +21,7 @@ oxc_semantic2 = { workspace = true } oxc_syntax = { workspace = true } [dev-dependencies] -walkdir = { workspace = true } +walkdir = { workspace = true } pico-args = { workspace = true } [target.'cfg(not(target_env = "msvc"))'.dev-dependencies] diff --git a/crates/oxc_parser/src/lexer/token.rs b/crates/oxc_parser/src/lexer/token.rs index d5c9cd072..4f8b5ccc7 100644 --- a/crates/oxc_parser/src/lexer/token.rs +++ b/crates/oxc_parser/src/lexer/token.rs @@ -28,11 +28,9 @@ pub struct Token<'a> { #[cfg(target_pointer_width = "64")] mod size_asserts { - use oxc_index::static_assert_size; + use oxc_index::assert_eq_size; - use super::Token; - - static_assert_size!(Token, 48); + assert_eq_size!(super::Token, [u8; 48]); } impl<'a> Token<'a> { diff --git a/crates/oxc_semantic/src/symbol/mod.rs b/crates/oxc_semantic/src/symbol/mod.rs index 90b0536f9..9a47386db 100644 --- a/crates/oxc_semantic/src/symbol/mod.rs +++ b/crates/oxc_semantic/src/symbol/mod.rs @@ -35,8 +35,8 @@ pub struct Symbol { #[cfg(target_pointer_width = "64")] mod size_asserts { - use oxc_index::static_assert_size; - static_assert_size!(super::Symbol, 88); + use oxc_index::assert_eq_size; + assert_eq_size!(super::Symbol, [u8; 88]); } bitflags! { diff --git a/crates/oxc_semantic2/src/symbol.rs b/crates/oxc_semantic2/src/symbol.rs index 1c4e87cb1..1d37d0c81 100644 --- a/crates/oxc_semantic2/src/symbol.rs +++ b/crates/oxc_semantic2/src/symbol.rs @@ -13,11 +13,6 @@ define_index_type! { pub struct SymbolId = u32; } -#[cfg(target_pointer_width = "64")] -mod size_asserts { - oxc_index::static_assert_size!(Option, 8); -} - bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SymbolFlags: u16 { diff --git a/tasks/minsize/Cargo.toml b/tasks/minsize/Cargo.toml index 7ff1f7a10..1a76da5c2 100644 --- a/tasks/minsize/Cargo.toml +++ b/tasks/minsize/Cargo.toml @@ -13,4 +13,4 @@ oxc_tasks_common = { workspace = true } flate2 = { workspace = true } humansize = "2.1.3" -brotlic = "0.8.1" +brotlic = "0.8.1"