Skip to content

Remove 7 stale module-level dead_code escapes from the node:http2 engine and react_compiler::hir - #42278

Open
robobun wants to merge 4 commits into
mainfrom
robobun/0c8bb89b/dead-code-sweep
Open

robobun wants to merge 4 commits into
mainfrom
robobun/0c8bb89b/dead-code-sweep

Conversation

@robobun

@robobun robobun commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • Seven module-level dead_code lint escapes are stale. Six are the #![allow(dead_code)] lines at the top of src/runtime/api/bun/h2/{wire,settings,flow_control,hpack,stream,connection}.rs. One is the dead_code entry in the #![allow(...)] block of src/react_compiler/hir/mod.rs.
  • Nothing in those modules is dead today. The escapes only hide 3,244 and 9,035 lines from rustc.
  • hawk treats every item under allow(dead_code) as a reachability root. It never reports these modules, and it keeps alive anything they reference.

Fix

  • Delete the seven escapes. test/internal/source-lints/dead-code-escapes.test.ts now requires the set of files with a module-level allow(dead_code) to equal a short allowlist (two generated surfaces, the standalone shim). It fails on main with the seven files listed and passes here.
  • Correct because dead_code is deny for the workspace and the build still passes: cargo check in dev and release on the host, bun run rust:check-all on all 12 targets, and bun bd (which adds --cfg bun_debug and --cfg bun_asan).
  • hawk on linux-x64 with the escapes removed reports no dead_public item in either directory.
  • Verified: that lint, test/js/node/http2/h2-conformance.test.ts, node-http2-settings-ack-ordering.test.ts, node-http2-continuation.test.ts, test/bundler/transpiler/react-compiler.test.ts.

Background

  • The workspace sets dead_code = "deny". An #[allow(dead_code)] is a deliberate escape. test/internal/source-lints/dead-code-escapes.test.ts pins the item-level escapes per file. It does not count module-level #![allow] blocks, so these seven were never audited.
  • hawk (hawk.toml, tools/hawk/) is the cross-crate analysis that finds pub items no other crate uses. rustc cannot see those.
  • src/runtime/api/bun/h2/ is the node:http2 engine that h2_frame_parser.rs drives. src/react_compiler/hir/ is the HIR of the React Compiler port.
Notes

This run of the dead-code sweep found no other deletion that an open PR does not already hold. What it covered, on 81f97bb020:

  • hawk on x86_64-unknown-linux-gnu, aarch64-apple-darwin and x86_64-pc-windows-msvc. 367 items are dead on all three. They are FFI struct fields, enum variants that mirror external code tables (already listed in hawk.toml), items an open PR deletes, or false positives (constants used only as array lengths, modules used only through a re-export, helpers named from generate-classes.ts templates).
  • hawk --fix to narrow visibility in a scratch tree, then cargo check with lints capped at warn. 36 dead_code hits: MultiArrayList column structs, holder fields, items used only from #[cfg(test)], or items an open PR deletes.
  • A relink of the debug objects with --gc-sections --print-gc-sections. 92 discarded C++ functions have an out-of-line definition in src/ or packages/. 76 are in open PRs. The rest have a caller on Windows or macOS, are exported API (napi_*, v8::), or are template instantiations. 1,158 discarded C-ABI symbols: the same result.
  • clang -fsyntax-only -Wunused-function -Wunused-template -Wunused-member-function -Wunused-const-variable over all 664 translation units (the build passes -Wno-unused-function). 13 hits. Four are in open PRs. The others are used on another platform or in another translation unit.
  • c-index-test -index-file over the same 664 translation units: 23,572 declarations in src/ and packages/, 7,320 with no reference. After a textual cross-check 62 names remain. All are macro-pasted names, JSC template hooks, or mirrors of the v8, libuv and llhttp headers.
  • No header that nothing includes. No .rs file outside a module tree. No unused Cargo dependency. No internal JS module that nothing requires. 179 lines of commented-out code in total.

Not in the diff:


[auto-merge] gate passed · iteration 3 · 8 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/pr_gate.xml" test/internal/source-lints/dead-code-escapes.test.ts
bun test v1.4.3 (4ff919377)

test/internal/source-lints/dead-code-escapes.test.ts:
(pass) #[allow(dead_code)] escapes > src/ast/runtime.rs (1) [1.95ms]
(pass) #[allow(dead_code)] escapes > src/bun_core/lib.rs (1) [0.06ms]
(pass) #[allow(dead_code)] escapes > src/bun_core/output.rs (1) [0.04ms]
(pass) #[allow(dead_code)] escapes > src/bun_core_macros/comptime_string_map.rs (2) [0.04ms]
(pass) #[allow(dead_code)] escapes > src/bundler/Chunk.rs (2) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/collections/multi_array_list.rs (8) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/crash_handler/lib.rs (1) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/css_derive/lib.rs (3) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/install/isolated_install/FileCloner.rs (3) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/install/lockfile/Package.rs (1) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/io/lib.rs (2) [0.04ms]
(pass) #[allow(dead_code)] escapes > src/io/posix_event_loop.rs (8) 
... (truncated)

release without fix: 1 FAILED
bun test v1.4.3-canary.1 (84a1fe8fe)

test/internal/source-lints/dead-code-escapes.test.ts:
(pass) #[allow(dead_code)] escapes > src/ast/runtime.rs (1) [0.04ms]
(pass) #[allow(dead_code)] escapes > src/bun_core/lib.rs (1)
(pass) #[allow(dead_code)] escapes > src/bun_core/output.rs (1)
(pass) #[allow(dead_code)] escapes > src/bun_core_macros/comptime_string_map.rs (2)
(pass) #[allow(dead_code)] escapes > src/bundler/Chunk.rs (2)
(pass) #[allow(dead_code)] escapes > src/collections/multi_array_list.rs (8)
(pass) #[allow(dead_code)] escapes > src/crash_handler/lib.rs (1)
(pass) #[allow(dead_code)] escapes > src/css_derive/lib.rs (3)
(pass) #[allow(dead_code)] escapes > src/install/isolated_install/FileCloner.rs (3)
(pass) #[allow(dead_code)] escapes > src/install/lockfile/Package.rs (1)
(pass) #[allow(dead_code)] escapes > src/io/lib.rs (2)
(pass) #[allow(dead_code)] escapes > src/io/posix_event_loop.rs (8)
(pass) #[allow(dead_code)] escapes > src/jsc/PosixSignalHandle.rs (4)
(pass) #[allow(dead_code)] escapes > src/jsc_macros/lib.rs (2)
(pass) #[allow(dead_code)] escapes > src/opaque/lib.rs (4)
(pass) #[allow(dead_code)] escapes > src/patch/lib.rs (2)
(pass) #[allow(d
... (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/pr_gate.xml" test/internal/source-lints/dead-code-escapes.test.ts
bun test v1.4.3 (4ff919377)

test/internal/source-lints/dead-code-escapes.test.ts:
(pass) #[allow(dead_code)] escapes > src/ast/runtime.rs (1) [2.34ms]
(pass) #[allow(dead_code)] escapes > src/bun_core/lib.rs (1) [0.07ms]
(pass) #[allow(dead_code)] escapes > src/bun_core/output.rs (1) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/bun_core_macros/comptime_string_map.rs (2) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/bundler/Chunk.rs (2) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/collections/multi_array_list.rs (8) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/crash_handler/lib.rs (1) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/css_derive/lib.rs (3) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/install/isolated_install/FileCloner.rs (3) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/install/lockfile/Package.rs (1) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/io/lib.rs (2) [0.03ms]
(pass) #[allow(dead_code)] escapes > src/io/posix_event_loop.rs (8) 
... (truncated)

release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 712ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/5] gen generated_host_exports.rs
generated_host_exports.rs: 122 exports (host=5, lazy=10, generic=107, rust=0); 243 extern-C blocks audited
[1/5] cargo bun_runtime → libbun_runtime.a
�[1m�[92m   Compiling�[0m bun_react_compiler v0.0.0 (/workspace/bun/src/react_compiler)
�[1m�[92m   Compiling�[0m bun_js_parser v0.0.0 (/workspace/bun/src/js_parser)
�[1m�[92m   Compiling�[0m bun_resolver v0.0.0 (/workspace/bun/src/resolver)
�[1m�[92m   Compiling�[0m bun_ini v0.0.0 (/workspace/bun/src/ini)
�[1m�[92m   Compiling�[0m bun_bundler v0.0.0 (/workspace/bun/src/bundler)
�[1m�[92m   Compiling�[0m bun_router v0.0.0 (/workspace/bun/src/router)
�[1m�[92m   Compiling�[0m bun_standalone_graph v0.0.0 (/workspace/bun/src/standalone_graph)
�[1m�[92m   Compiling�[0m bun_transpiler v0.0.0 (/workspace/bun/src/transpiler)
�[1m�[92m   Compiling�[0m bun_bunfig v0.0.0 (/workspace/bun/src/bunfig)
�[1m�[92m   Compiling�[0m bun_install v0.0.0 (/workspace/bun/src/install)
�[1m�[92m   Compiling�[0m bun_jsc v0.0.0 (/workspace/bun/src/
... (truncated)
diff hotspot
src/react_compiler/hir/mod.rs                      |  1 -
 src/runtime/api/bun/h2/connection.rs               |  2 --
 src/runtime/api/bun/h2/flow_control.rs             |  2 --
 src/runtime/api/bun/h2/hpack.rs                    |  2 --
 src/runtime/api/bun/h2/settings.rs                 |  2 --
 src/runtime/api/bun/h2/stream.rs                   |  2 --
 src/runtime/api/bun/h2/wire.rs                     |  2 --
 .../source-lints/dead-code-escapes.test.ts         | 25 ++++++++++++++++++++--
 8 files changed, 23 insertions(+), 15 deletions(-)

gate history · 2 passed · 1 rejected · iteration 3

evidence per changed file
file                                                  reads  edits  tests
src/react_compiler/hir/mod.rs                             0      0     12
src/runtime/api/bun/h2/connection.rs                      0      0     12
src/runtime/api/bun/h2/flow_control.rs                    0      0     12
src/runtime/api/bun/h2/hpack.rs                           0      0     12
src/runtime/api/bun/h2/settings.rs                        0      0     12
src/runtime/api/bun/h2/stream.rs                          0      0     12
src/runtime/api/bun/h2/wire.rs                            0      0     12
test/internal/source-lints/dead-code-escapes.test.ts      1      3     12

…e and react_compiler::hir

The six modules under src/runtime/api/bun/h2 each start with
#![allow(dead_code)], and react_compiler/hir/mod.rs lists dead_code in its
module-level allow. Nothing in those modules is dead any more: with the
escapes removed, cargo check passes for every shipped target in dev, and for
the host in release.

The escapes were not harmless. rustc skips the modules, and the cross-crate
hawk analysis treats every item under allow(dead_code) as a reachability
root, so 12.3k lines were invisible to both.
@robobun

robobun commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: ready to merge. The diff is green. The two red CI runs are on tests this PR does not touch.

How this was checked:

  • Removed the seven escapes, then ran cargo check -p bun_runtime -p bun_react_compiler in dev and in release on linux-x64. Both pass with dead_code = "deny".
  • bun run rust:check-all: 12 of 12 targets pass.
  • bun bd builds. The http2 and React Compiler test files named in the description pass with the debug build.
  • test/internal/source-lints/dead-code-escapes.test.ts fails with src/ from main (it lists the seven files) and passes with this branch.

CI:

  • Every build job passes on every platform, in both Buildkite runs. That is the proof for this change: the workspace denies dead_code, so a green build means nothing dead was hidden under the escapes.
  • The GitHub Actions checks pass (Source lints, cargo clippy, mordant, Format, Lint JavaScript).
  • Build 114158: one red test, test/cli/inspect/inspect.test.ts, a segmentation fault in bun on Windows 2019 x64.
  • Build 114169: one red test, test/js/bun/http/serve-pending-promise-abort-leak.test.ts on the Debian 13 x64 ASAN lane. The CI helper marks it as already failing on main.
  • All other failures passed on a retry.

The src/ change has no effect on generated code. It only removes lint attributes.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: Essentials

Run ID: b11fa56e-d4a4-4397-bb84-ed846fa2d328

📥 Commits

Reviewing files that changed from the base of the PR and between ec3a7ea and 84a1fe8.

📒 Files selected for processing (1)
  • test/internal/source-lints/dead-code-escapes.test.ts

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


Walkthrough

The change removes dead_code lint allowances from one React compiler module and six HTTP/2 modules. Source-lint tests now track module-level allowances and enforce an approved allowlist.

Changes

Dead-code lint cleanup

Layer / File(s) Summary
Remove dead-code allowances
src/react_compiler/hir/mod.rs, src/runtime/api/bun/h2/*.rs
Removes crate-level and module-level dead_code suppressions. Runtime logic and public declarations remain unchanged.
Enforce remaining allowances
test/internal/source-lints/dead-code-escapes.test.ts
Detects module-level dead_code allowances, excludes them from item-level counts, and verifies that each occurrence belongs to the approved allowlist.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 84a1f

The dead-code cleanup and allowlist enforcement are ready to merge.

🚥 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.
Title check ✅ Passed The title clearly identifies the removal of seven stale module-level dead_code escapes from the node:http2 engine and react_compiler::hir, which matches the main changes.
Description check ✅ Passed The description explains the problem, the fix, and the verification steps. It does not use the template headings exactly, but it provides the required information and includes detailed validation resu…

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

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

LGTM — pure lint-attribute deletion with no code path touched.

What was reviewed:

  • Confirmed all seven hunks only remove dead_code from module-level #![allow(...)] attributes; no other tokens change.
  • Checked src/react_compiler/hir/mod.rs: the surviving reason = "ported from facebook/react react_compiler_hir; uses std collections by design" still reads correctly for the remaining clippy::disallowed_types/disallowed_methods/unreachable_pub entries.
  • No CODEOWNERS entry covers these paths; change aligns with the repo's "delete dead code / don't hide it" rule.

<details>
<summary>Extended reasoning...</summary>

Overview

This PR deletes seven stale module-level dead_code lint escapes: six standalone #!&#91;allow(dead_code)] lines from the node:http2 engine modules (src/runtime/api/bun/h2/{connection,flow_control,hpack,settings,stream,wire}.rs) and one dead_code entry from the multi-lint #!&#91;allow(...)] block in src/react_compiler/hir/mod.rs. The diff is attribute-only — not a single line of executable code, type, or import is added or modified.

Security risks

None. Removing a lint suppression has zero runtime effect; the compiled output is byte-identical. There is no user input handling, no auth/crypto/permission surface, and no data flow change of any kind.

Level of scrutiny

Low. This is exactly the kind of mechanical cleanup the approval guidelines call out as approvable without human review. The only real risk is that unsuppressing the lint surfaces new warnings (which under the workspace's dead_code = "deny" would fail the build). The PR description states cargo check, bun run rust:check-all across all 12 targets, and bun bd all pass, and CI would catch a build break immediately if that claim were wrong. Because the workspace denies dead_code, a green build is itself the proof that nothing dead was hiding under these escapes — no separate test is needed for an attribute-only change per REVIEW.md's "refactor guilty until proven behavior-preserving" bar (the bar here is a clean rust:check-all).

Other factors

I verified the remaining reason string in react_compiler/hir/mod.rs still accurately describes the surviving allows (disallowed_types/disallowed_methods for std collections, unreachable_pub for the port), so no stale-comment issue. CODEOWNERS covers none of the touched paths. No prior reviews or outstanding objections exist on the timeline. The change directly serves REVIEW.md's "Delete dead code in the same PR that makes it dead… Public items escape dead-code lints" policy by re-enabling the lint and unblocking the hawk cross-crate reachability tool from treating these modules as roots.

</details>

…faces and the standalone shim

dead-code-escapes.test.ts skipped module-level #![allow(...)] blocks on the
assumption that they only appear on codegen surfaces. The seven escapes the
previous commit removed show that they also land on handwritten modules, where
they hide the file from rustc and root every item in it for hawk.

The lint now fails when a file outside a short allowlist carries one.

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread test/internal/source-lints/dead-code-escapes.test.ts Outdated
The check only failed when a file outside the allowlist gained an escape. An
allowlisted file that dropped its escape left a stale entry behind, and that
entry would let the escape come back unnoticed. Compare the two sets for
equality, like the item-level inventory above it does.
@robobun

robobun commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 12:31 AM PT - Sep 11th, 2026

❌ @robobun, your commit 461fa43 has 1 failures in Build #114169 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 42278

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

bun-42278 --bun

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

LGTM — the module-level check is now bidirectional (toEqual on both sorted lists), so a stale allowlist entry will fail the test just like a new escape would, and each allowlisted path carries a one-line justification.

What was reviewed:

  • The seven #!&#91;allow(dead_code)] deletions are pure lint-suppression removals with no code-path change; correctness is enforced by the workspace dead_code = "deny" plus CI's cross-target build.
  • MODULE_ESCAPE regex: the (?&lt;!&#91;\w:])dead_code\b lookbehind avoids false hits on namespaced lint names, and [^\]] fences the match inside a single attribute like the existing ESCAPE pattern.
  • The new test reuses the same stripped source (line comments removed) as the item-level scan, so commented-out attributes won't count.

<details>
<summary>Extended reasoning...</summary>

Overview

This PR deletes six #!&#91;allow(dead_code)] inner attributes from the node:http2 engine modules under src/runtime/api/bun/h2/ and drops the dead_code entry from the multi-lint #!&#91;allow(...)] in src/react_compiler/hir/mod.rs. It then extends test/internal/source-lints/dead-code-escapes.test.ts with a MODULE_ESCAPE regex and a bidirectional allowlist assertion so that any new (or stale) module-level dead_code escape breaks CI. My prior review flagged that the first version of this check was one-directional and that the react_compiler/diagnostics allowlist entry lacked a justifying comment; commit 84a1fe8 addressed both by switching to expect(moduleLevel.toSorted()).toEqual([...MODULE_ESCAPE_ALLOWED].toSorted()) and adding per-entry comments.

Security risks

None. The Rust changes remove lint suppressions only — no runtime code paths, allocations, or FFI surfaces are touched. The test change scans repository source files with a regex and compares against a hard-coded set; it takes no external input.

Level of scrutiny

Low. The native changes are one-line deletions whose only possible failure mode is a compile error (the workspace denies dead_code), which the multi-target CI build catches deterministically. The test-file change follows the exact pattern already established in the same file for item-level escapes, and the bidirectional toEqual shape matches REVIEW.md's "assert the strongest invariant" guidance.

Other factors

Exit reason was dry_streak and no findings were reported this run. There are no outstanding CHANGES_REQUESTED reviews from other parties. Both points from my earlier review have been addressed in the latest push, and REVIEW.md's dead-code guidance ("delete dead code in the same PR that makes it dead"; "do not add tests to check dead code stays dead") is satisfied here — the PR removes suppressions rather than adding them, and the new test guards escape-hatch inventory (an established local pattern in this file), not dead-symbol behavior.

</details>

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

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