Skip to content

Remove dead code from bun_css, bun_react_compiler, bun_jsc, and smaller crates - #40690

Open
robobun wants to merge 6 commits into
mainfrom
farm/73581f2d/dead-code-sweep
Open

robobun wants to merge 6 commits into
mainfrom
farm/73581f2d/dead-code-sweep

Conversation

@robobun

@robobun robobun commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • Code that nothing reaches remains in bun_css, bun_react_compiler, and a few smaller crates. dead_code = "deny" cannot see it: the items are pub, or trait impls, or fields that are written but never read, or branches behind an option that no caller ever sets.
  • The largest pieces are two lightningcss features that Bun never enables (PrinterOptions.analyze_dependencies, and the CSS-modules export and reference tables) and the React Compiler logger event types that no code constructs.

Fix

  • Delete the unreachable items and the plumbing that only fed them (46 files, -1471 +71 lines). Each symbol has zero references outside its own definition (rg -w over src/, packages/, scripts/, test/, build/debug/codegen/), and the workspace compiles with the items gone. The full list is in the Notes below.
  • bun_css (-820): analyze_dependencies and the Dependency types, the CssModule export and reference tables, Config.dashed_idents and the from clause of DashedIdentReference, Segment::Name. bun_react_compiler (-385): the logger event types, the events, ordered_log and renames outputs, count_memo_blocks, never-constructed enum variants. Smaller crates (-266): RefCounted::debug_name, unused HasLength impls, tcc enum variants, bun_jsc error helpers, WeakRefType::PostgreSQLQueryClient, five RedisError variants, stale builtins.d.ts declarations.
  • Add test/internal/source-lints/module-lint-escapes.test.ts: it pins the module-level #![allow(dead_code)] and #![allow(unreachable_pub)] escapes per file, like the item-level dead-code-escapes.test.ts. This change drops the escape in react_compiler/compile_result.rs, so the lint fails on main and passes here.
  • Verified: bun bd, cargo check --workspace, bun run rust:check-all (12 targets), bun bd test on test/bundler/css, test/js/bun/css, test/bundler/transpiler/react-compiler-fixtures.test.ts, test/js/valkey, test/js/sql/local-sql.test.ts, test/js/sql/postgres-binary-numeric.test.ts, test/js/bun/ffi, test/js/bun/test/mock-fn.test.js, test/js/web/fetch/fetch.test.ts (same failures as a release build in this container), and test/internal/source-lints.

Background

  • bun_css is a port of lightningcss. Bun renames CSS-module classes through the bundler symbol table, so the lightningcss export table was filled in and then dropped. analyze_dependencies replaces url() and @import with placeholders for a later rewrite pass. Bun resolves imports through ImportRecords instead, so the option was never set.
  • The React Compiler port keeps upstream's logger event shapes. Bun never wires a logger, so the event types had constructors but no construction site.
  • WeakRefType is the tag Bun passes to JSC weak handles so C++ knows which Rust finalizer to call. The PostgreSQLQueryClient arm declared a finalizer that was never defined.
Notes

Removed, per crate:

  • bun_css: the exports_by_source_index and references maps of CssModule (written, never read) with get_reference, reference_dashed, add_dashed, add_local, CssModuleExports, CssModuleReferences, CssModuleExport, CssModuleReference; Config.dashed_idents (always false); DashedIdentReference.from and parse_with_options (always None); Pattern::write_to_string, Pattern::write_to_string_with_prefix, Segment::Name; the analyze_dependencies printer option with Dependency, ImportDependency, UrlDependency, DependencyOptions, Printer.{dependencies,remove_imports}, Printer::get_import_records, Printer::replace_dots, Url::is_absolute, PrinterErrorKind::ambiguous_url_in_custom_property; the is_declaration parameter of Printer::write_dashed_ident; the raw-pointer references setup in StyleSheet::to_css_with_writer_impl; three no-op #[cfg_attr(any(), derive(...))] attributes.
  • bun_react_compiler: LoggerEvent, OrderedLogItem, DebugLogEntry, CompilerErrorDetailInfo, LoggerSuggestionInfo, LoggerSuggestionOp, CompilerErrorItemInfo, LoggerSourceLocation, LoggerPosition, BindingRenameInfo; the events, ordered_log and renames fields of CompileOutput with their producers (convert_renames, BindingRename, Environment.renames, ProgramContext.renames); count_memo_blocks with CountMemoBlockVisitor and the Debug impl for CodegenFunction that was its only reader; the four logged_severity methods; Display for ReactiveTerminalTargetKind; Error for CompilerError; ErrorCategory::{Suppression, FBT}, CompilerSuggestionOperation::{InsertBefore, InsertAfter, Remove}, JsxImportKind::CreateElement, ValueReason::StoreLocal; ExactSizeIterator, PartialEq, Eq and From<[K; N]> impls in collections.rs; the module-level #![allow(unreachable_pub)] in compile_result.rs.
  • bun_ptr, bun_core_macros: RefCounted::debug_name, ThreadSafeRefCounted::debug_name, type_base_name, and the debug_name key of #[ref_count(...)] (four attribute sites updated).
  • bun_core: HasLength impls for [u8], &str, &String.
  • bun_tcc_sys: Error::{SyntaxError, ExecError, OutputError}, OutputFormat::{Exe, Dll, Obj, Preprocess} and the matching TCC_OUTPUT_* constants.
  • bun_jsc: to_type_error_instance and to_range_error_instance on EncodedSliceJsc, to_syntax_error_instance and to_range_error_instance on StringJsc (the src/CLAUDE.md line that lists them is updated), WeakRefType::PostgreSQLQueryClient in Weak.rs and Weak.cpp.
  • bun_valkey, bun_runtime: RedisError::{InvalidArgument, InvalidArray, InvalidBigNumber, InvalidErrorString, InvalidSimpleString} and the ERR_REDIS_INVALID_{ARGUMENT, ARRAY, ERROR_STRING, SIMPLE_STRING} rows in ErrorCode.ts.
  • bun_sql_jsc: IntoOptionalData for &mut Data.
  • codegen and JS: the notImplementedIssue rule in src/codegen/replacements.ts (only the Fn form is used), 54 stale declare lines in src/js/builtins.d.ts.

Items the sweep saw and left alone, with the reason:

Candidates the compiler proved live, so they stay: Display for HookKind (used by name_anonymous_functions.rs), PendingCompile.binding (read in visit/mod.rs), Default for EditorContext (mem::take in BunObject.rs), CowSliceZ::dupe_maybe_z (used by into_owned).

Areas scanned and found clean: src/js/**, src/sql, src/valkey, src/runtime/webcore, src/runtime/node, src/runtime/{crypto,server,test_runner,bake,api,timer,ffi,napi,socket,shell}, src/http*, src/js_printer, src/runtime/cli, src/install, src/js_parser, src/bundler, src/jsc/*.rs, src/bun_core, 60 small crates, and the C++ bindings outside the files that open dead-code PRs touch.


[review] gate passed · iteration 1 · 49 files touched

fails on main (without fix)
ASAN without fix: 1 FAILED
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/module-lint-escapes.test.ts
bun test v1.4.1 (731aa92da)

test/internal/source-lints/module-lint-escapes.test.ts:
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/install/windows-shim/main.rs (1) [1.93ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/jsc/cpp.rs (1) [0.04ms]
86 |       if (count > limit) {
87 |         throw new Error(
88 |           `${source} has ${count} module-level dead_code/unreachable_pub escapes, up from ${limit}.\n` +
89 |             `A module-level escape hides every dead item in the file from the compiler. Delete the dead items or use pub(crate) instead.\n` +
90 |             `If the escape is justified, update the inventory with \`bun ./test/internal/source-lints/module-lint-escapes.test.ts --write\`.`,
91 |         );
             ^
error: src/react_compiler/compile_result.rs has 1 module-level dead_code/unreachable_pub escapes, up from 0.
A module-level escape hides every dead item in the file from the compi
... (truncated)

release without fix: 1 FAILED
bun test v1.4.1-canary.1 (a023e2016)

test/internal/source-lints/module-lint-escapes.test.ts:
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/install/windows-shim/main.rs (1) [0.04ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/jsc/cpp.rs (1)
86 |       if (count > limit) {
87 |         throw new Error(
88 |           `${source} has ${count} module-level dead_code/unreachable_pub escapes, up from ${limit}.\n` +
89 |             `A module-level escape hides every dead item in the file from the compiler. Delete the dead items or use pub(crate) instead.\n` +
90 |             `If the escape is justified, update the inventory with \`bun ./test/internal/source-lints/module-lint-escapes.test.ts --write\`.`,
91 |         );
             ^
error: src/react_compiler/compile_result.rs has 1 module-level dead_code/unreachable_pub escapes, up from 0.
A module-level escape hides every dead item in the file from the compiler. Delete the dead items or use pub(crate) instead.
If the escape is justified, update the inventory with `bun ./test/internal/source-lints/module-lint-escapes.test.ts --write`.
      at
... (truncated)
passes on PR (with fix)
ASAN with fix: all passed
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/module-lint-escapes.test.ts
bun test v1.4.1 (731aa92da)

test/internal/source-lints/module-lint-escapes.test.ts:
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/install/windows-shim/main.rs (1) [2.08ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/jsc/cpp.rs (1) [0.06ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/react_compiler/diagnostics/mod.rs (1) [0.05ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/react_compiler/hir/mod.rs (1) [0.04ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/react_compiler/inference/mod.rs (1) [0.05ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/react_compiler/optimization/mod.rs (1) [0.03ms]
(pass) module-level #![allow(dead_code)] / #![allow(unreachable_pub)] escapes > src/react_compiler/reactive_scopes/mod.rs (1) [0.03ms]
(pass) module-level #![allo
... (truncated)

release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 779ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/82] gen ErrorCode+*.h
[2/27] gen generated_host_exports.rs
generated_host_exports.rs: 122 exports (host=5, lazy=10, generic=107, rust=0); 243 extern-C blocks audited
[3/27] gen cpp.rs (cppbind)
[4/27] gen JS modules (bundle-modules)
Preprocess modules (8116ms)
Bundle modules (45ms)
Postprocesss modules (34ms)
Bundle Functions (412ms)
Generate Code (29ms)

[8.64s] Bundled "src/js" for production
  2595 kb
  197 internal modules
  13 native modules
  50 internal functions across 16 files
[4/17] cargo bun_runtime → libbun_runtime.a
�[1m�[92m   Compiling�[0m bun_core v0.0.0 (/workspace/bun/src/bun_core)
�[1m�[92m   Compiling�[0m bun_core_macros v0.0.0 (/workspace/bun/src/bun_core_macros)
�[1m�[92m   Compiling�[0m bun_errno v0.0.0 (/workspace/bun/src/errno)
�[1m�[92m   Compiling�[0m bun_ptr v0.0.0 (/workspace/bun/src/ptr)
�[1m�[92m   Compiling�[0m bun_boringssl_sys v0.0.0 (/workspace/bun/src/boringssl_sys)
�[1m�[92m   Compiling�[0m bun_safety v0.0.0 (/workspace/bun/src/safety)
�[1m�[92m   Compiling�[0m bun
... (truncated)
diff hotspot
hawk.toml                                          |   8 -
 src/CLAUDE.md                                      |   2 +-
 src/bun_core/comptime_string_map.rs                |  21 --
 src/bun_core_macros/lib.rs                         |  23 +-
 src/codegen/replacements.ts                        |   4 -
 src/css/css_modules.rs                             | 287 +--------------------
 src/css/css_parser.rs                              |  41 +--
 src/css/dependencies.rs                            |  71 +----
 src/css/error.rs                                   |  10 -
 src/css/lib.rs                                     |   2 -
 src/css/printer.rs                                 | 160 ++----------
 src/css/properties/animation.rs                    |  19 --
 src/css/properties/background.rs                   |   2 -
 src/css/properties/css_modules.rs                  |  21 --
 src/css/properties/custom.rs                       |  69 +----
 src/css/properties/masking.rs                      |   6 -
 src/css/rules/import.rs                            |  24 +-
 src/css/rules/mod.rs                               |  24 --
 src/css/values/ident.rs                            |  82 +-----
 src/css/values/image.rs                            |  35 +--
 src/css/values/url.rs                              |  73 ------
 src/js/builtins.d.ts                               |  54 ----
 src/js_parser/react_compiler_host.rs               |   1 -
 src/jsc/EncodedSlice.rs                            |   8 -
 src/jsc/Weak.rs                                    |   1 -
 src/jsc/bindings/ErrorCode.ts                      |   4 -
 src/jsc/bindings/Weak.cpp                          |  10 +-
 src/jsc/bun_string_jsc.rs                          |   8 -
 src/ptr/ref_count.rs                               |  32 ---
 src/react_compiler/codegen.rs                      |  82 ------
 src/react_compiler/collections.rs                  |  22 --
 src/react_compiler/compile_result.rs               |
... (truncated)

gate history · 3 passed · 0 rejected · iteration 1

evidence per changed file
file                                 reads  edits  tests
hawk.toml                                1      2      0
src/CLAUDE.md                            0      0      0
src/bun_core/comptime_string_map.rs      0      0      0
src/bun_core_macros/lib.rs               0      0      0
src/codegen/replacements.ts              0      0      0
src/css/css_modules.rs                   0      0      0
src/css/css_parser.rs                    0      0      0
src/css/dependencies.rs                  0      0      0
src/css/error.rs                         0      0      0
src/css/lib.rs                           0      0      0
src/css/printer.rs                       0      0      0
src/css/properties/animation.rs          0      0      0
src/css/properties/background.rs         0      0      0
src/css/properties/css_modules.rs        0      0      0
src/css/properties/custom.rs             0      0      0
src/css/properties/masking.rs            0      0      0
(+ 33 more files)

…er crates

Delete code that nothing reaches. The workspace denies dead_code, but
these items are pub, trait impls, write-only fields, or branches behind
an option that no caller sets.

bun_css: the CSS-modules export and reference tables, Config.dashed_idents,
DashedIdentReference.from, Pattern::write_to_string*, Segment::Name, the
analyze_dependencies printer option with Dependency, ImportDependency,
UrlDependency, DependencyOptions, Printer.{dependencies,remove_imports},
Printer::get_import_records, Url::is_absolute, and
PrinterErrorKind::ambiguous_url_in_custom_property.

bun_react_compiler: the logger event types (LoggerEvent, OrderedLogItem,
DebugLogEntry, CompilerErrorDetailInfo, LoggerSuggestionInfo,
LoggerSuggestionOp, CompilerErrorItemInfo, LoggerSourceLocation,
LoggerPosition), the events, ordered_log and renames fields of
CompileOutput with their producers, count_memo_blocks, the
logged_severity methods, and never-constructed enum variants.

Smaller crates: RefCounted::debug_name and its macro key, HasLength impls
for [u8], &str and &String, the unused tcc Error and OutputFormat
variants, the unused to_*_error_instance helpers in bun_jsc,
WeakRefType::PostgreSQLQueryClient, five RedisError variants with their
four ERR_REDIS_INVALID_* codes, IntoOptionalData for &mut Data, the
notImplementedIssue codegen rule, and 54 stale declarations in
src/js/builtins.d.ts.

Add a source lint that pins the module-level #![allow(dead_code)] and
dead-code analysis is a deliberate change.
@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 24 days. After that, they cost $0.25 per reviewed file.

Or wait 10 minutes for your next included review.

View limit details

Limit details: You’ve used all 5 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e034e160-d431-440e-850f-ad2dba2c35f8

📥 Commits

Reviewing files that changed from the base of the PR and between a46c250 and 6d7ad04.

📒 Files selected for processing (49)
  • hawk.toml
  • src/CLAUDE.md
  • src/bun_core/comptime_string_map.rs
  • src/bun_core_macros/lib.rs
  • src/codegen/replacements.ts
  • src/css/css_modules.rs
  • src/css/css_parser.rs
  • src/css/dependencies.rs
  • src/css/error.rs
  • src/css/lib.rs
  • src/css/printer.rs
  • src/css/properties/animation.rs
  • src/css/properties/background.rs
  • src/css/properties/css_modules.rs
  • src/css/properties/custom.rs
  • src/css/properties/masking.rs
  • src/css/rules/import.rs
  • src/css/rules/mod.rs
  • src/css/values/ident.rs
  • src/css/values/image.rs
  • src/css/values/url.rs
  • src/js/builtins.d.ts
  • src/js_parser/react_compiler_host.rs
  • src/jsc/EncodedSlice.rs
  • src/jsc/Weak.rs
  • src/jsc/bindings/ErrorCode.ts
  • src/jsc/bindings/Weak.cpp
  • src/jsc/bun_string_jsc.rs
  • src/ptr/ref_count.rs
  • src/react_compiler/codegen.rs
  • src/react_compiler/collections.rs
  • src/react_compiler/compile_result.rs
  • src/react_compiler/diagnostics/mod.rs
  • src/react_compiler/hir/environment.rs
  • src/react_compiler/hir/reactive.rs
  • src/react_compiler/hir/type_config.rs
  • src/react_compiler/imports.rs
  • src/react_compiler/lowering/hir_builder.rs
  • src/react_compiler/pipeline.rs
  • src/react_compiler/program.rs
  • src/runtime/api/bun/subprocess/SubprocessPipeReader.rs
  • src/runtime/api/js_bundle_completion_task.rs
  • src/runtime/server/HTMLBundle.rs
  • src/runtime/valkey_jsc/protocol_jsc.rs
  • src/sql_jsc/shared/SQLDataCell.rs
  • src/tcc_sys/tcc.rs
  • src/valkey/valkey_protocol.rs
  • test/internal/source-lints/module-lint-escapes.json
  • test/internal/source-lints/module-lint-escapes.test.ts

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

@robobun

robobun commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. The diff is green; CI is red only on lanes this PR does not touch.

Comment thread src/react_compiler/pipeline.rs Resolved
Comment thread src/react_compiler/pipeline.rs Resolved
@robobun

robobun commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 10:18 PM PT - Aug 27th, 2026

❌ @robobun, your commit 6d7ad04 has 1 failures in Build #107290 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 40690

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

bun-40690 --bun

Comment thread src/jsc/Weak.rs Resolved

@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.

Code review found no issues

No high-confidence issues detected in this change.

@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.

Code review found no issues

No high-confidence issues detected in this change.

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 Nov 7, 2026
…h.json input

Nine rows of the private-name list were the property names of the
node:path binding: basename, extname, format, isAbsolute, join,
normalize, parse, relative and toNamespacedPath. #45631 removed the
last read of each.

No built-in spells $name for any of them. No native code reads
namePublicName or namePrivateName. The generated code and the engine
sources do not name them as private names.

.vscode/launch.json: the input commandLine. Every configuration reads
${input:testName}, and nothing reads ${input:commandLine}.

builtins.d.ts still declares a $name for each of the nine rows. #40690
and #37305 delete those lines, so this commit leaves them.

This branch has not been deployed

No deployments
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