Repository navigation
Remove dead code: 92 trait impls nothing calls, across 29 crates - #39795
Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (5)
Included review availability: Your plan provides up to 5 included reviews per hour; 1 remains after this review. WalkthroughThe pull request removes selected ChangesTrait and conversion API removal
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
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:
Step 3 put back |
|
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. |
|
Updated 2:09 PM PT - Aug 20th, 2026
✅ @robobun, your commit dba630a437dfc3725e78265be2699c1812953afd passed in 🧪 To try this PR locally: bunx bun-pr 39795That installs a local version of the PR into your 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.
…eRegistry and GlobalRegistry
|
Two review rounds are folded in, both from the line comments above, all four threads resolved:
The description is updated to match. The diff is now 80 files, 1064 lines removed and one doc line shortened. |
There was a problem hiding this comment.
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_oncewas 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 (
nmon the linked binary, then delete-and-recompile). - CI build #101793 is in progress on the current head; no human reviews yet.
|
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 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. |
#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.
### 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>
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.
…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.
main removed PartialEq for CustomPropertyName (#39795).
Problem
Default,From,Clone,PartialEq) across 29 crates have no caller. rustc'sdead_codelint exempts trait impls, so the workspace lints never report them.src/resolver/options.rs,Flags::DEFAULTSinsrc/md/types.rs, and five error variants that only a removedFromimpl constructed.Fix
--gc-sections --print-gc-sectionslists the trait methods dropped from every codegen unit. Impls that a bound or a supertrait still needs (DerefunderDerefMut,PartialEqunderOrd,From<RGBA> for SRGB) do not compile without the impl, so they stay.bun run rust:check-all(11 targets),bun run rust:clippy,cargo build --testsfor the 21 touched crates with unit tests,cargo miri testfor 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
-ffunction-sectionsat opt-level 0, so a function that nothing references is its own section and is not inlined away.--gc-sectionsdrops exactly those sections. A method that survives in any codegen unit (an#[inline]copy, for example) counts as live.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::Errorsrc/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 JsStringsrc/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 Datasrc/jsc(6):Default for BuildMessage;Default for CPUProfilerConfig;Default for Column;Default for ResolveMessage;Default for RuntimeTranspilerCache;Default for Storesrc/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 JsErrorsrc/install(4):Default for Entry;Default for MoreInstructions<'_>;Default for Scratch;PartialEq<crate::Error> for ForManifestErrorsrc/css(3):PartialEq for CustomPropertyName;PartialEq for KeyframesName;PartialEq for LayerNamesrc/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 PErrsrc/uws_sys(3):Default for ListenConfig;Default for VTable;Default for us_socket_stream_buffer_tsrc/bun_alloc(2):Default for MaxHeapAllocator;Default for Mutexsrc/bundler(2):Clone for OutputFile;Default for BunLogOptionssrc/install_types(2):Default for TarballInfo;From<CreateMatcherError> for FromExprErrorsrc/js_parser(2):Default for ReactFastRefresh;Default for ThenCatchChainsrc/sourcemap(2):Default for Chunk;Default for Mappingsrc/base64(1):Default for VLQsrc/collections(1):Default for StringMapsrc/dns(1):Default for Backendsrc/dotenv(1):Default for Mapsrc/io(1):Default for FilePollsrc/paths(1):From<Error> for crate::Errorsrc/picohttp(1):Default for Response<'a>src/ptr(1):Default for WeakPtrDatasrc/resolve_builtins(1):Default for Aliassrc/s3_signing(1):Default for SignQueryOptionssrc/sql_jsc(1):From<FlushQueueError> for crate::Errorsrc/sys(1):Default for Addresssrc/threading(1):Default for ThreadPoolFollow-up removals that became unused with them:
src/resolver/options.rs: theEXTENSION_ORDER/MODULE_EXTENSION_ORDERcopies and theTargetMainFields/DEFAULT_MAIN_FIELDS_*tables (onlyDefault for BundleOptionsread them; the bundler projects these options itself).src/md/types.rs:Flags::DEFAULTS(onlyDefault for Flagsread it;root.rsbuildsFlagsfield by field).src/parsers/xml.rs: thePErr::Oomvariant and its match arm (only the removedFrom<AllocError>produced it).src/css/rules/keyframes.rs,src/css/rules/layer.rs: theHashandEqimpls that went with the removedPartialEqimpls, and the two comments that described them. TheShapeRegistryandGlobalRegistrydocs insrc/react_compiler/hir/lose the sentence about cloning for the same reason. Neither type is used as a map key;LayerNamecomparisons go through the inherenteql.src/ast/stmt.rs:impl Eq for Data.Fromimpl, with theirname()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
bun_core::strings::rsplit_oncehas no caller, butclippy.tomlnames it as the replacement forstr::rsplit_once,str::rsplitnandbstr::ByteSlice::rsplit_once_str, so it stays. Policy files are one kind of reference the linker does not see. No other removed item is named inclippy.toml,hawk.toml, or the docs.Three impls came back during verification and are not in the diff:
Semaphore: Default(used by the macOSfs_events.rs, found byrust:check-all),clap::Help: Defaultandbraces::Token: PartialEq(used only by unit tests, found bycargo build --tests). The cross-target and test builds are needed for this kind of sweep: the linux binary alone does not see them.Scope of this sweep and what came back clean, so the next run can skip it:
Seven dead-code PRs are open right now (Remove dead code from uws_sys, webcore bindings, crash_handler, and scripts #37181, Remove dead code from bun-uws, the native BufferList class, and built-in JS #37659, Remove dead code from C++ bindings, bindgen glue, ast, and orphaned scripts #39581, Remove dead code from the bun_runtime re-export hubs, bun_core, bun_css, bun_install, bun_bundler, the FFI crates, and the error-code table #39582, Remove dead code from the JSC FFI glue, WebCore bindings, usockets, built-in JS, and orphaned scripts #39618, Remove dead code from bun_css, the build scripts, and misc crates #39697, Remove dead code from simdutf_sys, ncrypto, js_parser, bun_install, built-in JS, bindgen, uSockets, and 66 Cargo manifests #39732). This PR deletes no line that any of them deletes (checked by diffing the removed lines).
src/jsc/headergen/sizegen.cppis dead too, but Remove dead code from the JSC FFI glue, WebCore bindings, usockets, built-in JS, and orphaned scripts #39618 already removes it.Flipping every
pubtopub(crate)inbun_runtime(349k lines) and letting rustc report leaves 53 items, nearly all Windows-only or FFI enum tags. The same two-round flip over the other 95 crates found only macro-generated tables and items that are used from other platforms or from macro bodies.The gc-sections list for C++ is almost entirely covered by the open PRs. What is left is small: 15
JSFoo::toWrappedstubs, a fewncryptohelpers, a handful of unused overloads.src/js/internal/**(111 files) and the remainingsrc/js/node,builtins,bun,thirdpartyfiles (86 files) were scanned export by export: nothing dead beyond a few single lines (WASI.prototype.getState/setState, three unused WASI constants).No orphan files: every
.rsis mounted, every.cppis compiled, every.his included. No stalecfgnames (the build emits nounexpected_cfgswarnings).Left alone on purpose:
src/runtime/api/bun/h2/(in-progress rewrite,#![allow(dead_code)]by design),src/react_compiler/compile_result.rs(marked as not yet wired), the MySQLCharacterSetcollation table (222 unused constants, a code table like the oneshawk.tomlkeeps),Sys/Allocerror variants that follow the crateErrorconvention, and theJsPosterclone vtable slot.Possible larger follow-up for a maintainer decision:
PerformanceResourceTiming::createand theResourceTiming/NetworkLoadMetrics/PerformanceServerTimingconstructors are unreferenced, so no such entry can ever exist. The JS classes stay reachable as globals, which is why about 1.8k lines ofsrc/jsc/bindings/webcore/*Timing*survive. Removing them changes the global surface, so it is not in this PR.