Skip to content

Remove dead code and deduplicate helpers across src/#31912

Closed
alii wants to merge 18 commits into
mainfrom
claude/simplify-dead-code-pass
Closed

Remove dead code and deduplicate helpers across src/#31912
alii wants to merge 18 commits into
mainfrom
claude/simplify-dead-code-pass

Conversation

@alii

@alii alii commented Jun 5, 2026

Copy link
Copy Markdown
Member

What this is

A repo-wide cleanup pass over src/: deleting dead code and consolidating duplicated logic into shared helpers. Net −17,825 lines (206 files, +11,497 / −29,322 vs the base commit).

What changed

Dead code removed:

  • Parallel "draft" FFI implementation (host_fns.rs + draft types in ffi/mod.rs, ~620 lines) — only reference was an unused re-export
  • #[cfg(any())]-parked 1,188-variant MS-ERREF error table in src/sys/windows/mod.rs (~2,800 lines)
  • Duplicate WinsockError table + caller-less converter (−219)
  • Bundler-local copy of bun_resolver::cache::Fs (every live caller already used the resolver's)
  • Caller-less helpers, orphaned imports, and stale wrappers across cli/bake/zlib

Duplication consolidated (monomorphization-preserving — macros/const generics, no vtables added):

  • Shell builtins' copy-pasted OutputTaskVTable impls → one macro
  • JSON/TOML lexers' identical ~80-line decimal scanner → shared #[inline] generic in src/parsers/number_scan.rs (diffed against both reference implementations)
  • mysql/postgres/sqlite pooled-connection and query-constructor logic → src/js/internal/sql/shared.ts, src/sql/shared/
  • bake init_transpiler twins, link/unlink and outdated/update-interactive CLI helper blocks, bundler parse-task dispatch tail, cron/node_fs/CryptoHasher/hosted_git_info helper dedups

Verification

  • Build green; baseline test scope identical before/after (406 pass + 1 skip, 56,060 expects; runtime 5.27s vs 6.49s baseline)
  • No tests removed or weakened
  • Windows code is heavily touched (~3.5k gated lines deleted) and this was built on macOS, so cargo check was additionally run for x86_64-pc-windows-msvc and x86_64-unknown-linux-gnu — both pass, all 10 workspace cross-targets green
  • Per-change adversarial review for behavior preservation and perf: 0 regressions found; all 11 added clone sites match copies the old code already made or are cold CLI paths

Reviewer notes

  • src/css/compat.rs was converted from a generated match to a data table (equal-or-faster, verified) — but it's no longer regenerable by build-prefixes.js as-is. If we'd rather keep it generator-owned, I can revert that one commit's hunk or update the generator to emit the table form.
  • Zero behavior change is a hard goal of this PR: a 202-file behavioral-equivalence audit (one reviewer per changed file vs main, adversarially verified, plus a follow-up sweep) was run, and every confirmed divergence — error-message wording in bun add/update, postgres NoticeResponse short-length tolerance, macro-map parsing, JSON5/YAML space handling, SQL driver failure timing, pool slot guards — has been reverted to match main exactly. Where a dedup could not preserve behavior, the dedup itself was reverted.
  • The dead-code-escapes guard initially flagged a new #[allow(dead_code)] in src/router/lib.rs; resolved by deleting the orphaned cfg(test) fixture scaffolding (266 lines, plus its now-unused dev-dependency), not by updating the inventory.
  • CI triage (build 61383): bunx.test.ts "requires node 24" failure is pre-existing on main; the darwin AsyncLocalStorage-tracking fs-watch exit segfault is the known FSEventsLoop shutdown race (fs.watch(macOS): make FSEventsLoop Sync and retain the CFRunLoop across shutdown #30758 — identical stack, fault address 0xC, filed before this branch existed; every file in that crash path is byte-identical to main here).
  • This PR only moves and removes code; purely internal consolidation.

@robobun

robobun commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator
Updated 2:44 PM PT - Jun 8th, 2026

@alii, your commit 350764d has 2 failures in Build #61383 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 31912

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

bun-31912 --bun

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This PR may be a duplicate of:

  1. sql: deduplicate and remove dead code across the MySQL/Postgres drivers #31664 - Also deduplicates and removes dead code across the MySQL/Postgres SQL drivers, with overlapping changes in src/sql_jsc/shared/, src/sql_jsc/mysql/, and src/sql_jsc/postgres/

🤖 Generated with Claude Code

@alii alii force-pushed the claude/simplify-dead-code-pass branch from 590c8d0 to 3cd193f Compare June 6, 2026 03:42
@alii alii force-pushed the claude/simplify-dead-code-pass branch from 1157bd2 to 46ad414 Compare June 6, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants