Skip to content

Remove dead code: 92 trait impls nothing calls, across 29 crates - #39795

Merged
Jarred-Sumner merged 4 commits into
mainfrom
farm/472073f1/dead-code-trait-impls-misc
Aug 21, 2026
Merged

Jarred-Sumner merged 4 commits into
mainfrom
farm/472073f1/dead-code-trait-impls-misc

Conversation

@robobun

@robobun robobun commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • 92 hand-written trait impls (Default, From, Clone, PartialEq) across 29 crates have no caller. rustc's dead_code lint exempts trait impls, so the workspace lints never report them.
  • A few items existed only for those impls: two tables in src/resolver/options.rs, Flags::DEFAULTS in src/md/types.rs, and five error variants that only a removed From impl constructed.

Fix

  • Delete the impls and the items that became unused. 80 files, 1064 lines removed. The one added line is a doc comment with its last sentence cut.
  • The candidates come from the linker: a relink of the debug build with --gc-sections --print-gc-sections lists the trait methods dropped from every codegen unit. Impls that a bound or a supertrait still needs (Deref under DerefMut, PartialEq under Ord, From<RGBA> for SRGB) do not compile without the impl, so they stay.
  • Verified: bun run rust:check-all (11 targets), bun run rust:clippy, cargo build --tests for the 21 touched crates with unit tests, cargo miri test for the touched miri crates, bun bd, and 2112 tests across css, md, shell, env, resolve, node:fs, console.table, archive, http2, build errors, install, and compile sourcemaps.

Background

  • To rustc a trait impl is always reachable: generic code could call it through the trait. Only a whole-program view shows which impls nothing calls.
  • The debug build uses -ffunction-sections at opt-level 0, so a function that nothing references is its own section and is not inlined away. --gc-sections drops exactly those sections. A method that survives in any codegen unit (an #[inline] copy, for example) counts as live.
  • The removed impls are listed below.
Removed impls by crate
  • src/runtime (19): Default for Chmod; Default for ExecCfg; Default for FChmod; Default for FetchOptions; Default for FrameHeader; Default for Framework; Default for FromJSOptions; Default for GzipOptions; Default for ID; Default for InitOptions<'a>; Default for IntoArray; Default for JSS3Error; Default for MkdirTemp; Default for Open; Default for ReactFastRefresh; Default for RmDir; Default for Stat; From<CreatePtyError> for crate::Error; From<InitError> for crate::Error
  • src/react_compiler (10): Clone for GlobalRegistry; Clone for ShapeRegistry; Default for Environment; Default for ExhaustiveEffectDepsMode; Default for ScopeBlockTraversal; From<&str> for JsString; From<String> for JsString; From<f64> for FloatValue; PartialEq<&str> for JsString; PartialEq<str> for JsString
  • src/ast (8): Default for ClassStaticBlock; Default for CommonJSNamedExport; Default for Dependency; Default for MetadataResolve; Default for NamedImport; Default for Query; From<SetError> for crate::Error; PartialEq for Data
  • src/jsc (6): Default for BuildMessage; Default for CPUProfilerConfig; Default for Column; Default for ResolveMessage; Default for RuntimeTranspilerCache; Default for Store
  • src/resolver (6): Clone for DependencyMap; Default for BundleOptions; Default for EntryCache; Default for ExtensionOrder; Default for ExtensionOrderGroup; Default for Package<'_>
  • src/bun_core (4): Clone for SmolStr; Default for CtorOptions; Default for DeserOpts; From<crate::Error> for JsError
  • src/install (4): Default for Entry; Default for MoreInstructions<'_>; Default for Scratch; PartialEq<crate::Error> for ForManifestError
  • src/css (3): PartialEq for CustomPropertyName; PartialEq for KeyframesName; PartialEq for LayerName
  • src/md (3): Default for BlockHeader; Default for Flags; Default for Theme<'a>
  • src/parsers (3): Default for JSONOptions; From<AddToLogError> for crate::Error; From<bun_alloc::AllocError> for PErr
  • src/uws_sys (3): Default for ListenConfig; Default for VTable; Default for us_socket_stream_buffer_t
  • src/bun_alloc (2): Default for MaxHeapAllocator; Default for Mutex
  • src/bundler (2): Clone for OutputFile; Default for BunLogOptions
  • src/install_types (2): Default for TarballInfo; From<CreateMatcherError> for FromExprError
  • src/js_parser (2): Default for ReactFastRefresh; Default for ThenCatchChain
  • src/sourcemap (2): Default for Chunk; Default for Mapping
  • src/base64 (1): Default for VLQ
  • src/collections (1): Default for StringMap
  • src/dns (1): Default for Backend
  • src/dotenv (1): Default for Map
  • src/io (1): Default for FilePoll
  • src/paths (1): From<Error> for crate::Error
  • src/picohttp (1): Default for Response<'a>
  • src/ptr (1): Default for WeakPtrData
  • src/resolve_builtins (1): Default for Alias
  • src/s3_signing (1): Default for SignQueryOptions
  • src/sql_jsc (1): From<FlushQueueError> for crate::Error
  • src/sys (1): Default for Address
  • src/threading (1): Default for ThreadPool

Follow-up removals that became unused with them:

  • src/resolver/options.rs: the EXTENSION_ORDER / MODULE_EXTENSION_ORDER copies and the TargetMainFields / DEFAULT_MAIN_FIELDS_* tables (only Default for BundleOptions read them; the bundler projects these options itself).
  • src/md/types.rs: Flags::DEFAULTS (only Default for Flags read it; root.rs builds Flags field by field).
  • src/parsers/xml.rs: the PErr::Oom variant and its match arm (only the removed From<AllocError> produced it).
  • src/css/rules/keyframes.rs, src/css/rules/layer.rs: the Hash and Eq impls that went with the removed PartialEq impls, and the two comments that described them. The ShapeRegistry and GlobalRegistry docs in src/react_compiler/hir/ lose the sentence about cloning for the same reason. Neither type is used as a map key; LayerName comparisons go through the inherent eql.
  • src/ast/stmt.rs: impl Eq for Data.
  • Error variants whose only constructor was a removed From impl, with their name() arms: bun_runtime::Error::TerminalInit, bun_ast::Error::Clobber, bun_paths::Error::MaxPathExceeded, bun_sql_jsc::Error::AuthenticationFailed. The inner error types (InitError, SetError, path_options::Error, FlushQueueError) are still live on their own.
Notes

…ed them

92 hand-written Default, From, Clone and PartialEq impls across 29 crates
have no caller. rustc does not report unused trait impls, so they survived
the workspace dead_code lints. The list comes from relinking the debug
build with --gc-sections and keeping the trait methods whose symbol was
dropped from every codegen unit. Impls that a bound or a supertrait still
needs were kept.

Also removes what became unused with them: the extension order and main
field tables in resolver/options.rs, md Flags::DEFAULTS, the xml PErr::Oom
variant, the Hash and Eq impls of KeyframesName and LayerName, Eq for
ast stmt::Data, and bun_core strings::rsplit_once.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5ae0c2a4-c9bc-428d-9eb5-897fafb308a4

📥 Commits

Reviewing files that changed from the base of the PR and between fa7bb3b and d3d715a.

📒 Files selected for processing (5)
  • src/ast/error.rs
  • src/css/rules/keyframes.rs
  • src/paths/error.rs
  • src/runtime/error.rs
  • src/sql_jsc/error.rs
💤 Files with no reviewable changes (5)
  • src/sql_jsc/error.rs
  • src/runtime/error.rs
  • src/css/rules/keyframes.rs
  • src/paths/error.rs
  • src/ast/error.rs

Included review availability: Your plan provides up to 5 included reviews per hour; 1 remains after this review.


Walkthrough

The pull request removes selected Default, Clone, PartialEq, Eq, Hash, From, and error-variant implementations across AST, resolver, runtime, compiler, parser, and system modules. Existing explicit constructors, constants, and error mappings remain where stated.

Changes

Trait and conversion API removal

Layer / File(s) Summary
Frontend and data-type default removal
src/ast/*, src/base64/lib.rs, src/bun_core/*, src/bundler/*, src/collections/*, src/js_parser/*, src/md/*, src/react_compiler/*, src/resolve_builtins/*
Selected frontend, parser, markdown, compiler, and data types no longer implement Default. Existing constructors and constants remain where specified.
Resolver and runtime default removal
src/resolver/*, src/runtime/*, src/install/*, src/sourcemap/*, src/sys/*, src/threading/*, src/uws_sys/*, src/dns/*, src/dotenv/*, src/io/*
Selected resolver, runtime, installation, source-map, system, threading, allocator, and socket types no longer provide default construction. Resolver extension-order defaults and target-specific main-field constants are also removed.
Comparison, clone, and conversion removal
src/ast/stmt.rs, src/bun_core/string/*, src/css/*, src/install/NetworkTask.rs, src/react_compiler/*, src/resolver/package_json.rs, src/react_compiler/diagnostics/*
Manual equality, hashing, cloning, string conversion, numeric conversion, and related comparison implementations are removed.
Error conversion and variant removal
src/ast/e.rs, src/ast/error.rs, src/bun_core/lib.rs, src/parsers/*, src/paths/*, src/runtime/api/bun/Terminal.rs, src/runtime/error.rs, src/sql_jsc/*
Selected error conversions and allocation mappings are removed. Clobber, MaxPathExceeded, TerminalInit, and AuthenticationFailed variants are removed with their name() branches.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description clearly explains the problem, fix, scope, methodology, and verification results, although it does not use the template headings.
Title check ✅ Passed The title clearly summarizes the removal of unused trait implementations across the affected crates.

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. Nothing in this diff overlaps with the open dead-code PRs (#37181, #37659, #39581, #39582, #39618, #39697, #39732). I compared the removed lines of each one against this diff.

How the list was derived, for anyone who wants to check an entry:

  1. Relink the debug build with -Wl,--gc-sections -Wl,--print-gc-sections. The output names every function section the linker dropped.
  2. Keep the <Type as Trait>::method entries whose symbol is absent from the linked binary (nm on the result), so #[inline] copies that survive elsewhere count as live.
  3. Delete the impl and let the compiler decide the rest: bun run rust:check-all, bun run rust:clippy, cargo build --tests for the touched crates, cargo miri test for the touched miri crates, then bun bd and the test files listed in the description.

Step 3 put back Semaphore: Default (macOS only caller), clap::Help: Default and braces::Token: PartialEq (unit tests only), plus the impls that a bound or a supertrait still requires. Those are not in the diff.

@robobun

robobun commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

The second commit on this branch is autofix-ci. It removes one trailing blank line that the deletion left at the end of src/resolver/options.rs. Nothing else changed: the diff is still the 92 impls and their helpers listed in the description, now 1059 lines removed and none added. The automated review above reported nothing to act on.

Comment thread src/bun_core/string/immutable.rs Resolved
Comment thread src/runtime/api/bun/Terminal.rs Resolved
Comment thread src/css/rules/keyframes.rs Resolved
@robobun

robobun commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 2:09 PM PT - Aug 20th, 2026

✅ @robobun, your commit dba630a437dfc3725e78265be2699c1812953afd passed in Build #101793! 🎉


🧪   To try this PR locally:

bunx bun-pr 39795

That installs a local version of the PR into your bun-39795 executable, so you can run:

bun-39795 --bun

…error variants

rsplit_once is the replacement that clippy.toml names for str::rsplit_once,
str::rsplitn and bstr::ByteSlice::rsplit_once_str, so it stays even though
nothing calls it today.

The removed From impls were the only constructors of bun_runtime
Error::TerminalInit, bun_ast Error::Clobber, bun_paths Error::MaxPathExceeded
and bun_sql_jsc Error::AuthenticationFailed. Remove those variants and their
name() arms, the same way PErr::Oom was removed.

Also drop the keyframes.rs comment that described the removed Hash and
PartialEq impls.
Comment thread src/react_compiler/hir/object_shape.rs Resolved
@robobun

robobun commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Two review rounds are folded in, both from the line comments above, all four threads resolved:

  • d3d715a: strings::rsplit_once is back (clippy.toml names it as the replacement for three disallowed methods). The four error variants that only a removed From impl constructed are gone with their name() arms: TerminalInit, Clobber, MaxPathExceeded, AuthenticationFailed. The stale keyframes.rs comment is deleted.
  • dba630a: the ShapeRegistry and GlobalRegistry docs lose the sentence about cloning.

The description is updated to match. The diff is now 80 files, 1064 lines removed and one doc line shortened. cargo check --workspace, cargo fmt --check and bun bd pass on the new head. The other automated comments since my last note are summaries with nothing to act on.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR across three rounds and the bug-hunting system found nothing on the current head. All four items I raised earlier (rsplit_once policy reference, four orphaned error variants, two stale-comment sites) are resolved in d3d715a and dba630a. Given the breadth — 80 files across 29 crates, including resolver defaults tables (DEFAULT_MAIN_FIELDS_*, EXTENSION_ORDER copies) and error-enum variant surgery — a maintainer glance to confirm nothing on the removal list is wanted for near-term work would still be worthwhile.

What was reviewed:

  • Linker-driven methodology cross-checked against rust:check-all (11 targets), cargo build --tests, and miri; three impls that came back during verification are correctly excluded.
  • Follow-up removals (error variants, Flags::DEFAULTS, resolver tables, PErr::Oom) each traced to their sole removed constructor.
  • Policy-file references (clippy.toml, hawk.toml) checked — rsplit_once was the only hit and is now kept.
  • Stale prose describing removed impls swept in keyframes.rs, layer.rs, object_shape.rs, globals.rs.
Extended reasoning...

Overview

This PR removes 92 hand-written trait impls (Default, From, Clone, PartialEq, Eq, Hash) across 29 crates that the linker's --gc-sections --print-gc-sections pass shows nothing calls, plus the items that became dead with them: two extension-order/main-fields tables in src/resolver/options.rs, Flags::DEFAULTS in src/md/types.rs, the PErr::Oom variant, four crate-level error variants (TerminalInit, Clobber, MaxPathExceeded, AuthenticationFailed) with their name() arms, and several stale doc comments. Net: 80 files, 1064 lines removed, one doc line shortened.

Security risks

None. Pure deletions of unreferenced trait impls and the constants/variants only they consumed. No parsing, validation, auth, crypto, or FFI-boundary changes. If any removed impl were reachable, rust:check-all across 11 targets would fail to compile.

Level of scrutiny

Medium-high, driven by breadth rather than per-change complexity. Each deletion is individually trivial and compiler-verified — Rust will not link if a needed impl is missing, and the author ran the full cross-target/test/miri matrix plus 2112 runtime tests. But the sweep touches resolver, bundler, runtime, jsc, install, css, and sql across 29 crates, and includes non-impl follow-ups (resolver defaults tables with domain commentary about main-fields resolution, error-enum variant removal). The rsplit_once case I flagged earlier — dead to the linker but load-bearing as a clippy.toml policy target — shows the class of "intentionally kept for future callers" that only a maintainer can confirm is fully covered. The author was careful (excluded h2/ in-progress rewrite, MySQL collation table, Sys/Alloc convention variants), but a maintainer skim of the removal list is the right final check.

Other factors

  • All four items from my two prior review rounds are addressed and threads resolved; the author also proactively swept every file in the diff for remaining stale prose after the last round.
  • Seven other dead-code PRs are open; the author diffed removed lines against each and confirms no overlap.
  • The methodology description is detailed enough for a maintainer to spot-check any single entry (nm on the linked binary, then delete-and-recompile).
  • CI build #101793 is in progress on the current head; no human reviews yet.

@robobun

robobun commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

For the maintainer glance the review above asks for: the full removal list is the "Removed impls by crate" block in the description, one line per crate, and the non-impl removals are the short list under it. If any entry is wanted for work in flight, name it and I will put it back; each one is an independent block, so keeping one does not affect the rest. The h2/ rewrite, compile_result.rs, and the MySQL collation table were skipped for that reason already.

State on dba630a: every GitHub check is green (clippy, miri, mordant, format, source lints), no review threads open, and Buildkite #101793 has 175 of 179 jobs passed with the last 4 still running.

@Jarred-Sumner
Jarred-Sumner merged commit f1700dd into main Aug 21, 2026
10 of 11 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the farm/472073f1/dead-code-trait-impls-misc branch August 21, 2026 00:35
robobun added a commit that referenced this pull request Aug 21, 2026
#39795 removed four Default impls this branch had converted (Query,
ClassStaticBlock, NamedImport and the MetadataResolve one), so they are gone.
#39770 split add_error, add_range_error_with_notes and range_data into an
inline generic wrapper and one shared body; here the wrapper also does the
Option<Loc> / Option<Range> conversion and the body takes the Option. Four
diagnostics main added without a location (no bundlable entry point, external
entry point, and the two builtin / browser-field entry point errors) pass None.

main itself does not build at this point (PackageInstaller.rs:1359, #39816
against #39770); that is tracked separately and not touched here.
Jarred-Sumner pushed a commit that referenced this pull request Sep 21, 2026
### Problem
- 49 hand-written trait impls across 12 crates have no user: no call,
and no bound that needs them.
- rustc's `dead_code` lint exempts trait impls, so the workspace's deny
lints never report them.

### Fix
- Delete the 49 impls and `hash_array_list` (`src/css/generics.rs`),
whose only caller was a removed impl. 25 files, 436 lines removed.
- Candidates come from the linker: in a relink of the debug build with
`--gc-sections`, an impl block with no kept function address is a
candidate. The compiler decides next: an impl that a bound, a
supertrait, another target, or a unit test needs does not compile away,
so it stays. That kept 128 of 233 candidates.
- 56 more stayed by choice: open PRs use them, docs describe them, or
they are std ergonomics impls on shared containers. See the Notes.
- Verified: `bun run rust:check-all` (12 targets), `cargo check
--release` (3 targets), `cargo check --tests`, `cargo clippy`, `bun bd`,
11 test files, and a scan of all open PRs for users.

### Background
- To rustc a trait impl is always reachable: generic code could call it.
Only a whole-program view shows that nothing does.
- The debug build uses opt-level 0 and one section per function, so
`--gc-sections` drops every function with no caller. Callers in generic
instantiations and macro-expanded code count.
- That link proves linux only. `cargo check` covers the other targets.
- #39795 removed 92 impls this way.

<details><summary>Notes</summary>

**Removed impls, by file**

- `src/ast/e.rs`
  - `impl From<f64> for Number`
- `src/bun_alloc/baby_vec.rs`
  - `impl<'a, 'b, T: Copy> Extend<&'b T> for BabyVec<'a, T>`
  - `impl<'a, 'b, T> IntoIterator for &'b BabyVec<'a, T>`
  - `impl<'a, 'b, T> IntoIterator for &'b mut BabyVec<'a, T>`
  - `impl<'a, T> core::borrow::Borrow<[T]> for BabyVec<'a, T>`
  - `impl<'a, T> AsRef<[T]> for BabyVec<'a, T>`
- `src/bun_alloc/lib.rs`
  - `impl<const N: usize> BSSAppendable for [&[u8]; N]`
- `src/bun_core/atomic_cell.rs`
  - `unsafe impl<U> Atom for *const U`
- `src/bun_core/fmt.rs`
  - `impl From<InvalidCharacter> for crate::CrateError`
- `src/bun_core/output.rs`
  - `impl<T: fmt::Display> FmtTuple for &[T]`
- `src/bundler/Chunk.rs`
  - `impl core::ops::Index<usize> for CompileResultSlots`
- `src/bundler/bundle_v2.rs`
  - `impl Ord for StableRef`
  - `impl PartialOrd for StableRef`
- `src/collections/array_hash_map.rs`
- `impl<K, V, C, A: MapAllocator> ArrayHashMapExt for ArrayHashMap<K, V,
C, A>`
- `src/css/generics.rs`
  - `impl<'bump, T: DeepClone<'bump>> DeepClone<'bump> for &'bump T`
  - `impl<T: CssEql, const N: usize> CssEql for [T; N]`
  - `impl CssHash for ()`
  - `impl<T: CssHash, const N: usize> CssHash for [T; N]`
  - `impl<'bump, T: CssHash> CssHash for ArrayList<'bump, T>`
  - `impl CssHash for bun_ast::Loc`
  - `impl<T: IsCompatible, const N: usize> IsCompatible for [T; N]`
  - `impl<'bump, T: ToCss> ToCss for ArrayList<'bump, T>`
  - `impl ToCss for CustomIdent`
  - `impl ToCss for DashedIdent`
  - `impl ToCss for Ident`
- `src/css/media_query.rs`
  - `impl crate::generic::ToCss for MediaList`
- `src/css/properties/mod.rs`
- `impl crate::generics::ParseWithOptions for
css_values::length::Length`
- `impl<S, const P: u8> crate::generics::Parse for GenericBorder<S, P>`
- `src/css/rules/supports.rs`
  - `impl crate::generics::CssEql for SupportsCondition`
  - `impl css::generic::ToCss for SupportsCondition`
- `src/css/selectors/parser.rs`
  - `impl<Impl: SelectorImpl> Default for GenericSelector<Impl>`
  - `impl<Impl: BunSelectorImpl> CssEql for GenericSelectorList<Impl>`
  - `impl<Impl: BunSelectorImpl> CssHash for GenericSelectorList<Impl>`
  - `impl<Impl: BunSelectorImpl> CssEql for GenericComponent<Impl>`
  - `impl<Impl: BunSelectorImpl> CssHash for GenericComponent<Impl>`
- `src/css/values/alpha.rs`
  - `impl crate::generics::CssHash for AlphaValue`
- `src/install/lockfile/lockfile_json_stringify_for_debugging.rs`
  - `impl<const N: usize> JsonScalar for &[u8; N]`
- `src/install/resolution.rs`
  - `impl Default for Tag`
- `src/install_types/resolver_hooks.rs`
  - `impl<I: VersionInt> Default for ResolutionValue<I>`
  - `impl Default for Resolution`
- `src/jsc/JSPropertyIterator.rs`
  - `impl IntoIterObject for *const JSObject`
- `src/jsc/JSValue.rs`
  - `impl FromAny for ()`
  - `impl FromAny for &str`
  - `impl<T: FromAny> FromAny for Option<T>`
- `src/jsc/host_fn.rs`
  - `impl<T> IntoHostConstructReturn for *mut T`
- `src/react_compiler/hir/mod.rs`
  - `impl From<FloatValue> for f64`
- `src/runtime/bake/DevServer.rs`
  - `impl From<OpaqueFileId> for OpaqueFileIdOrOptional`
- `src/runtime/error.rs`
  - `impl From<Error> for bun_jsc::CrateError`
- `src/tcc_sys/tcc.rs`
  - `impl<ErrCtx> Default for Config<ErrCtx>`

**Candidates that stayed (184 of 233)**
- 128: the workspace does not compile without the impl (a bound, a
supertrait, another target, or a unit test needs it).
- 8: open PRs use them. The six `SmallList` impls (`Deref`, `DerefMut`,
`IntoIterator` x2, `FromIterator`, `Extend`) for #39497, #38692 and
#36605. `Default for Wyhash` for #40372. `AsRef<[u8]> for Utf8Bytes` for
#40708. This branch merged with #39497, #38692 and #40708 passes `cargo
check --workspace`. #36605 and #40372 conflict with main on their own.
- 19: std ergonomics impls on widely shared types. This is a design
call, so it needs a maintainer decision and its own PR: `Interned`
(`Deref`, `AsRef<[u8]>`, `Borrow<[u8]>`), `ZStr` (`AsRef<ZStr>`,
`PartialEq<[u8]>`, `PartialEq<&[u8; N]>`), `StoreStr`
(`PartialEq<[u8]>`), `StoreSlice` (`AsRef<[T]>`, `From<&[T]>`,
`From<ArenaVec>`), `IntoIterator for &HashMap` and `&mut HashMap`,
`BoundedArrayAligned` (`Deref`, `DerefMut`, `fmt::Write`), `AsRef<[T]>
for RawSlice`, `Deref for ArenaString` (also the only caller of
`ArenaString::as_str`), `Display for GenericIndex`, `Display for
CowSliceZ`.
- 21: docs or comments describe the impl as part of a design.
`ArrayHashContext<Box<[u8], A>> for BoxedSliceContext<C>` (its doc
comment records it as the fix for lookups reached through `Deref`),
`Default for Ordinal` (the default is `INVALID`, not 0), `IntoLogWrite
for &mut W`, `ThrowFmtArgs for fmt::Arguments`, `PoolStorage for
UnwiredStorage`, `StringBuilder for semver_string::Builder`, `fmt::Write
for FmtAdapter`, `AsFd for &File`, and the css blanket impls that the
`css_derive` module docs and the `Parse` section of
`src/css/generics.rs` name (`Option<T>`, `SmallList`, `bool`, `str`,
`[u8]`, `[T]`, `Size2D`, `Rect`).
- 6: next to a hunk of an open dead-code PR (#40690, #41335, #43010,
#42278), left alone to avoid a conflict.
- 2: the removal leaves something else half-used. See the follow-up
list.

**Method details**
- Link: the debug link command from `build.ninja` plus
`-Wl,--gc-sections`. `-rdynamic`, `--dynamic-list` and the version
script stay, so the exported NAPI/V8/uv surface is still a root.
- Liveness: `llvm-nm` lists the 669,524 kept function symbols and
`llvm-symbolizer` maps each address to `file:line`. An impl block is a
candidate when no kept address falls inside it and a rust-analyzer SCIP
index shows that linux compiles every method in it.
- Limit of the finder: it reads impl blocks from source text. Impls that
a `macro_rules!` type list generates are not candidates, so unused arms
of such lists are not in this PR.
- Restore loop: delete all candidates, run `cargo check --workspace
--keep-going --message-format=json`, put back each impl that an error
names, repeat until clean. Targets in the loop: linux-gnu, windows-msvc,
darwin, freebsd, android, musl, then `--tests`.
- Method resolution: on linux the link proves that no call to a removed
impl remains, so no call can resolve differently. On other targets a
call that used a removed impl fails to compile.
- Open PRs: main has no merge queue, so a green PR that uses a removed
impl would break main when it merges. I fetched the heads of all 5474
open non-draft PRs, took the Rust lines each one adds against its merge
base, and searched them for the types and traits of the 49 impls. No PR
uses one.
- Base: main at 18fe86e. The liveness data is from cf71211. The
commits between them do not touch the 25 files, and every check above
ran again on 18fe86e.
- `cargo check --workspace --tests` reports one error,
`src/bundler/options.rs:2328` (`expected ContentHash, found integer`).
Clean main has the same error. This PR does not touch it.
- Three tests fail in the local debug build with and without this
change: `ffi.test.js` "FTL-compiled call site" (5 s timeout under ASAN),
and two `serve.test.ts` tests that depend on the container (root can
bind low ports, loopback check).

**Other scans in this run**
- Free functions, inherent methods, types, consts and statics: a name
scan, the linker scan, and a rust-analyzer zero-reference scan for
linux, windows and darwin. Every hit was platform code with a caller on
another target, test-only code, or a deletion that an open PR already
carries.
- Also clean or already claimed: `.rs` files outside every mod tree,
unused Cargo dependencies, extern declarations without a Rust caller,
commented-out code in C++/TS, unused `src/js` modules and internal
exports, linker-dropped C++ functions in `src/jsc/bindings`.

**Follow-up candidates, not in this diff**
- 25 hand-written `Debug` impls that nothing formats. They are a
debugging aid, so this PR keeps them.
- `Clone for JsPoster` has no caller, and it is the only reader of the
`JsPosterVTable::clone` slot. Removing both is a small refactor in
`src/event_loop` and `src/jsc/VmHandle.rs`.
- `Display for ErrorLocation` (`src/css/error.rs`) has no caller, and it
is the only reader of `ErrorLocation::filename`.
- The 19 std ergonomics impls above, if a maintainer wants shared
containers to go through inherent methods only.
- `Bun__napi_get_version` in `src/jsc/bindings/napi.cpp` has no caller.
- The class generator emits `<Type>Class__call` shims for classes that
set `call: true` and `noConstructor: true` (the seven `Expect*` matchers
in `jest.classes.ts`). Nothing references those shims.

</details>
robobun added a commit that referenced this pull request Oct 15, 2026
Conflicts:
- src/css/properties/custom.rs: main removed `impl PartialEq for
  CustomPropertyName` (#39795). `PropertyId::eq` now compares the two
  names with the derived `CssEql`.
- src/css/rules/style.rs: keep the `pub(crate)` visibility from main.
- src/css/rules/supports.rs: keep the private `Declaration::eql` from
  main.
robobun added a commit that referenced this pull request Oct 15, 2026
…portance

lightningcss fixed the same defect in 93b9e66 ("Fix duplicate rule
detection with different importance") with the same rule: two rules are
duplicates only when the selectors, the properties and the importance
are the same. Add its two tests and one case with two declarations.

Also correct three comments:
- A derived `PartialEq` for `PropertyId` does not compile, because
  `CustomPropertyName` has no `PartialEq` since #39795. The old text
  said it compares raw pointers.
- `PropertyId` implements `CssEql` (generics.rs), so the reason that
  `SupportsCondition::eql` gave for its hand-written match was wrong.
- In the reversed-order test, the earlier normal rule is dead in the
  cascade. It stays because the two rules differ in importance.
robobun added a commit that referenced this pull request Oct 16, 2026
main removed PartialEq for CustomPropertyName (#39795).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants