Skip to content

Commit

Permalink
chore(deps): remove static_assertions dependency. (#4883)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Aug 14, 2024
1 parent a9c729a commit c164bb8
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 45 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions crates/oxc_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
26 changes: 13 additions & 13 deletions crates/oxc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ast::Statement>() == 16);
assert!(size_of::<ast::Expression>() == 16);
assert!(size_of::<ast::Declaration>() == 16);
assert!(size_of::<ast::BindingPatternKind>() == 16);
assert!(size_of::<ast::ModuleDeclaration>() == 16);
assert!(size_of::<ast::ClassElement>() == 16);
assert!(size_of::<ast::ExportDefaultDeclarationKind>() == 16);
assert!(size_of::<ast::AssignmentTargetPattern>() == 16);
assert!(size_of::<ast::AssignmentTargetMaybeDefault>() == 16);
assert!(size_of::<ast::AssignmentTargetProperty>() == 16);
assert!(size_of::<ast::TSLiteral>() == 16);
assert!(size_of::<ast::TSType>() == 16);
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<RuleEnum>() == 16);
}

#[derive(Debug)]
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 21 additions & 19 deletions crates/oxc_parser/src/lexer/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<super::Token>() == 16);
}

impl Token {
Expand Down

0 comments on commit c164bb8

Please sign in to comment.