From 000144f52afa9ecc64649ec1914bf5856f3e916c Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Tue, 29 Oct 2024 21:46:10 +0700 Subject: [PATCH] Remove size_of_test macro from legacy layout and inline it (#34055) in the last remaining location it is used. Signed-off-by: Nico Burns --- Cargo.lock | 12 +----------- Cargo.toml | 3 +-- components/layout/Cargo.toml | 1 - components/layout/fragment.rs | 8 -------- components/shared/background_hang_monitor/Cargo.toml | 1 - components/shared/base/Cargo.toml | 2 +- components/shared/base/id.rs | 9 ++++++++- 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5707e8d65dc..9316ab7e156 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -346,7 +346,6 @@ dependencies = [ "malloc_size_of_derive", "parking_lot", "serde", - "size_of_test", "webrender_api", ] @@ -377,7 +376,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot", "serde", - "size_of_test", + "static_assertions", "time 0.3.36", "webrender_api", "windows-sys 0.59.0", @@ -3894,7 +3893,6 @@ dependencies = [ "servo_config", "servo_geometry", "servo_url", - "size_of_test", "smallvec", "style", "style_traits", @@ -6779,14 +6777,6 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" -[[package]] -name = "size_of_test" -version = "0.0.1" -source = "git+https://github.com/servo/stylo?branch=2024-10-04#789ab89c30d94e25f514c19c079a00a6ab583638" -dependencies = [ - "static_assertions", -] - [[package]] name = "slab" version = "0.4.9" diff --git a/Cargo.toml b/Cargo.toml index d12c353f80e..a18a842340d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,10 +113,10 @@ servo-media-dummy = { git = "https://github.com/servo/media" } servo-media-gstreamer = { git = "https://github.com/servo/media" } servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-10-04", features = ["servo"] } servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-10-04" } -size_of_test = { git = "https://github.com/servo/stylo", branch = "2024-10-04" } smallbitvec = "2.5.3" smallvec = "1.13" sparkle = "0.1.26" +static_assertions = "1.1" string_cache = "0.8" string_cache_codegen = "0.5" style = { git = "https://github.com/servo/stylo", branch = "2024-10-04", features = ["servo"] } @@ -192,7 +192,6 @@ codegen-units = 1 # selectors = { path = "../stylo/selectors" } # servo_arc = { path = "../stylo/servo_arc" } # servo_atoms = { path = "../stylo/atoms" } -# size_of_test = { path = "../stylo/size_of_test" } # static_prefs = { path = "../stylo/style_static_prefs" } # style = { path = "../stylo/style" } # style_config = { path = "../stylo/style_config" } diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 8e86bbfd6a6..797aac24cfa 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -44,7 +44,6 @@ servo_atoms = { workspace = true } servo_config = { path = "../config" } servo_geometry = { path = "../geometry" } servo_url = { path = "../url" } -size_of_test = { workspace = true } smallvec = { workspace = true, features = ["union"] } style = { workspace = true } style_traits = { workspace = true } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 01004e47438..6daa29325bd 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -29,7 +29,6 @@ use script_layout_interface::wrapper_traits::{ use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaData, SVGSVGData}; use serde::ser::{Serialize, SerializeStruct, Serializer}; use servo_url::ServoUrl; -use size_of_test::size_of_test; use style::computed_values::border_collapse::T as BorderCollapse; use style::computed_values::box_sizing::T as BoxSizing; use style::computed_values::clear::T as Clear; @@ -167,11 +166,6 @@ pub struct Fragment { pub established_reference_frame: Option, } -#[cfg(debug_assertions)] -size_of_test!(Fragment, 176); -#[cfg(not(debug_assertions))] -size_of_test!(Fragment, 152); - impl Serialize for Fragment { fn serialize(&self, serializer: S) -> Result { let mut serializer = serializer.serialize_struct("fragment", 3)?; @@ -226,8 +220,6 @@ pub enum SpecificFragmentInfo { TruncatedFragment(Box), } -size_of_test!(SpecificFragmentInfo, 24); - impl SpecificFragmentInfo { fn restyle_damage(&self) -> RestyleDamage { let flow = match *self { diff --git a/components/shared/background_hang_monitor/Cargo.toml b/components/shared/background_hang_monitor/Cargo.toml index 90a0c90d003..4eed7c0430c 100644 --- a/components/shared/background_hang_monitor/Cargo.toml +++ b/components/shared/background_hang_monitor/Cargo.toml @@ -20,5 +20,4 @@ malloc_size_of = { workspace = true } malloc_size_of_derive = { workspace = true } parking_lot = { workspace = true } serde = { workspace = true } -size_of_test = { workspace = true } webrender_api = { workspace = true } diff --git a/components/shared/base/Cargo.toml b/components/shared/base/Cargo.toml index 09dd2cd928d..db39415bfb6 100644 --- a/components/shared/base/Cargo.toml +++ b/components/shared/base/Cargo.toml @@ -20,9 +20,9 @@ malloc_size_of = { workspace = true } malloc_size_of_derive = { workspace = true } parking_lot = { workspace = true } serde = { workspace = true } -size_of_test = { workspace = true } time_03 = { workspace = true } webrender_api = { workspace = true } +static_assertions = { workspace = true } [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] mach2 = { workspace = true } diff --git a/components/shared/base/id.rs b/components/shared/base/id.rs index 30b4744a2a4..47625ae7d44 100644 --- a/components/shared/base/id.rs +++ b/components/shared/base/id.rs @@ -16,9 +16,16 @@ use malloc_size_of::malloc_size_of_is_0; use malloc_size_of_derive::MallocSizeOf; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; -use size_of_test::size_of_test; 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); + }; +} + macro_rules! namespace_id_method { ($func_name:ident, $func_return_data_type:ident, $self:ident, $index_name:ident) => { fn $func_name(&mut $self) -> $func_return_data_type {