Remove ~39k lines of dead Rust across the workspace

Merged
JA
4mo ago
+746-38055

What does this PR do?

Deletes ~39k lines of dead Rust across the workspace. The workspace is ~100 crates but ships only two artifacts — the staticlib linked into the bun binary, and the Windows bin-linking shim — so a lot of pub API is cross-crate-visible yet unreferenced from any build. rustc's per-crate dead_code/unreachable_pub lints can't see that; a workspace-wide reachability analysis, intersected across all seven shipped target triples, can. This removes what that analysis proved dead on every target: unused functions, consts, types, extern declarations, and the fields/impls/imports/deps that cascade off them.

A few items the analysis flagged are deliberately kept, because their only users are invisible to it: an at-exit function-pointer hook (deinit_caches), a field read via const-generic string reflection (WatchItem.count), a function called only from generated code (js_assert_encoding_valid), Windows-only call sites (File::get_pos, classify_rel_t), and code under non-default Cargo features (show_crash_trace, bake_debugging_features).

Out of scope: --features show_crash_trace already fails on main (ResolverAction visibility in bun_crash_handler); unchanged here.

How did you verify your code works?

  • bun bd builds and links the debug binary (1.4.0-debug); drove it with -e across Bun.serve+fetch, blob/crypto, node:fs, subprocess, and the transpiler.
  • cargo check --workspace is clean on linux-gnu, linux-musl, windows-msvc, apple-darwin, and freebsd.
  • nm --defined-only build/debug/bun-debug shows no weak-undefined Bun__/Zig__/JSC__/napi_/uv_ symbols (Linux ZIG_DECLs are weak, so a deleted Rust definition would otherwise link and only crash when called).