Remove dead code from js_printer, bundler, js_parser, patch, shell, http - #35978
Conversation
js_printer::Format::Cjs / Format::CjsAscii are never constructed (only Esm
and EsmAscii are), which makes print_common_js and Transpiler::print_cjs_cold
unreachable. This also drops the IS_COMMON_JS=true Printer monomorphization
from .text.
OutputFile::Value::Move and Value::Pending are never constructed (only
Buffer/Copy/Saved/Noop are produced by OutputFile::init and transpiler.rs),
which makes move_to, get_pathname, and the Kind enum unreachable.
Also removed:
- js_parser parse_entry.rs 'if false {}' block (marked permanently disabled)
- impl PrintArg for u16 (no u16 ever reaches .print())
- task_tag::ShellIOWriter (documented as never enqueued)
- LsParseError::ShowUsage (parse_opts only returns IllegalOption)
- Stage::Connect (never assigned)
- git_diff_preprocess_paths SENTINEL const-generic (only <false> instantiated)
- 5 unused pub re-exports
Verified via rg across src/ and build/debug/codegen/; rust:check-all passes
on all 10 targets.
WalkthroughChangesThe pull request removes obsolete printer and bundler output paths, simplifies runtime dispatch and output conversion, narrows several public APIs, updates patch and parser handling, and adds source-lint tests preventing removed symbols from returning. Obsolete code-path removal
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Updated 1:35 AM PT - Jul 27th, 2026
@Jarred-Sumner, your commit ec52bc4 is building: |
The condition is side-effect-free (bool field + Vec::is_empty) and there is no trailing else, so with the body gone the whole arm is dead along with its stale comment.
…le Clone residue
print_common_js was the only Printer instantiation with
REWRITE_ESM_TO_CJS=true; the three surviving PrinterType aliases all
hard-code it to false. That makes every 'if REWRITE_ESM_TO_CJS { }'
branch dead, along with print_bundled_export and
print_module_export_symbol (only called from inside those branches).
Remove the const-generic parameter entirely.
OutputFile: the manual 'impl Clone for Value' existed only because
Value::Pending's payload wasn't Clone; with Pending gone, all remaining
payloads derive Clone. Also drop the stale 'move the file' header
comment and the stale print_common_js mentions in renamer.rs /
Chunk.rs / VirtualMachine.rs.
- valkey_jsc: drop the ValkeyContext ZST module and its sibling re-export in valkey.rs (zero consumers; rare_data.rs already documents the backing field was removed). - sourcemap/Chunk.rs: scrub the second stale printCommonJS mention at line_offset_tables doc. - shell/ls: LsParseError is now single-variant after ShowUsage was removed; inline to Result<Option<usize>, Box<[u8]>>.
…OptionsData::File FileOperation.dir's only reader was the deleted move_to. Tracing that: OptionsData::File is never constructed (only Buffer and Saved are), so the OutputFile::init arm that set op.dir/op.fd via from_file is dead, which leaves FileOperation.fd always Fd::INVALID at the one remaining construction site. Drop dir, fd, from_file, the Default impl, and the OptionsData::File variant; simplify the two copy.fd.is_valid() branches in output_file_jsc.rs to the Path arm. Also fix the two Printer<W,A,B,C,D,E> arity comments in transpiler.rs to reflect the dropped const-generic axis.
- transpiler.rs: drop the two 'same as the Cjs arm' shorthands that pointed at the deleted print_cjs_cold body (print_with_source_map_maybe already documents print_arena). - HTTPThread.rs / fetch.rs: rename the GlobalRegistry alias references in comments to the surviving ssl_config::global_registry path. - OutputFile.rs: dest_path can now move options.output_path; the .clone() was only needed for the deleted OptionsData::File arm's later borrow.
The manual impl Default existed to init the deleted fd/dir fields to Fd::INVALID; 3a84fbc converted it to a derive but also removed both ..Default::default() consumers in the same commit.
…ment scrubs Options.runtime_imports had its only reader in the deleted 'if REWRITE_ESM_TO_CJS && is_export' block in print_decl_stmt. Drop the field, its default, the two ast.runtime_imports.clone() write sites in transpiler.rs, the forwarding comment that described the plumbing, and the now-unused 'use js_ast::runtime;' import. Also: - transpiler.rs:2557 print_expr<true,false,true,false,true> stale arity - H2Client.rs plural 'aliases' comment now describes one alias
|
Diff is ready for review: net -500 across 23 source files (+1 source-lint test), all review threads resolved. Both automated reviewers returned "no bugs found". The full transitive chain from CI is green on the diff. Build #83126 (the re-roll): 194/196 jobs passed; the only test failures are all marked
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/js_printer/renamer.rs`:
- Around line 101-103: Update the ownership comment above NoOpRenamer in
renamer.rs to acknowledge that it is constructed by both print_ast and
print_json, while preserving the accurate explanation that each caller provides
an owned Map whose contents can be safely dropped.
In `@src/patch/lib.rs`:
- Around line 1731-1733: Replace the vague comment above the
slashes_to_posix_in_place call with a concise, professional explanation of the
durable Windows path-normalization invariant that requires converting
backslashes in old_folder_ to POSIX separators before copying or using the path.
In `@test/internal/source-lints/dead-symbols-printer-bundler-shell.test.ts`:
- Around line 18-29: Update the dead-symbol regex checks in the “dead js_printer
Format::Cjs chain does not reappear” test and the additional affected checks to
tolerate Rust visibility, whitespace, and line breaks. Match tokens such as
optional `pub(...)` before functions, `if false` with arbitrary whitespace
before the brace, and multiline `pub use` declarations, while preserving each
check’s intended symbol detection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5054520a-2d84-42cf-847d-58d8b37a2c70
📒 Files selected for processing (24)
src/bundler/OutputFile.rssrc/bundler/transpiler.rssrc/event_loop/ConcurrentTask.rssrc/http/H2Client.rssrc/http/HTTPThread.rssrc/http/InternalState.rssrc/http/ssl_config.rssrc/install/PackageManager/patchPackage.rssrc/install/lib.rssrc/js_parser/parse/parse_entry.rssrc/js_printer/lib.rssrc/js_printer/renamer.rssrc/jsc/VirtualMachine.rssrc/patch/lib.rssrc/runtime/api/output_file_jsc.rssrc/runtime/bake/dev_server/mod.rssrc/runtime/dispatch.rssrc/runtime/shell/IOWriter.rssrc/runtime/shell/builtin/ls.rssrc/runtime/valkey_jsc/mod.rssrc/runtime/valkey_jsc/valkey.rssrc/runtime/webcore/fetch.rssrc/sourcemap/Chunk.rstest/internal/source-lints/dead-symbols-printer-bundler-shell.test.ts
💤 Files with no reviewable changes (9)
- src/runtime/bake/dev_server/mod.rs
- src/runtime/valkey_jsc/valkey.rs
- src/runtime/shell/IOWriter.rs
- src/js_parser/parse/parse_entry.rs
- src/http/ssl_config.rs
- src/install/lib.rs
- src/http/InternalState.rs
- src/event_loop/ConcurrentTask.rs
- src/runtime/valkey_jsc/mod.rs
…mment The renamer.rs scrub in 48ce811 dropped print_common_js but missed that print_json also constructs NoOpRenamer. Also replace the pre-existing crude comment in git_diff_preprocess_paths with a plain description of the invariant.
3a84fbc converted the multi-arm match to a single if-let; the comment described the old plural shape.
There was a problem hiding this comment.
No bugs found. Deferring to a maintainer given the scope — ~500 LOC removed across 24 files including the Printer const-generic arity change in js_printer/lib.rs and OutputFile::Value/OptionsData variant deletions, which are load-bearing enough on the runtime print path that a human should confirm the Format::Cjs-unconstructed and FileOperation.fd-never-set claims.
What was reviewed:
REWRITE_ESM_TO_CJSaxis removal: every unwrapped guard (SFunction/SClass/SExportClause/ERequireString/print_decl_stmt) is behavior-preserving for the survivingfalsevalue;MAY_HAVE_MODULE_INFOreduction is correct.output_file_jsc.rscopy.fdbranch removal traced to the soleValue::Copyproducer intranspiler.rs:build_static_file, which never setfd.task_tag::ShellIOWriterremoval:COUNTassert bumped 97→96, dispatch arm andrun_from_main_threadno-op removed together; no producer found.git_diff_preprocess_pathsWindows path:.to_vec()+slashes_to_posix_in_placematches the oldSENTINEL=falsebehavior.
Extended reasoning...
Overview
Net -488 lines across 24 files. Three transitive dead-code chains: (1) js_printer::Format::Cjs/CjsAscii → print_cjs_cold → print_common_js → the REWRITE_ESM_TO_CJS const-generic axis on Printer (~280 LOC in js_printer/lib.rs, plus PrinterType alias updates); (2) OutputFile::Value::{Move,Pending} / OptionsData::File → move_to/from_file/FileOperation.{fd,dir}/Kind (~120 LOC across OutputFile.rs / output_file_jsc.rs / transpiler.rs); (3) assorted single-item removals (task_tag::ShellIOWriter, Stage::Connect, LsParseError, git_diff_preprocess_paths<SENTINEL>, five pub use re-exports, an if false block in parse_entry.rs). Plus ~14 stale-comment scrubs across the review cycle and a new source-lint test.
Security risks
None. Pure dead-code deletion; no new inputs, no parsing changes, no permission/auth/crypto surface touched. The patch/lib.rs change only drops an unused const-generic branch.
Level of scrutiny
High. js_printer/lib.rs is the runtime's JS output path — every bun run / transpiled module flows through it — and the change alters the Printer struct's const-generic arity and unwraps ~10 if REWRITE_ESM_TO_CJS guards. dispatch.rs is the event-loop hot path with a compile-time COUNT assert. OutputFile is the bundler's output handle. Each individual deletion is mechanically verifiable (and the author did verify via rg -w across src/ + codegen/), but the aggregate is large enough and the printer hot enough that a maintainer should sign off on the two root claims: that Format is only ever constructed as Esm/EsmAscii at 7 named sites, and that OptionsData::File / Value::Move/Pending have zero constructors.
Other factors
- The PR has been through ~14 review rounds (all mine were stale-comment residue, all addressed; CodeRabbit's substantive comments addressed, one withdrawn). All threads resolved.
rust:check-all10/10, transpiler/patch/worker_threads tests pass locally per the description; CI on the latest push was blocked by fleet infra, not test failures.- The
Ast.runtime_importswrite-only field created by 8761a43 is documented as a followup rather than fixed here — reasonable scope boundary. - The source-lint test follows the existing
test/internal/source-lints/dead-symbols-*.test.tspattern.
Not approving because this exceeds the "simple, mechanical, or obvious" bar: the printer const-generic arity change and the enum-variant-unconstructed claims are the kind of thing a maintainer with repo history should confirm, even though I found nothing wrong with them.
There was a problem hiding this comment.
No bugs found. All prior review threads (mine, CodeRabbit, comment-cop) are resolved and the removals check out mechanically — rust:check-all passing on 10 targets is the real proof. Deferring to a human because the scope is large: -488 lines across 21 files, including dropping the REWRITE_ESM_TO_CJS const-generic axis from Printer and a slot from the task_tag dispatch table, which are design-level commitments a maintainer should sign off on.
What was reviewed:
- Confirmed the many
Format::Cjsgrep hits insrc/are the bundler'soptions::Format/OutputFormatenum, not the removedjs_printer::Format::Cjs. FileOperation.fdremoval inoutput_file_jsc.rs—fdwas only everFd::INVALID(sole constructor isbuild_static_file, which never set it), so thePath-only branch is behaviour-preserving.task_tag::ShellIOWriterremoval +COUNT97→96 — no producer, anddispatch.rsconst-assert is updated in lockstep.CacheDirAndSubpath/PackedMapre-export removals leave the underlying types intact; no cross-crate consumers (build passes).
Extended reasoning...
Overview
Net -488 lines across 21 source files + 1 new source-lint test. Two large transitive chains: (1) js_printer::Format::Cjs/CjsAscii → print_common_js → the REWRITE_ESM_TO_CJS const-generic axis on Printer → print_bundled_export/print_module_export_symbol/Options.runtime_imports; (2) OutputFile::Value::{Move,Pending} → move_to/Kind/manual Clone → OptionsData::File → FileOperation.{fd,dir}. Plus a scattering of unconstructed enum variants (Stage::Connect, LsParseError::ShowUsage), an unused task tag (ShellIOWriter), a dead const-generic (git_diff_preprocess_paths::<SENTINEL>), five unused pub use re-exports, an if false { } block in parse_entry.rs, and ~15 stale-comment scrubs accumulated over the review cycle.
Security risks
None. Pure dead-code removal; no new inputs, no relaxed validation, no changed error handling on live paths.
Level of scrutiny
High — not because the changes are subtle, but because of scope. The compiler + rust:check-all (10 targets) provide strong structural guarantees: any missed match arm, wrong const-generic arity, or dangling cross-crate reference would fail to build. I spot-checked the highest-risk claims: the Format::Cjs grep across src/ returns ~30 hits, but every one is options::Format/bundle_opts::Format/OutputFormat/ModuleFormat (the bundler's output-format config enums), not the removed js_printer::Format print-path enum. Stage::Connect has zero remaining references. The output_file_jsc.rs copy.fd.is_valid() branch removal is safe because the only Value::Copy constructor (build_static_file) never populated fd.
That said, dropping the REWRITE_ESM_TO_CJS axis from Printer and removing a task_tag slot are design commitments (they close off a code path someone may have intended to re-enable), and 21 files touching the printer/bundler/dispatch hot paths is above my threshold for approving without a maintainer glance.
Other factors
The PR went through ~15 review iterations, all of which surfaced only stale-comment residue (plural→singular, arity counts, renamed aliases) — no behavioural findings. All inline threads are resolved. The bug-hunting system found nothing this run. Ast.runtime_imports (made write-only by 8761a43) is explicitly deferred to a followup with a stated reason. The new source-lint test follows the existing test/internal/source-lints/dead-symbols-*.test.ts convention.
There was a problem hiding this comment.
No bugs found; deferring given the size (−488 lines across 23 files in js_printer / bundler / transpiler / event-loop dispatch) — worth a maintainer sign-off rather than a bot approval.
What was reviewed:
- Verified
Format::Cjs/CjsAsciiare unconstructed at all 7 sites and theREWRITE_ESM_TO_CJSaxis,print_common_js,print_bundled_export,Options.runtime_importscascade is fully dead. - Verified
OutputFile::Value::{Move,Pending}/OptionsData::Fileare unconstructed and theFileOperation.{fd,dir}/move_to/Kindcascade has no remaining readers (includingoutput_file_jsc.rs'scopy.fdbranch). - Checked
task_tag::ShellIOWriterhas no producer,Stage::Connectis never assigned, and the removedpub usere-exports (LIVE_SESSIONS,GlobalRegistry,CacheDirAndSubpath,PackedMap,ValkeyContext) have no external references. - Note: ec52bc4 dropped the source-lint test; the PR description's Verification section still references it.
Extended reasoning...
Overview
This PR removes ~488 lines of provably-dead code across 23 files: the js_printer::Format::Cjs/CjsAscii chain and its REWRITE_ESM_TO_CJS const-generic axis (~300 LOC), OutputFile::Value::{Move,Pending} and the OptionsData::File/FileOperation.{fd,dir} cascade (~65 LOC), a permanently-disabled if false block in parse_entry.rs, an unreachable task_tag::ShellIOWriter dispatch arm, unused enum variants (LsParseError::ShowUsage, Stage::Connect), a dead SENTINEL const-generic in git_diff_preprocess_paths, and five unused pub use re-exports. It also scrubs ~15 stale comment references to the deleted code.
Security risks
None identified. This is pure deletion of unreferenced code paths; no new logic, no input handling, no auth/crypto surface. The only security-adjacent file touched (ssl_config.rs) drops a single unused re-export alias.
Level of scrutiny
High — the changes touch core hot-path infrastructure (js_printer, bundler/transpiler, event-loop dispatch.rs, ConcurrentTask tag table). Dead-code removal is low-risk when correct but requires proving each item is truly unreferenced across all cfg-gated targets and codegen output. The author verified via rg -w across src/ and build/debug/codegen/, and rust:check-all passes on 10/10 targets, which the compiler enforces for most items (removed enum variants/functions cannot compile if referenced).
Other factors
- I left 17 inline comments over the review cycle (cascading residue:
REWRITE_ESM_TO_CJSaxis,FileOperation.dir,ValkeyContextmodule,LsParseErrorcollapse, ~14 stale-comment scrubs); all were addressed and all threads are resolved. - CodeRabbit's three findings were addressed or withdrawn.
- The
Ast.runtime_importswrite-only residue is documented under "Not removed (flagged for followup)" since it cascades into two more crates. - A maintainer pushed ec52bc4 deleting the source-lint test that the PR description still references under Verification; this leaves the PR with no test file, though for pure dead-code removal the compiler's exhaustiveness check on 10/10 targets is the substantive guard. The stale description line is cosmetic.
- CI build #83218 is running on the latest commit.
Given the breadth (23 files, several core subsystems) and that a maintainer is already engaged with the branch, deferring rather than bot-approving.
…ttp (#35978) Net -488 lines across 21 source files. Each item was verified to have zero callers/constructors via `rg -w` across `src/` and `build/debug/codegen/` before deletion. ## `js_printer::Format::Cjs` / `CjsAscii` chain and the `REWRITE_ESM_TO_CJS` axis (~300 LOC) `Format` is constructed at exactly 7 sites (transpiler.rs, jsc_hooks.rs, RuntimeTranspilerStore.rs, AsyncModule.rs, JSTranspiler.rs), all of which pass `Esm` or `EsmAscii`. The enum has no `repr`/serde/bytemuck so it cannot arrive from an integer. With `Cjs`/`CjsAscii` gone: - `fn print_cjs_cold` (bundler/transpiler.rs) becomes unreachable: only caller was the `Format::Cjs` match arm. - `pub fn print_common_js` (js_printer/lib.rs) becomes unreachable: only caller was `print_cjs_cold`. - `print_common_js` was the only `Printer<_, _, _, true, ...>` instantiation, so the `REWRITE_ESM_TO_CJS` const-generic axis is dead: dropped the parameter from the struct and impl, removed `print_bundled_export` and `print_module_export_symbol` (only called inside `if REWRITE_ESM_TO_CJS { }` guards), and unwrapped/deleted the ~10 guarded branches. - `impl PrintArg for u16` has no callers (every `.print(x)` passes `u8` or `&[u8]`). ## `OutputFile::Value::Move` / `Value::Pending` (~65 LOC) `Value` is constructed only in `OutputFile::init` (Buffer/Copy/Saved) and `transpiler.rs:build_static_file` (Copy). `Move` and `Pending` are only matched, never constructed. With them gone: - `OutputFile::move_to` becomes unreachable (only called from the `Move` arm). - `FileOperation::get_pathname` becomes unreachable (only called from `move_to`). - `pub enum Kind` + `Value::kind()` become unreachable (only used in a `todo_panic!` format string). - The manual `impl Clone for Value` existed only because `Pending`'s payload wasn't `Clone`; replaced with `#[derive(Clone)]`. - `OptionsData::File` is never constructed (only `Buffer`/`Saved` are), which made `FileOperation::from_file`, `FileOperation.fd`, and `FileOperation.dir` dead; `FileOperation` is now `{ pathname: Box<[u8]> }`. ## Other removed items - `js_parser/parse/parse_entry.rs`: 58-line `else if p.options.bundle && parts.is_empty() { if false { ... } }` arm already commented "permanently disabled"; with no trailing `else` the whole arm is a no-op. - `task_tag::ShellIOWriter`: doc comment on `IOWriter::run_from_main_thread` said "No code path enqueues this tag"; confirmed no producer. - `LsParseError::ShowUsage`: `ls::parse_opts` only returns `Ok` or `Err(IllegalOption)`. - `Stage::Connect` (`http::InternalState`): only `Pending`/`Done`/`Fail` are ever assigned. - `git_diff_preprocess_paths::<SENTINEL>`: both call sites pass `<false>`; dropped the const-generic and its branches. - Unused `pub use` re-exports: `h2::LIVE_SESSIONS`, `ssl_config::GlobalRegistry`, `install::CacheDirAndSubpath`, `dev_server::PackedMap`, `valkey_jsc::ValkeyContext`. - Stale `print_common_js` mentions scrubbed from renamer.rs / Chunk.rs / VirtualMachine.rs comments. ## Verification - `bun bd` builds. - `bun run rust:check-all`: 10/10 targets pass. - `bun bd test test/bundler/transpiler/transpiler.test.js`: 182 pass. - `bun bd test test/cli/install/bun-patch.test.ts`: 29 pass. - `bun bd test test/js/node/worker_threads/worker_threads.test.ts`: 91 pass. - `test/internal/source-lints/dead-symbols-printer-bundler-shell.test.ts` asserts none of these symbols reappear. ## Not removed (flagged for followup) - `RedisError::{InvalidArray, InvalidSimpleString, InvalidErrorString, InvalidNull, InvalidArgument, JSError, JSTerminated}` appear unconstructed, but the enum derives `strum::EnumString` so they could in principle arrive via `FromStr`; left alone. - `rm::PromptBehaviour` is write-only (only checked against `Never`) but represents planned `-i`/`-I` support; left alone. - `Ast.runtime_imports` (src/ast/ast_result.rs:26) became write-only after 8761a43 removed its two `.clone()` readers in transpiler.rs. Removing it cascades into `bun_ast` and `bun_js_parser` (p.rs:8378/:8393 and the associated comment); deferred to keep this PR's crate footprint bounded. ## Scanned areas with nothing confidently dead `src/sql`, `src/runtime/crypto`, `src/threading`, `src/valkey`, `src/uws`, `src/runtime/server` were scanned and found clean (every pub item has at least one caller). These were already swept by #35002. <!-- robobun:evidence:begin --> --- **[review]** gate passed · iteration 1 · 24 files touched <details><summary>fails on main (without fix)</summary> ```console ASAN without fix: 3 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/dead-symbols-printer-bundler-shell.test.ts bun test v1.4.0 (c5288fe) test/internal/source-lints/dead-symbols-printer-bundler-shell.test.ts: 26 | ["src/js_printer/lib.rs", /fn print_module_export_symbol\b/], 27 | ["src/bundler/transpiler.rs", /fn print_cjs_cold\b/], 28 | ["src/bundler/transpiler.rs", /Format::CjsAscii => unreachable/], 29 | ]; 30 | const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); 31 | expect(resurrected).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "src/js_printer/lib.rs: ^\s*Cjs,$", + "src/js_printer/lib.rs: ^\s*CjsAscii,$", + "src/js_printer/lib.rs: pub fn print_common_js\b", + "src/js_printer/lib.rs: impl PrintArg for u16\b", + "src/js_printer/lib.rs: REWRITE_ESM_TO_CJS", + "src/js_printer/lib.rs: fn print_bundled_export\b", + "src/js_printer/lib.rs: fn print_module_export_symbol\b", + "src/bundler/transpiler.rs: fn print_cjs_cold\b", + ... (truncated) release without fix: 3 FAILED bun test v1.4.0-canary.1 (924ef25) test/internal/source-lints/dead-symbols-printer-bundler-shell.test.ts: 26 | ["src/js_printer/lib.rs", /fn print_module_export_symbol\b/], 27 | ["src/bundler/transpiler.rs", /fn print_cjs_cold\b/], 28 | ["src/bundler/transpiler.rs", /Format::CjsAscii => unreachable/], 29 | ]; 30 | const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); 31 | expect(resurrected).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "src/js_printer/lib.rs: ^\s*Cjs,$", + "src/js_printer/lib.rs: ^\s*CjsAscii,$", + "src/js_printer/lib.rs: pub fn print_common_js\b", + "src/js_printer/lib.rs: impl PrintArg for u16\b", + "src/js_printer/lib.rs: REWRITE_ESM_TO_CJS", + "src/js_printer/lib.rs: fn print_bundled_export\b", + "src/js_printer/lib.rs: fn print_module_export_symbol\b", + "src/bundler/transpiler.rs: fn print_cjs_cold\b", + "src/bundler/transpiler.rs: Format::CjsAscii => unreachable", + ] - Expected - 1 + Received + 11 at <anonymous> (/workspace/bun/test/internal/source-lints/dead-symbols-printer-bundler ... (truncated) ``` </details> <details><summary>passes on PR (with fix)</summary> ```console 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/dead-symbols-printer-bundler-shell.test.ts bun test v1.4.0 (c5288fe) test/internal/source-lints/dead-symbols-printer-bundler-shell.test.ts: (pass) dead js_printer Format::Cjs chain does not reappear [44.96ms] (pass) dead OutputFile::Value variants do not reappear [13.62ms] (pass) dead shell / http / patch items do not reappear [27.42ms] 3 pass 0 fail 3 expect() calls Ran 3 tests across 1 file. [2.54s] __F:0:S:0 release with fix: all passed $ bun scripts/build.ts --profile=release [configured] bun-profile → bun (stripped) in 860ms (unchanged) ninja: Entering directory `/workspace/bun/build/release' [1/7] gen bake.{client,server,error}.js -> bake.client.js, bake.server.js, bake.error.js [2/7] gen generated_host_exports.rs generated_host_exports.rs: 94 exports (host=3, lazy=10, generic=81, rust=0); 240 extern-C blocks audited [2/7] cargo bun_bin → libbun_rust.a (--target x86_64-unknown-linux-gnu) nightly-2026-07-20-x86_64-unknown-linux-gnu unchanged - rustc 1.99.0-nightly (9f36de775 2026-07-19) �[1m�[92m Compiling�[0m bun_core v0.0.0 (/workspace/bun/src/bun_core) �[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_zlib_sys v0.0.0 (/workspace/bun/src/zlib_sys) �[1m�[92m Compiling�[0m bun_cares_sys v0.0.0 (/workspace/bun/src/cares_sys) �[1m�[92m Compiling�[0m bun_zstd v0.0.0 (/workspace/bun/src/zstd) �[1m�[92m Compiling�[0m ... (truncated) ``` </details> <details><summary>diff hotspot</summary> ``` src/bundler/OutputFile.rs | 121 +-------- src/bundler/transpiler.rs | 87 +------ src/event_loop/ConcurrentTask.rs | 1 - src/http/H2Client.rs | 5 +- src/http/HTTPThread.rs | 4 +- src/http/InternalState.rs | 1 - src/http/ssl_config.rs | 2 - src/install/PackageManager/patchPackage.rs | 2 +- src/install/lib.rs | 1 - src/js_parser/parse/parse_entry.rs | 58 ----- src/js_printer/lib.rs | 278 ++------------------- src/js_printer/renamer.rs | 2 +- src/jsc/VirtualMachine.rs | 2 +- src/patch/lib.rs | 41 +-- src/runtime/api/output_file_jsc.rs | 33 +-- src/runtime/bake/dev_server/mod.rs | 1 - src/runtime/dispatch.rs | 8 +- src/runtime/shell/IOWriter.rs | 7 - src/runtime/shell/builtin/ls.rs | 35 +-- src/runtime/valkey_jsc/mod.rs | 9 - src/runtime/valkey_jsc/valkey.rs | 2 - src/runtime/webcore/fetch.rs | 2 +- src/sourcemap/Chunk.rs | 10 +- .../dead-symbols-printer-bundler-shell.test.ts | 68 +++++ 24 files changed, 140 insertions(+), 640 deletions(-) ``` </details> **gate history** · 9 passed · 0 rejected · iteration 1 <details><summary>evidence per changed file</summary> ``` file reads edits tests src/bundler/OutputFile.rs 6 5 0 src/bundler/transpiler.rs 5 5 0 src/event_loop/ConcurrentTask.rs 1 1 0 src/http/H2Client.rs 2 2 0 src/http/HTTPThread.rs 1 1 0 src/http/InternalState.rs 1 1 0 src/http/ssl_config.rs 1 1 0 src/install/PackageManager/patchPackage.rs 1 1 0 src/install/lib.rs 1 1 0 src/js_parser/parse/parse_entry.rs 2 2 0 src/js_printer/lib.rs 8 6 0 src/js_printer/renamer.rs 2 3 0 src/jsc/VirtualMachine.rs 1 1 0 src/patch/lib.rs 2 3 0 src/runtime/api/output_file_jsc.rs 3 3 0 src/runtime/bake/dev_server/mod.rs 1 1 0 (+ 8 more files) ``` </details> <!-- robobun:evidence:end --> --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Net -488 lines across 21 source files. Each item was verified to have zero callers/constructors via
rg -wacrosssrc/andbuild/debug/codegen/before deletion.js_printer::Format::Cjs/CjsAsciichain and theREWRITE_ESM_TO_CJSaxis (~300 LOC)Formatis constructed at exactly 7 sites (transpiler.rs, jsc_hooks.rs, RuntimeTranspilerStore.rs, AsyncModule.rs, JSTranspiler.rs), all of which passEsmorEsmAscii. The enum has norepr/serde/bytemuck so it cannot arrive from an integer. WithCjs/CjsAsciigone:fn print_cjs_cold(bundler/transpiler.rs) becomes unreachable: only caller was theFormat::Cjsmatch arm.pub fn print_common_js(js_printer/lib.rs) becomes unreachable: only caller wasprint_cjs_cold.print_common_jswas the onlyPrinter<_, _, _, true, ...>instantiation, so theREWRITE_ESM_TO_CJSconst-generic axis is dead: dropped the parameter from the struct and impl, removedprint_bundled_exportandprint_module_export_symbol(only called insideif REWRITE_ESM_TO_CJS { }guards), and unwrapped/deleted the ~10 guarded branches.impl PrintArg for u16has no callers (every.print(x)passesu8or&[u8]).OutputFile::Value::Move/Value::Pending(~65 LOC)Valueis constructed only inOutputFile::init(Buffer/Copy/Saved) andtranspiler.rs:build_static_file(Copy).MoveandPendingare only matched, never constructed. With them gone:OutputFile::move_tobecomes unreachable (only called from theMovearm).FileOperation::get_pathnamebecomes unreachable (only called frommove_to).pub enum Kind+Value::kind()become unreachable (only used in atodo_panic!format string).impl Clone for Valueexisted only becausePending's payload wasn'tClone; replaced with#[derive(Clone)].OptionsData::Fileis never constructed (onlyBuffer/Savedare), which madeFileOperation::from_file,FileOperation.fd, andFileOperation.dirdead;FileOperationis now{ pathname: Box<[u8]> }.Other removed items
js_parser/parse/parse_entry.rs: 58-lineelse if p.options.bundle && parts.is_empty() { if false { ... } }arm already commented "permanently disabled"; with no trailingelsethe whole arm is a no-op.task_tag::ShellIOWriter: doc comment onIOWriter::run_from_main_threadsaid "No code path enqueues this tag"; confirmed no producer.LsParseError::ShowUsage:ls::parse_optsonly returnsOkorErr(IllegalOption).Stage::Connect(http::InternalState): onlyPending/Done/Failare ever assigned.git_diff_preprocess_paths::<SENTINEL>: both call sites pass<false>; dropped the const-generic and its branches.pub usere-exports:h2::LIVE_SESSIONS,ssl_config::GlobalRegistry,install::CacheDirAndSubpath,dev_server::PackedMap,valkey_jsc::ValkeyContext.print_common_jsmentions scrubbed from renamer.rs / Chunk.rs / VirtualMachine.rs comments.Verification
bun bdbuilds.bun run rust:check-all: 10/10 targets pass.bun bd test test/bundler/transpiler/transpiler.test.js: 182 pass.bun bd test test/cli/install/bun-patch.test.ts: 29 pass.bun bd test test/js/node/worker_threads/worker_threads.test.ts: 91 pass.test/internal/source-lints/dead-symbols-printer-bundler-shell.test.tsasserts none of these symbols reappear.Not removed (flagged for followup)
RedisError::{InvalidArray, InvalidSimpleString, InvalidErrorString, InvalidNull, InvalidArgument, JSError, JSTerminated}appear unconstructed, but the enum derivesstrum::EnumStringso they could in principle arrive viaFromStr; left alone.rm::PromptBehaviouris write-only (only checked againstNever) but represents planned-i/-Isupport; left alone.Ast.runtime_imports(src/ast/ast_result.rs:26) became write-only after 8761a43 removed its two.clone()readers in transpiler.rs. Removing it cascades intobun_astandbun_js_parser(p.rs:8378/:8393 and the associated comment); deferred to keep this PR's crate footprint bounded.Scanned areas with nothing confidently dead
src/sql,src/runtime/crypto,src/threading,src/valkey,src/uws,src/runtime/serverwere scanned and found clean (every pub item has at least one caller). These were already swept by #35002.[review] gate passed · iteration 1 · 24 files touched
fails on main (without fix)
passes on PR (with fix)
diff hotspot
gate history · 9 passed · 0 rejected · iteration 1
evidence per changed file