From c164bb8b642cf2507b158535434edaa1706331a7 Mon Sep 17 00:00:00 2001 From: rzvxa <3788964+rzvxa@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:18:06 +0000 Subject: [PATCH] chore(deps): remove `static_assertions` dependency. (#4883) --- Cargo.lock | 3 -- Cargo.toml | 1 - crates/oxc_ast/Cargo.toml | 3 -- crates/oxc_ast/src/lib.rs | 26 ++++++++--------- crates/oxc_linter/Cargo.toml | 1 - crates/oxc_linter/src/lib.rs | 4 +-- crates/oxc_parser/Cargo.toml | 1 - crates/oxc_parser/src/lexer/number.rs | 40 ++++++++++++++------------- crates/oxc_parser/src/lexer/token.rs | 2 +- 9 files changed, 36 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca0490c465870..39718acb8652a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1469,7 +1469,6 @@ dependencies = [ "oxc_syntax", "serde", "serde_json", - "static_assertions", "tsify", "wasm-bindgen", ] @@ -1689,7 +1688,6 @@ dependencies = [ "schemars", "serde", "serde_json", - "static_assertions", "url", ] @@ -1777,7 +1775,6 @@ dependencies = [ "rustc-hash", "seq-macro", "serde_json", - "static_assertions", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 99713a028c9b7..b407cab9ae2c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,7 +171,6 @@ serde = "1.0.206" serde_json = "1.0.124" serde-wasm-bindgen = "0.6.5" similar = "2.6.0" -static_assertions = "1.1.0" syn = { version = "2.0.74", default-features = false } tempfile = "3.12.0" textwrap = "0.16.1" diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 23e2490aec161..dbe469e833091 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -33,9 +33,6 @@ serde_json = { workspace = true, optional = true } tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } -[dev-dependencies] -static_assertions = { workspace = true } - [features] default = [] serialize = [ diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 0eeb31bdd0f65..8ed15f752c5f9 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -90,22 +90,22 @@ pub use crate::{ #[cfg(target_pointer_width = "64")] #[test] fn size_asserts() { - use static_assertions::assert_eq_size; + use std::mem::size_of; use crate::ast; - assert_eq_size!(ast::Statement, [u8; 16]); - assert_eq_size!(ast::Expression, [u8; 16]); - assert_eq_size!(ast::Declaration, [u8; 16]); - assert_eq_size!(ast::BindingPatternKind, [u8; 16]); - assert_eq_size!(ast::ModuleDeclaration, [u8; 16]); - assert_eq_size!(ast::ClassElement, [u8; 16]); - assert_eq_size!(ast::ExportDefaultDeclarationKind, [u8; 16]); - assert_eq_size!(ast::AssignmentTargetPattern, [u8; 16]); - assert_eq_size!(ast::AssignmentTargetMaybeDefault, [u8; 16]); - assert_eq_size!(ast::AssignmentTargetProperty, [u8; 16]); - assert_eq_size!(ast::TSLiteral, [u8; 16]); - assert_eq_size!(ast::TSType, [u8; 16]); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); + assert!(size_of::() == 16); } #[test] diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index 827d342431604..964db7e79f1d9 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -54,7 +54,6 @@ json-strip-comments = { workspace = true } schemars = { workspace = true, features = ["indexmap2"] } [dev-dependencies] -static_assertions = { workspace = true } insta = { workspace = true } project-root = { workspace = true } markdown = { version = "1.0.0-alpha.19" } diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 38c221f27bb98..808071e71a8c9 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -44,12 +44,10 @@ use crate::{ #[cfg(target_pointer_width = "64")] #[test] fn size_asserts() { - 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. // See codspeed in https://github.com/oxc-project/oxc/pull/1783 - assert_eq_size!(RuleEnum, [u8; 16]); + assert!(std::mem::size_of::() == 16); } #[derive(Debug)] diff --git a/crates/oxc_parser/Cargo.toml b/crates/oxc_parser/Cargo.toml index 54ed40c56fc38..790180e423b07 100644 --- a/crates/oxc_parser/Cargo.toml +++ b/crates/oxc_parser/Cargo.toml @@ -38,7 +38,6 @@ memchr = { workspace = true } oxc_ast = { workspace = true, features = ["serialize"] } serde_json = { workspace = true } ouroboros = { workspace = true } # for `multi-thread` example -static_assertions = { workspace = true } [features] # Expose Lexer for benchmarks diff --git a/crates/oxc_parser/src/lexer/number.rs b/crates/oxc_parser/src/lexer/number.rs index cea51cb00abe0..5dabe13f6975f 100644 --- a/crates/oxc_parser/src/lexer/number.rs +++ b/crates/oxc_parser/src/lexer/number.rs @@ -450,25 +450,27 @@ mod test { } } - // decimal - static_assertions::const_assert_eq!(decimal_byte_to_value(b'0'), 0); - static_assertions::const_assert_eq!(decimal_byte_to_value(b'9'), 9); - - // binary - static_assertions::const_assert_eq!(binary_byte_to_value(b'0'), 0); - static_assertions::const_assert_eq!(binary_byte_to_value(b'1'), 1); - - // octal - static_assertions::const_assert_eq!(octal_byte_to_value(b'0'), 0); - static_assertions::const_assert_eq!(octal_byte_to_value(b'7'), 7); - - // hex - static_assertions::const_assert_eq!(hex_byte_to_value(b'0'), 0); - static_assertions::const_assert_eq!(hex_byte_to_value(b'9'), 9); - static_assertions::const_assert_eq!(hex_byte_to_value(b'A'), 10); - static_assertions::const_assert_eq!(hex_byte_to_value(b'F'), 15); - static_assertions::const_assert_eq!(hex_byte_to_value(b'a'), 10); - static_assertions::const_assert_eq!(hex_byte_to_value(b'f'), 15); + const _: () = { + // decimal + assert!(decimal_byte_to_value(b'0') == 0); + assert!(decimal_byte_to_value(b'9') == 9); + + // binary + assert!(binary_byte_to_value(b'0') == 0); + assert!(binary_byte_to_value(b'1') == 1); + + // octal + assert!(octal_byte_to_value(b'0') == 0); + assert!(octal_byte_to_value(b'7') == 7); + + // hex + assert!(hex_byte_to_value(b'0') == 0); + assert!(hex_byte_to_value(b'9') == 9); + assert!(hex_byte_to_value(b'A') == 10); + assert!(hex_byte_to_value(b'F') == 15); + assert!(hex_byte_to_value(b'a') == 10); + assert!(hex_byte_to_value(b'f') == 15); + }; #[test] #[allow(clippy::excessive_precision, clippy::cast_precision_loss)] diff --git a/crates/oxc_parser/src/lexer/token.rs b/crates/oxc_parser/src/lexer/token.rs index a70aed25d1f77..cabdf2b4e51eb 100644 --- a/crates/oxc_parser/src/lexer/token.rs +++ b/crates/oxc_parser/src/lexer/token.rs @@ -41,7 +41,7 @@ pub struct Token { #[cfg(all(test, target_pointer_width = "64"))] mod size_asserts { - static_assertions::assert_eq_size!(super::Token, [u8; 16]); + const _: () = assert!(std::mem::size_of::() == 16); } impl Token {