From ac72d08592bfbb8603181f0db15cddf2fc34daed Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:26:23 +0330 Subject: [PATCH] chore: cleanup the dependencies on `static_assertions` and `oxc_index`. (#3095) We used to export `static_assertions` as part of the `oxc_index`. It would've made sense back when it was only a vessel for exporting other crates - although even then it wouldn't make much sense other than being convenient - Now with it turning into a port of `index_vec` and potentially getting bigger as the result of specific needs of the project; It makes much more sense to stop exporting it from `oxc_index` and use the crate directly in places that used to use what `oxc_index` were exporting. PS: we may want to follow up this with an `oxc_asset` crate containing our own set of assertion tools which would also export `static_assertions`. --- Cargo.lock | 7 +++---- crates/oxc_ast/Cargo.toml | 3 ++- crates/oxc_ast/src/lib.rs | 2 +- crates/oxc_index/Cargo.toml | 3 +-- crates/oxc_index/src/lib.rs | 2 -- crates/oxc_linter/Cargo.toml | 3 ++- crates/oxc_linter/src/lib.rs | 2 +- crates/oxc_parser/Cargo.toml | 12 ++++++------ crates/oxc_parser/src/lexer/token.rs | 2 +- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03747e7f5..5205dc336 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,12 +1239,12 @@ dependencies = [ "bitflags 2.5.0", "num-bigint", "oxc_allocator", - "oxc_index", "oxc_span", "oxc_syntax", "ryu-js", "serde", "serde_json", + "static_assertions", "tsify", "wasm-bindgen", ] @@ -1354,7 +1354,6 @@ name = "oxc_index" version = "0.12.5" dependencies = [ "serde", - "static_assertions", ] [[package]] @@ -1406,7 +1405,6 @@ dependencies = [ "oxc_ast", "oxc_codegen", "oxc_diagnostics", - "oxc_index", "oxc_macros", "oxc_parser", "oxc_resolver", @@ -1420,6 +1418,7 @@ dependencies = [ "rustc-hash", "serde", "serde_json", + "static_assertions", "url", ] @@ -1490,12 +1489,12 @@ dependencies = [ "oxc_allocator", "oxc_ast", "oxc_diagnostics", - "oxc_index", "oxc_span", "oxc_syntax", "rustc-hash", "seq-macro", "serde_json", + "static_assertions", ] [[package]] diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 4c813d3fd..e460154fe 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -21,7 +21,6 @@ doctest = false oxc_allocator = { workspace = true } oxc_span = { workspace = true } oxc_syntax = { workspace = true } -oxc_index = { workspace = true } bitflags = { workspace = true } num-bigint = { workspace = true } @@ -33,6 +32,8 @@ ryu-js = { workspace = true, optional = true } tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } +static_assertions = { workspace = true } + [features] default = [] serialize = [ diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 8a557cdd5..8fa60dfd3 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -56,7 +56,7 @@ pub use crate::{ #[test] fn size_asserts() { use crate::ast; - use oxc_index::assert_eq_size; + use static_assertions::assert_eq_size; assert_eq_size!(ast::Statement, [u8; 16]); assert_eq_size!(ast::Expression, [u8; 16]); diff --git a/crates/oxc_index/Cargo.toml b/crates/oxc_index/Cargo.toml index 93916b012..9a2a8c635 100644 --- a/crates/oxc_index/Cargo.toml +++ b/crates/oxc_index/Cargo.toml @@ -19,8 +19,7 @@ workspace = true doctest = false [dependencies] -serde = { workspace = true } -static_assertions = { workspace = true } +serde = { workspace = true } [features] serialize = [] diff --git a/crates/oxc_index/src/lib.rs b/crates/oxc_index/src/lib.rs index b081c9320..ed44b577f 100644 --- a/crates/oxc_index/src/lib.rs +++ b/crates/oxc_index/src/lib.rs @@ -150,8 +150,6 @@ mod indexing; pub use idxslice::{IndexBox, IndexSlice}; pub use indexing::{IdxRangeBounds, IdxSliceIndex}; -pub use static_assertions::*; - #[macro_use] mod macros; diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index 033015d7e..2e84e7c40 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -28,7 +28,6 @@ oxc_macros = { workspace = true } oxc_semantic = { workspace = true } oxc_syntax = { workspace = true } oxc_codegen = { workspace = true } -oxc_index = { workspace = true } oxc_resolver = { workspace = true } rayon = { workspace = true } @@ -50,5 +49,7 @@ once_cell = { workspace = true } memchr = { workspace = true } json-strip-comments = { workspace = true } +static_assertions = { workspace = true } + [dev-dependencies] insta = { workspace = true } diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index beaa1839d..753001b8f 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -41,7 +41,7 @@ use oxc_semantic::AstNode; #[cfg(target_pointer_width = "64")] #[test] fn size_asserts() { - use oxc_index::assert_eq_size; + use static_assertions::assert_eq_size; // `RuleEnum` runs in a really tight loop, make sure it is small for CPU cache. // A reduction from 168 bytes to 16 results 15% performance improvement. diff --git a/crates/oxc_parser/Cargo.toml b/crates/oxc_parser/Cargo.toml index 2ab9ddf51..14d3aa00a 100644 --- a/crates/oxc_parser/Cargo.toml +++ b/crates/oxc_parser/Cargo.toml @@ -23,13 +23,13 @@ oxc_span = { workspace = true } oxc_ast = { workspace = true } oxc_syntax = { workspace = true } oxc_diagnostics = { workspace = true } -oxc_index = { workspace = true } -assert-unchecked = { workspace = true } -bitflags = { workspace = true } -rustc-hash = { workspace = true } -num-bigint = { workspace = true } -seq-macro = { workspace = true } +static_assertions = { workspace = true } +assert-unchecked = { workspace = true } +bitflags = { workspace = true } +rustc-hash = { workspace = true } +num-bigint = { workspace = true } +seq-macro = { workspace = true } memchr = { workspace = true } diff --git a/crates/oxc_parser/src/lexer/token.rs b/crates/oxc_parser/src/lexer/token.rs index 122c5080b..84119516e 100644 --- a/crates/oxc_parser/src/lexer/token.rs +++ b/crates/oxc_parser/src/lexer/token.rs @@ -35,7 +35,7 @@ pub struct Token { #[cfg(target_pointer_width = "64")] mod size_asserts { - oxc_index::assert_eq_size!(super::Token, [u8; 16]); + static_assertions::assert_eq_size!(super::Token, [u8; 16]); } impl Token {