From 40e57e95b283e43084511206a070b652c27ff2f2 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Date: Thu, 14 Aug 2025 21:02:37 +0200 Subject: [PATCH] base: Remove last usage of static_assertions crate (#38687) Replace static_assertions in the `size_of_test` macro with `const assert`s. The error message is still informative. Additionally also remove the `cfg` guard, which caused the assertion to only be enabled on 64 bit platforms, which is something one would not expect given the name `size_of_test` of the macro. `cargo tree -i static_assertions` now points to only `stylo` using `static_assertions`, so we should be able to remove this dependency fairly easy, since the macro doesn't seem to be used there either at first glance. Testing: Covered by existing tests. --------- Signed-off-by: Jonathan Schwender --- Cargo.lock | 1 - Cargo.toml | 1 - components/shared/base/Cargo.toml | 1 - components/shared/base/id.rs | 3 +-- 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d300aad472d..34a30dba7db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -728,7 +728,6 @@ dependencies = [ "parking_lot", "serde", "servo_malloc_size_of", - "static_assertions", "time", "webrender_api", "windows-sys 0.59.0", diff --git a/Cargo.toml b/Cargo.toml index 1a18cb7e22c..63c909a9872 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,6 @@ servo-tracing = { path = "components/servo_tracing" } servo_arc = { git = "https://github.com/servo/stylo", branch = "2025-08-01" } smallbitvec = "2.6.0" smallvec = { version = "1.15", features = ["serde", "union"] } -static_assertions = "1.1" string_cache = "0.8" string_cache_codegen = "0.5" strum = "0.26" diff --git a/components/shared/base/Cargo.toml b/components/shared/base/Cargo.toml index fea06db6ed0..b293fa0faf3 100644 --- a/components/shared/base/Cargo.toml +++ b/components/shared/base/Cargo.toml @@ -20,7 +20,6 @@ malloc_size_of = { workspace = true } malloc_size_of_derive = { workspace = true } parking_lot = { workspace = true } serde = { workspace = true } -static_assertions = { workspace = true } time = { workspace = true } webrender_api = { workspace = true } diff --git a/components/shared/base/id.rs b/components/shared/base/id.rs index 616fb5adf23..7510bb427a2 100644 --- a/components/shared/base/id.rs +++ b/components/shared/base/id.rs @@ -22,8 +22,7 @@ use webrender_api::{ExternalScrollId, PipelineId as WebRenderPipelineId}; /// Asserts the size of a type at compile time. macro_rules! size_of_test { ($t: ty, $expected_size: expr) => { - #[cfg(target_pointer_width = "64")] - ::static_assertions::const_assert_eq!(std::mem::size_of::<$t>(), $expected_size); + const _: () = assert!(std::mem::size_of::<$t>() == $expected_size); }; }