From c426ed6e0a76dde2fc771059702e3bcf6d5f3833 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 14 Aug 2026 21:23:36 +0000 Subject: [PATCH] Remove dead code from bun_core, bun_css, bun_jsc, and the FFI crates Cross-crate reachability analysis over the Rust workspace (intersected across linux-gnu, linux-musl, android, freebsd, darwin and windows-msvc, test targets included) found these pub items unreachable from any shipped root. Deletes the inherent eql/to_css/parse forwarders in bun_css that the trait impls replaced (including the CalcValue::eql hook that only they called), leftover helpers in bun_core/bun_alloc/bun_ast/bun_ptr/bun_jsc, and unused wrappers, aliases and constants in the sys crates. Verified with cargo check --workspace on all ten CI triples (plus the bun_debug/bun_asan cfgs and --all-targets on linux) and a full debug build. A source lint in test/internal/source-lints keeps the symbols from coming back. --- src/ast/symbol.rs | 8 - src/boringssl_sys/boringssl.rs | 8 - src/bun_alloc/lib.rs | 29 +--- src/bun_core/bounded_array.rs | 8 - src/bun_core/external_shared.rs | 11 -- src/bun_core/lib.rs | 17 --- src/bun_core/string/mod.rs | 11 -- src/bun_core/string/write.rs | 3 - src/bun_core/util.rs | 44 +----- src/cares_sys/c_ares.rs | 6 - src/css/css_parser.rs | 19 +-- src/css/generics.rs | 10 -- src/css/lib.rs | 2 +- src/css/properties/custom.rs | 8 +- src/css/rules/mod.rs | 7 +- src/css/selectors/parser.rs | 36 +---- src/css/values/angle.rs | 4 - src/css/values/calc.rs | 132 +---------------- src/css/values/css_string.rs | 6 - src/css/values/time.rs | 7 - src/css_derive/lib.rs | 4 +- src/install/windows-shim/main.rs | 4 +- src/jsc/AbortSignal.rs | 14 +- src/jsc/ConsoleObject.rs | 6 - src/jsc/ErrorCode.rs | 5 - src/jsc/JSCell.rs | 6 +- src/jsc/JSGlobalObject.rs | 13 -- src/jsc/JSValue.rs | 6 - src/jsc/Task.rs | 8 - src/jsc/TopExceptionScope.rs | 27 ---- src/jsc/array_buffer.rs | 39 +---- src/jsc/job.rs | 33 +---- src/jsc/lib.rs | 33 ----- src/jsc/uuid.rs | 5 - src/ptr/lib.rs | 11 -- src/sys/lib.rs | 31 +--- src/sys/linux_syscall.rs | 2 +- src/sys/windows/mod.rs | 3 +- src/tcc_sys/lib.rs | 3 +- src/tcc_sys/tcc.rs | 3 - src/uws_sys/Loop.rs | 10 -- src/uws_sys/Response.rs | 9 -- src/uws_sys/SocketGroup.rs | 7 - src/uws_sys/lib.rs | 5 +- src/uws_sys/socket.rs | 24 +-- src/windows_sys/externs.rs | 21 --- src/zlib_sys/posix.rs | 4 +- src/zlib_sys/shared.rs | 7 +- .../dead-symbols-cross-crate-sweep.test.ts | 139 ++++++++++++++++++ 49 files changed, 183 insertions(+), 675 deletions(-) create mode 100644 test/internal/source-lints/dead-symbols-cross-crate-sweep.test.ts diff --git a/src/ast/symbol.rs b/src/ast/symbol.rs index 7bc5ac875ee..1b76b3abee9 100644 --- a/src/ast/symbol.rs +++ b/src/ast/symbol.rs @@ -545,14 +545,6 @@ impl Map { }) } - pub fn init(source_count: usize) -> Map { - let mut v: NestedList = Vec::with_capacity(source_count); - v.resize_with(source_count, Vec::new); - Map { - symbols_for_source: v, - } - } - // Takes ownership of `list` and boxes it into a one-element NestedList. // PERF: one extra allocation — profile if needed (single caller is the // printer one-shot, cold). diff --git a/src/boringssl_sys/boringssl.rs b/src/boringssl_sys/boringssl.rs index ed3994d474b..b4467c77cee 100644 --- a/src/boringssl_sys/boringssl.rs +++ b/src/boringssl_sys/boringssl.rs @@ -331,10 +331,6 @@ impl GeneralNames { unsafe { sk_num(self.0.as_ptr().cast::()) } } - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - /// Borrows the `i`th entry; `None` past the end. pub(crate) fn get(&self, i: usize) -> Option<&GENERAL_NAME> { if i >= self.len() { @@ -1098,10 +1094,6 @@ opaque!( /// `TLS1_3_VERSION` (`openssl/tls1.h`). pub const TLS1_3_VERSION: u16 = 0x0304; -/// `X509_V_OK` (`openssl/x509.h`). -pub const X509_V_OK: c_long = 0; -/// `SSL_SESS_CACHE_CLIENT` (`openssl/ssl.h`). -pub const SSL_SESS_CACHE_CLIENT: c_int = 1; unsafe extern "C" { pub safe fn TLS_method() -> *const SSL_METHOD; diff --git a/src/bun_alloc/lib.rs b/src/bun_alloc/lib.rs index d99683419c7..b8b43c68734 100644 --- a/src/bun_alloc/lib.rs +++ b/src/bun_alloc/lib.rs @@ -592,13 +592,6 @@ impl Default for Mutex { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AllocError; -impl AllocError { - #[inline] - pub const fn name(self) -> &'static str { - "OutOfMemory" - } -} - impl core::fmt::Display for AllocError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_str("OutOfMemory") @@ -698,13 +691,6 @@ pub unsafe fn realloc_raw( Ok(new_ptr.cast::()) } -/// `mi_usable_size` — actual allocated size for a mimalloc-owned ptr. -#[inline] -pub fn usable_size(ptr: *const u8) -> usize { - // SAFETY: `mi_usable_size` is null-safe (returns 0). - unsafe { mimalloc::mi_usable_size(ptr.cast()) } -} - // ────────────────────────────────────────────────────────────────────────── // Symbols hoisted DOWN into T0 so higher tiers can re-import without cycles. // ────────────────────────────────────────────────────────────────────────── @@ -1453,7 +1439,7 @@ macro_rules! bss_singleton { /// Heap-allocate a fresh `T` via mimalloc and run its in-place `init_at` initializer. /// -/// Shared body of the `BSSList`/`BSSStringList`/`BSSMapInner` `init()` shims. +/// Shared body of the `BSSStringList`/`BSSMapInner` `init()` shims. /// The once-guard is the *caller's* responsibility; use the `bss_*!` macros /// for the canonical per-monomorphization singleton. #[doc(hidden)] // Public only for the `bss_singleton!` macro expansion in dependent crates. @@ -2020,9 +2006,7 @@ impl BSSList { // Rust cannot define generic statics, so the per-monomorphization storage is // emitted at the *declare site* via `bss_list! { name: T, N }` (see macro // below), which owns a `SyncUnsafeCell>` + `Once` and - // calls `init_at` on first access. `init()` is kept for callers that manage - // their own once-guard (e.g. `dir_info::hash_map_instance`); it heap-allocs - // a fresh instance each call. + // calls `init_at` on first access. /// In-place field initialization into demand-zero storage. /// @@ -2048,13 +2032,6 @@ impl BSSList { } } - /// Heap-allocate and initialize a fresh instance. The once-guard is the - /// *caller's* responsibility — use `bss_list!` for - /// the canonical per-monomorphization singleton. - pub fn init() -> NonNull { - bss_heap_init(Self::init_at) - } - // Singleton teardown belongs to the `bss_list!` singleton wrapper; // Drop only frees the heap-allocated head chain. @@ -2066,7 +2043,7 @@ impl BSSList { &mut self, ) -> core::result::Result<*mut MaybeUninit, AllocError> { self.used += 1; - // SAFETY: head is always non-null after init() (points at self.tail or heap block). + // SAFETY: head is always non-null after init_at() (points at self.tail or heap block). let mut head_ptr = self.head.unwrap(); // Check capacity first, allocate the new block if // needed, then reserve exactly one slot. Safe under `self.mutex`. diff --git a/src/bun_core/bounded_array.rs b/src/bun_core/bounded_array.rs index d05eb3d4777..446625e2658 100644 --- a/src/bun_core/bounded_array.rs +++ b/src/bun_core/bounded_array.rs @@ -125,14 +125,6 @@ impl BoundedArrayAligned { // If a non-`Copy` caller // appears, add a `from_slice_clone` or use `ptr::copy_nonoverlapping`. - /// Return the element at index `i` of the slice. - pub fn get(&self, i: usize) -> T - where - T: Copy, - { - self.const_slice()[i] - } - /// Check that the slice can hold at least `additional_count` items. pub(crate) fn ensure_unused_capacity( &self, diff --git a/src/bun_core/external_shared.rs b/src/bun_core/external_shared.rs index 171a06c38aa..79d20322e40 100644 --- a/src/bun_core/external_shared.rs +++ b/src/bun_core/external_shared.rs @@ -39,13 +39,6 @@ impl ExternalShared { self.ptr.as_ptr() } - /// Alias of [`Self::get`] — provided so call sites that previously used a - /// hand-rolled `NonNull` wrapper (e.g. `AbortSignalRef`) keep compiling. - #[inline] - pub fn as_ptr(&self) -> *mut T { - self.ptr.as_ptr() - } - /// # Safety /// `raw` must be a valid pointer managed by the external refcount. pub unsafe fn clone_from_raw(raw: *mut T) -> Self { @@ -111,10 +104,6 @@ impl ExternalSharedOptional { ptr: NonNull::new(incremented_raw), } } - - pub fn get(&self) -> Option<*mut T> { - self.ptr.map(|p| p.as_ptr()) - } } impl Default for ExternalSharedOptional { diff --git a/src/bun_core/lib.rs b/src/bun_core/lib.rs index c69c6a85b16..1397e66edd9 100644 --- a/src/bun_core/lib.rs +++ b/src/bun_core/lib.rs @@ -129,16 +129,6 @@ impl RawSlice { pub const fn new(s: &[T]) -> Self { RawSlice(core::ptr::from_ref(s)) } - /// Wrap a raw slice pointer. - /// - /// # Safety - /// `p` must either be a (dangling, len 0) empty slice or point to `len` - /// initialized `T` that remain live and stable for the lifetime of every - /// `RawSlice` copied from the result. - #[inline] - pub const unsafe fn from_raw(p: *const [T]) -> Self { - RawSlice(p) - } #[inline] pub const fn as_ptr(self) -> *const [T] { self.0 @@ -935,13 +925,6 @@ pub fn concat_boxed(parts: &[&[T]]) -> Box<[T]> { v.into_boxed_slice() } -/// Back-compat alias for the original `u8`-only buffer-concat. New code should -/// call [`concat_into`] directly. -#[inline] -pub fn concat<'b>(buf: &'b mut [u8], parts: &[&[u8]]) -> &'b [u8] { - concat_into(buf, parts) -} - /// Tagged-union field projection — `data.file`, `chunk.content.javascript`. /// /// Consolidates ~20 identical diff --git a/src/bun_core/string/mod.rs b/src/bun_core/string/mod.rs index 2e7a65b21b0..2eae4e7d1ea 100644 --- a/src/bun_core/string/mod.rs +++ b/src/bun_core/string/mod.rs @@ -1835,17 +1835,6 @@ impl SliceWithUnderlyingString { } } - /// `fromUTF8` — wrap a borrowed UTF-8 slice (caller keeps it alive). - #[inline] - pub fn from_utf8(utf8: &[u8]) -> SliceWithUnderlyingString { - SliceWithUnderlyingString { - utf8: ZigStringSlice::from_utf8_never_free(utf8), - underlying: String::DEAD, - #[cfg(debug_assertions)] - did_report_extra_memory_debug: false, - } - } - /// `slice` — the UTF-8 byte view. #[inline] pub fn slice(&self) -> &[u8] { diff --git a/src/bun_core/string/write.rs b/src/bun_core/string/write.rs index df8d80418c4..5126b1694bf 100644 --- a/src/bun_core/string/write.rs +++ b/src/bun_core/string/write.rs @@ -11,7 +11,4 @@ //! (`FixedBufferStream`, `BufWriter`, `FmtAdapter`, `DiscardingWriter`) on top, //! so the existing `bun_io::Write` importers are unaffected. -/// `Result` over `core::fmt::Error` so `?` composes everywhere. -pub type Result = core::result::Result; - pub use crate::io::{IntLe, Write}; diff --git a/src/bun_core/util.rs b/src/bun_core/util.rs index 1e90288ed22..48b10e87698 100644 --- a/src/bun_core/util.rs +++ b/src/bun_core/util.rs @@ -37,11 +37,6 @@ pub unsafe fn bytes_as_slice_mut(bytes: &mut [u8]) -> &mut [T] { pub struct Unaligned(T); impl Unaligned { - #[inline(always)] - pub const fn new(value: T) -> Self { - Self(value) - } - #[inline(always)] pub fn get(self) -> T { // `self` is by-value (already moved into an aligned local), so a plain @@ -601,8 +596,7 @@ macro_rules! opaque_extern { // `bun_threading::Guarded` / `bun_threading::RwLock` directly. // // API parity with the previous `parking_lot` aliases: `const fn new(T)`, -// `.lock()` → guard (no `Result`), `.try_lock()` → `Option`, `.get_mut()`, -// `Default`. +// `.lock()` → guard (no `Result`), `.try_lock()` → `Option`, `Default`. /// Poison-free `std::sync::Mutex` wrapper. See module note above for why /// this is not `bun_threading::Guarded`. @@ -635,13 +629,6 @@ impl Mutex { Err(std::sync::TryLockError::WouldBlock) => None, } } - - #[inline] - pub fn get_mut(&mut self) -> &mut T { - self.0 - .get_mut() - .unwrap_or_else(std::sync::PoisonError::into_inner) - } } impl Default for Mutex { @@ -675,13 +662,6 @@ impl RwLock { .write() .unwrap_or_else(std::sync::PoisonError::into_inner) } - - #[inline] - pub fn get_mut(&mut self) -> &mut T { - self.0 - .get_mut() - .unwrap_or_else(std::sync::PoisonError::into_inner) - } } impl Default for RwLock { @@ -3356,12 +3336,6 @@ impl GenericIndex { GenericIndexOptional(self.0, core::marker::PhantomData) } } -impl GenericIndexOptional { - #[inline] - pub fn is_some(self) -> bool { - !self.is_none() - } -} /// `GenericIndex::Optional` — `MAX` is `none`. #[repr(transparent)] @@ -3386,18 +3360,7 @@ impl core::fmt::Debug for GenericIndexOptional { } } impl GenericIndexOptional { - #[inline] - pub fn is_none(self) -> bool { - self.0 == I::NULL_VALUE - } - pub const NONE: Self = Self(I::NULL_VALUE, core::marker::PhantomData); - /// Alias for `unwrap()` matching the local-newtype API that pre-existed in - /// `bun_bundler::output_file::IndexOptional`. - #[inline] - pub fn get(self) -> Option> { - self.unwrap() - } #[inline] pub fn unwrap(self) -> Option> { if self.0 == I::NULL_VALUE { @@ -4919,11 +4882,6 @@ impl Timespec { const NS_PER_S: i64 = crate::time::NS_PER_S as i64; const NS_PER_MS: i64 = crate::time::NS_PER_MS as i64; - #[inline] - pub const fn new(sec: i64, nsec: i64) -> Self { - Self { sec, nsec } - } - #[inline] pub fn eql(&self, other: &Timespec) -> bool { self == other diff --git a/src/cares_sys/c_ares.rs b/src/cares_sys/c_ares.rs index 7c07c672436..8b6d6a4f13e 100644 --- a/src/cares_sys/c_ares.rs +++ b/src/cares_sys/c_ares.rs @@ -671,12 +671,6 @@ pub struct AddrInfo_hints { // SAFETY: four `c_int` fields; all-zero is a valid hints value (S021). unsafe impl bun_core::ffi::Zeroable for AddrInfo_hints {} -impl AddrInfo_hints { - pub fn is_empty(&self) -> bool { - self.ai_flags == 0 && self.ai_family == 0 && self.ai_socktype == 0 && self.ai_protocol == 0 - } -} - #[derive(Copy, Clone, Default)] pub struct ChannelOptions { pub timeout: Option, diff --git a/src/css/css_parser.rs b/src/css/css_parser.rs index 3e1c9d02e63..a6377080886 100644 --- a/src/css/css_parser.rs +++ b/src/css/css_parser.rs @@ -625,12 +625,6 @@ pub trait QualifiedRuleParser { #[derive(Default, Clone, Copy, crate::DeepClone)] pub struct DefaultAtRule; -impl DefaultAtRule { - pub fn to_css(self, dest: &mut Printer) -> Result<(), PrintErr> { - dest.new_error(PrinterErrorKind::fmt_error, None) - } -} - /// Same as `AtRuleParser` but modified to provide parser options. /// Also added: `on_import_rule` to handle `@import` rules. pub trait CustomAtRuleParser { @@ -5257,11 +5251,6 @@ pub enum TokenKind { pub use crate::Token; impl Token { - pub fn eql(lhs: &Token, rhs: &Token) -> bool { - // TODO: derive PartialEq once payload lifetimes settle. - generic::implement_eql(lhs, rhs) - } - /// Return whether this token represents a parse error. pub(crate) fn is_parse_error(&self) -> bool { matches!( @@ -5506,22 +5495,16 @@ pub use bun_io::Write as WriteAll; // Num/Dimension data layouts hoisted at crate root (lib.rs). pub use crate::{Dimension, Num}; -// Num/Dimension eql/hash gated until generics::CssEql/CssHash blanket impls +// Num/Dimension hash gated until generics::CssHash blanket impls // cover the float/slice payloads. impl Num { - pub fn eql(lhs: &Num, rhs: &Num) -> bool { - generic::implement_eql(lhs, rhs) - } pub(crate) fn hash(&self, hasher: &mut bun_wyhash::Wyhash) { generic::implement_hash(self, hasher) } } impl Dimension { - pub fn eql(lhs: &Self, rhs: &Self) -> bool { - generic::implement_eql(lhs, rhs) - } pub(crate) fn hash(&self, hasher: &mut bun_wyhash::Wyhash) { generic::implement_hash(self, hasher) } diff --git a/src/css/generics.rs b/src/css/generics.rs index 956273c7312..a4a0e08f618 100644 --- a/src/css/generics.rs +++ b/src/css/generics.rs @@ -190,11 +190,6 @@ pub trait CssEql { /// derive into scope (same-name idiom, cf. `Clone`). pub use bun_css_derive::CssEql; -#[inline] -pub fn implement_eql(this: &T, other: &T) -> bool { - this.eql(other) -} - #[inline] pub(crate) fn eql(lhs: &T, rhs: &T) -> bool { lhs.eql(rhs) @@ -1205,11 +1200,6 @@ pub fn parse_with_options( T::parse_with_options(input, options) } -#[inline] -pub fn parse(input: &mut Parser) -> CssResult { - T::parse(input) -} - // ── container / primitive Parse impls ──────────────────────────────────────── impl Parse for Option { diff --git a/src/css/lib.rs b/src/css/lib.rs index 771ffc9a399..2f7baff7302 100644 --- a/src/css/lib.rs +++ b/src/css/lib.rs @@ -340,7 +340,7 @@ pub struct Dimension { } /// CSS lexer token. Data-only definition hoisted out of `css_parser.rs`; the -/// `to_css*`/`eql`/`hash` impls stay in `css_parser.rs` since they depend on +/// `to_css*`/`hash` impls stay in `css_parser.rs` since they depend on /// `serializer::*` and `generics`. // Every `&'static [u8]` payload actually borrows the parser arena/source text and // must not outlive the arena; `&'static` is the crate-wide placeholder until the diff --git a/src/css/properties/custom.rs b/src/css/properties/custom.rs index ddc8252a7c2..e346ec0cd0a 100644 --- a/src/css/properties/custom.rs +++ b/src/css/properties/custom.rs @@ -1,6 +1,6 @@ //! CSS custom properties / `var()` / `env()` / unparsed token lists. // -// `TokenList::{parse, parse_into, parse_with_options, to_css, to_css_raw}`, +// `TokenList::{parse, parse_into, to_css, to_css_raw}`, // `UnresolvedColor::{parse, to_css}`, `Variable::{parse, to_css}`, // `EnvironmentVariable::{parse, parse_nested, to_css}`, // `EnvironmentVariableName::{parse, to_css}`, `Function::to_css`, @@ -162,7 +162,7 @@ mod ext { // ─── Token protocol impls ────────────────────────────────────────────────── // `Token` / `Num` / `Dimension` are defined data-only at crate root (lib.rs); -// their `eql`/`hash` bodies in css_parser.rs forward to `generic::implement_*` +// their `hash` bodies in css_parser.rs forward to `generic::implement_*` // which bound on these traits — provide them here so the cycle closes and // `#[derive(CssEql/CssHash/DeepClone)]` on `TokenOrValue` resolves the // `Token(Token)` arm. Hand-written (not derived) because `Token` carries @@ -480,10 +480,6 @@ impl TokenList { Ok(TokenList { v: tokens }) } - pub fn parse_with_options(input: &mut Parser, options: &ParserOptions) -> Result { - Self::parse(input, options, 0) - } - pub(crate) fn parse_raw( input: &mut Parser, tokens: &mut Vec, diff --git a/src/css/rules/mod.rs b/src/css/rules/mod.rs index 78ac8c93746..f7d41330c61 100644 --- a/src/css/rules/mod.rs +++ b/src/css/rules/mod.rs @@ -58,10 +58,9 @@ macro_rules! css_rule_variants { match self { $( CssRule::$Variant(x) => x.to_css(dest), )+ CssRule::Unknown(x) => x.to_css(dest), - // The only concrete `R` is `DefaultAtRule` (whose `to_css` - // errors unconditionally), so erroring here is correct for - // every `R` that is actually instantiated. If another `R` - // is ever added, thread a `ToCss`-style bound + // The only concrete `R` is `DefaultAtRule`, so erroring here + // is correct for every `R` that is actually instantiated. If + // another `R` is ever added, thread a `ToCss`-style bound // (or per-`R` vtable) so `Custom(x)` dispatches to // `x.to_css(dest)` and only the error path maps through // `add_fmt_error()`; that bound cascades through every nested diff --git a/src/css/selectors/parser.rs b/src/css/selectors/parser.rs index 163683cd3be..1aa3ff6b2f1 100644 --- a/src/css/selectors/parser.rs +++ b/src/css/selectors/parser.rs @@ -112,10 +112,10 @@ pub(crate) const SELECTOR_WHITESPACE: &[u8] = &[b' ', b'\t', b'\n', b'\r', 0x0C] /// by `impl_::Selectors` in `bun_css::selector::impl_`. // `PartialEq + Clone` bounds dropped — the concrete assoc types // (`values::ident::{Ident,IdentOrRef}`, `*const [u8]`) implement structural -// equality via the `CssEql` protocol (`generics::implement_eql`), not -// `core::cmp::PartialEq`. Every `eql`/`deep_clone`/`hash` callsite in this -// module forwards through `css::implement_*` which bound on `CssEql`/ -// `DeepClone`/`CssHash`, so the std bounds were never load-bearing. +// equality via the `CssEql` protocol, not `core::cmp::PartialEq`. Every +// `eql`/`deep_clone`/`hash` callsite in this module forwards through +// `css::implement_*` which bound on `CssEql`/`DeepClone`/`CssHash`, so the +// std bounds were never load-bearing. pub trait SelectorImpl: Sized { type AttrValue: Clone; type Identifier: Clone; @@ -1613,13 +1613,6 @@ impl GenericSelectorList { true } - /// Do not call this! Use `serializer::serialize_selector_list()` or - /// `tocss_servo::to_css_selector_list()` instead. - #[deprecated = "use serializer::serialize_selector_list()"] - pub fn to_css(&self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_selector_list()"); - } - pub fn parse( parser: &mut SelectorParser, input: &mut CssParser, @@ -1830,13 +1823,6 @@ impl GenericSelector { parse_selector::(parser, input, &mut state, NestingRequirement::None) } - /// Do not call this! Use `serializer::serialize_selector()` or - /// `tocss_servo::to_css_selector()` instead. - #[deprecated = "use serializer::serialize_selector()"] - pub fn to_css(&self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_selector()"); - } - pub(crate) fn append(&mut self, component: GenericComponent) { let index = 'index: { for (i, comp) in self.components.iter().enumerate() { @@ -2286,13 +2272,6 @@ impl GenericComponent { matches!(self, Self::Combinator(_)) } - /// Do not call this! Use `serializer::serialize_component()` or - /// `tocss_servo::to_css_component()` instead. - #[deprecated = "use serializer::serialize_component()"] - pub fn to_css(&self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_component()"); - } - pub(crate) fn hash(&self, hasher: &mut Wyhash) { use GenericComponent as C; // Hash a variant tag, then the payload. @@ -2822,13 +2801,6 @@ pub enum Combinator { impl Combinator { // hash — via `#[derive(CssHash)]`. - /// Do not call this! Use `serializer::serialize_combinator()` or - /// `tocss_servo::to_css_combinator()` instead. - #[deprecated = "use serializer::serialize_combinator()"] - pub fn to_css(self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_combinator()"); - } - pub(crate) fn is_tree_combinator(self) -> bool { matches!( self, diff --git a/src/css/values/angle.rs b/src/css/values/angle.rs index 21f37e3fdaa..935ead24135 100644 --- a/src/css/values/angle.rs +++ b/src/css/values/angle.rs @@ -178,10 +178,6 @@ impl Angle { Some(Angle::Deg(self.to_degrees() + rhs.to_degrees())) } - pub(crate) fn eql(self, rhs: Angle) -> bool { - self.to_degrees() == rhs.to_degrees() - } - pub(crate) fn mul_f32(self, other: f32) -> Angle { // return Angle.op(&this, &other, Angle.mulF32); match self { diff --git a/src/css/values/calc.rs b/src/css/values/calc.rs index a429d0d7381..9ad34f6ea4f 100644 --- a/src/css/values/calc.rs +++ b/src/css/values/calc.rs @@ -141,7 +141,6 @@ pub trait CalcValue: fn into_calc(self) -> Calc; /// Convert a `Calc` into `Self` if representable. fn from_calc(c: Calc, input: &mut css::Parser) -> CssResult; - fn eql(&self, other: &Self) -> bool; } impl Clone for Calc { @@ -152,8 +151,7 @@ impl Clone for Calc { // Structural equality decoupled from `CalcValue` so `derive(PartialEq)` on // `Length` / `DimensionPercentage` consumers can compare through -// `Box>` without pulling in the full behavior bound. `Calc::eql` -// (below) keeps its `V: CalcValue` bound for callers that already have it. +// `Box>` without pulling in the full behavior bound. impl PartialEq for Calc { fn eq(&self, other: &Self) -> bool { match (self, other) { @@ -217,38 +215,6 @@ impl Calc { // Cleanup is handled by Drop on Box/Box>/ // Box>. No explicit Drop impl needed. - - pub fn eql(&self, other: &Self) -> bool - where - V: CalcValue, - { - match (self, other) { - (Calc::Value(a), Calc::Value(b)) => a.eql(b), - (Calc::Number(a), Calc::Number(b)) => *a == *b, - ( - Calc::Sum { - left: al, - right: ar, - }, - Calc::Sum { - left: bl, - right: br, - }, - ) => al.eql(bl) && ar.eql(br), - ( - Calc::Product { - number: an, - expression: ae, - }, - Calc::Product { - number: bn, - expression: be, - }, - ) => an == bn && ae.eql(be), - (Calc::Function(a), Calc::Function(b)) => a.eql(b), - _ => false, - } - } } // `PartialEq for Calc` is provided above with the looser `V: PartialEq + @@ -1204,8 +1170,8 @@ pub enum MathFunction { impl PartialEq for MathFunction { fn eq(&self, other: &Self) -> bool { - // Mirrors `MathFunction::eql` but bounds only on `V: PartialEq` so - // `Calc: PartialEq` (above) closes without `CalcValue`. + // Bounds only on `V: PartialEq` so `Calc: PartialEq` (above) + // closes without `CalcValue`. match (self, other) { (MathFunction::Calc(a), MathFunction::Calc(b)) => a == b, (MathFunction::Min(a), MathFunction::Min(b)) => a == b, @@ -1262,78 +1228,7 @@ impl PartialEq for MathFunction { } } -fn eql_calc_list(a: &[Calc], b: &[Calc]) -> bool { - if a.len() != b.len() { - return false; - } - for (l, r) in a.iter().zip(b.iter()) { - if !l.eql(r) { - return false; - } - } - true -} - impl MathFunction { - pub fn eql(&self, other: &Self) -> bool - where - V: CalcValue, - { - match (self, other) { - (MathFunction::Calc(a), MathFunction::Calc(b)) => a.eql(b), - (MathFunction::Min(a), MathFunction::Min(b)) => eql_calc_list(a, b), - (MathFunction::Max(a), MathFunction::Max(b)) => eql_calc_list(a, b), - ( - MathFunction::Clamp { - min: a0, - center: a1, - max: a2, - }, - MathFunction::Clamp { - min: b0, - center: b1, - max: b2, - }, - ) => a0.eql(b0) && a1.eql(b1) && a2.eql(b2), - ( - MathFunction::Round { - strategy: as_, - value: av, - interval: ai, - }, - MathFunction::Round { - strategy: bs, - value: bv, - interval: bi, - }, - ) => as_ == bs && av.eql(bv) && ai.eql(bi), - ( - MathFunction::Rem { - dividend: ad, - divisor: av, - }, - MathFunction::Rem { - dividend: bd, - divisor: bv, - }, - ) => ad.eql(bd) && av.eql(bv), - ( - MathFunction::Mod { - dividend: ad, - divisor: av, - }, - MathFunction::Mod { - dividend: bd, - divisor: bv, - }, - ) => ad.eql(bd) && av.eql(bv), - (MathFunction::Abs(a), MathFunction::Abs(b)) => a.eql(b), - (MathFunction::Sign(a), MathFunction::Sign(b)) => a.eql(b), - (MathFunction::Hypot(a), MathFunction::Hypot(b)) => eql_calc_list(a, b), - _ => false, - } - } - pub(crate) fn deep_clone(&self) -> Self where V: Clone, @@ -1615,10 +1510,6 @@ impl CalcValue for CSSNumber { _ => Err(input.new_custom_error(css::ParserError::invalid_value)), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - *self == *other - } } impl CalcValue for Angle { @@ -1636,10 +1527,6 @@ impl CalcValue for Angle { _ => Err(input.new_custom_error(css::ParserError::invalid_value)), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - Angle::eql(*self, *other) - } } // ───────────────────────────────────────────────────────────────────────────── @@ -1777,10 +1664,6 @@ impl CalcValue for Percentage { _ => Ok(Percentage { v: f32::NAN }), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - Percentage::eql(*self, *other) - } } calc_protocol_forwarders!(Time { @@ -1823,10 +1706,6 @@ impl CalcValue for Time { _ => Err(input.new_custom_error(css::ParserError::invalid_value)), } } - #[inline] - fn eql(&self, other: &Self) -> bool { - Time::eql(*self, *other) - } } calc_protocol_forwarders!(Length { @@ -1864,10 +1743,6 @@ impl CalcValue for Length { fn from_calc(c: Calc, _input: &mut css::Parser) -> CssResult { Ok(Length::Calc(Box::new(c))) } - #[inline] - fn eql(&self, other: &Self) -> bool { - self == other - } } /// `protocol::*` + `CalcValue` impls for the two concrete `DimensionPercentage` @@ -1916,7 +1791,6 @@ macro_rules! dim_pct_protocol { fn from_calc(c: Calc, _input: &mut css::Parser) -> CssResult { Ok(DimensionPercentage::Calc(Box::new(c))) } - #[inline] fn eql(&self, other: &Self) -> bool { self == other } } }; } diff --git a/src/css/values/css_string.rs b/src/css/values/css_string.rs index 960cd50e69c..4c85544d4ba 100644 --- a/src/css/values/css_string.rs +++ b/src/css/values/css_string.rs @@ -1,5 +1,4 @@ pub use crate::css_parser as css; -pub use css::CssResult as Result; pub use css::PrintErr; pub use css::Printer; @@ -15,11 +14,6 @@ pub type CssString = *const [u8]; pub struct CssStringFns; impl CssStringFns { - pub fn parse(input: &mut css::Parser) -> Result { - // No lifetime laundering: capture the arena slice as a raw pointer. - input.expect_string().map(std::ptr::from_ref::<[u8]>) - } - pub fn to_css(this: &CssString, dest: &mut Printer) -> core::result::Result<(), PrintErr> { // SAFETY: per the `CssString` invariant above, the pointee borrows the // parser arena which outlives the `Printer` it is being written to. diff --git a/src/css/values/time.rs b/src/css/values/time.rs index ce14b1f814f..bba24ac9873 100644 --- a/src/css/values/time.rs +++ b/src/css/values/time.rs @@ -28,13 +28,6 @@ pub enum Time { impl Time { // css.implementDeepClone / css.implementEql / css.implementHash — provided // by `#[derive(DeepClone, CssEql, CssHash)]` above (POD f32 payload). - // Kept as an inherent assoc fn for `protocol::CalcValue` callers that - // forward via UFCS (`Time::eql(a, b)`) — does not conflict with the - // derived trait method (that one has a `&self` receiver). - #[inline] - pub fn eql(lhs: Self, rhs: Self) -> bool { - lhs == rhs - } pub fn parse(input: &mut css::Parser) -> Result