Remove unused Cargo boilerplate deps from 70 crates + misc dead C++/Rust
What changed
-851 / +95 across 79 files (net -756 after rebase onto 301696e4d9). Two independent cleanups:
1. Unused Cargo [dependencies] boilerplate (~400 dep edges across 69 crates)
The Zig-to-Rust port scaffolding stamped the same 8-dep block into nearly every crate manifest:
strum.workspace = true
bstr.workspace = true
scopeguard.workspace = true
const_format.workspace = true
enum-map.workspace = true
enumset.workspace = true
libc.workspace = true
bitflags.workspace = true
Most crates use few or none of these. For each dep in each crate, verified zero references (crate name, underscore-converted name, and derive/attr macro patterns like formatcp!, EnumSetType, bitflags!, #[error() across all .rs files, then removed. bun run rust:check-all passes on all 10 target triples afterwards, so nothing was cfg-gated. Cargo.lock drops 393 lines of dead edges as a result.
Skipped src/{collections,css,glob,io,paths,router}/Cargo.toml which are touched by open PRs.
2. Dead C++/Rust symbols
| Removed | Why dead |
|---|---|
BakeSourceProvider.cpp: BakeRegisterProductionChunk | No Rust extern, no C++ caller, not declared in any header. |
BakeProduction.h | Declared an empty namespace Bake {}, only included by its own .cpp. |
subprocess/Readable.rs: on_close, on_ready; Writable.rs: on_ready + BlobSizeType import | Never wired into any SignalHandler; the live Writable::on_close is the trait impl at :559 which has its own body. |
io/posix_event_loop.rs: Waker/Closer/KEventWaker re-exports | All callers use bun_io::{Waker,Closer} via lib.rs. |
bake/DevServer.rs: ig_log! macro + declare_scope!(IncrementalGraph) | Declared via define_scoped_log!, never invoked (debug_log!/map_log! are); the static has no linker-section side effect. |
webcore/blob/write_file.rs: commented-out setFileOffset block | Carried-over Zig syntax, dead since 2023. |
(After rebase, main had independently removed the helpers.h dead statics and FSWatcher::event_loop() that were in the original diff; those hunks auto-merged to no-ops.)
Verification
bun bdbuilds clean (debug + ASAN)bun run rust:check-all: 10/10 targets pass (linux/darwin/windows/freebsd/android × x64/aarch64, plus musl)bun bd test test/internal/source-lints/dead-symbols-cargo-boilerplate.test.ts: 11/11 pass (all fail on main)bun bd test test/internal/source-lints/dead-code-escapes.test.ts: passesbun bd test test/js/node/watch/fs.watch.test.ts: 42/42 pass
Not done (follow-up candidates)
src/runtime/api/bun/h2/connection.rshas a ~200-line outbound API (begin_header_block/encode_header/send_data/send_push_promise) with no non-test callers, but it's scaffolding for the in-progressnode:http2rewrite (#31584), so left alone.OutputFile::Value::{Move,Pending}are never constructed but have match arms across two files; removing them is a refactor rather than a pure deletion.
[review] gate passed · iteration 7 · 79 files touched
fails on main (without fix)
ASAN without fix: 11 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-cargo-boilerplate.test.ts
bun test v1.4.0 (702e6016f)
test/internal/source-lints/dead-symbols-cargo-boilerplate.test.ts:
69 |
70 | for (const [rel, deps] of Object.entries(crates)) {
71 | test(rel, () => {
72 | const toml = readFileSync(join(repoRoot, rel), "utf8");
73 | const present = deps.filter(d => new RegExp(`^${d}(\\.workspace\\s*=|\\s*=)`, "m").test(toml));
74 | expect(present).toEqual([]);
^
error: expect(received).toEqual(expected)
- []
+ [
+ "strum",
+ "scopeguard",
+ "const_format",
+ "enum-map",
+ "enumset",
+ "libc",
+ "bitflags",
+ ]
- Expected - 1
+ Received + 9
at <anonymous> (/workspace/bun/test/internal/source-lints/dead-symbols-cargo-boilerplate.test.ts:74:23)
(fail) unused boilerplate Cargo deps stay removed > src/wyhash/Cargo.toml [14.80ms]
69 |
70 | for (const [rel, deps] of Object.entries(crates)) {
71 | test(rel, () => {
72 | const toml = readFileSync(join(repoRoot, rel), "utf8");
7
... (truncated)
release without fix: 11 FAILED
bun test v1.4.0-canary.1 (dd84fabaa)
test/internal/source-lints/dead-symbols-cargo-boilerplate.test.ts:
69 |
70 | for (const [rel, deps] of Object.entries(crates)) {
71 | test(rel, () => {
72 | const toml = readFileSync(join(repoRoot, rel), "utf8");
73 | const present = deps.filter(d => new RegExp(`^${d}(\\.workspace\\s*=|\\s*=)`, "m").test(toml));
74 | expect(present).toEqual([]);
^
error: expect(received).toEqual(expected)
- []
+ [
+ "strum",
+ "scopeguard",
+ "const_format",
+ "enum-map",
+ "enumset",
+ "libc",
+ "bitflags",
+ ]
- Expected - 1
+ Received + 9
at <anonymous> (/workspace/bun/test/internal/source-lints/dead-symbols-cargo-boilerplate.test.ts:74:23)
(fail) unused boilerplate Cargo deps stay removed > src/wyhash/Cargo.toml [0.37ms]
69 |
70 | for (const [rel, deps] of Object.entries(crates)) {
71 | test(rel, () => {
72 | const toml = readFileSync(join(repoRoot, rel), "utf8");
73 | const present = deps.filter(d => new RegExp(`^${d}(\\.workspace\\s*=|\\s*=)`, "m").test(toml));
74 | expect(present).toEqual([]);
^
error: expect(re
... (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/dead-symbols-cargo-boilerplate.test.ts
bun test v1.4.0 (702e6016f)
test/internal/source-lints/dead-symbols-cargo-boilerplate.test.ts:
(pass) unused boilerplate Cargo deps stay removed > src/wyhash/Cargo.toml [12.11ms]
(pass) unused boilerplate Cargo deps stay removed > src/ptr/Cargo.toml [2.95ms]
(pass) unused boilerplate Cargo deps stay removed > src/base64/Cargo.toml [5.85ms]
(pass) unused boilerplate Cargo deps stay removed > src/brotli_sys/Cargo.toml [2.27ms]
(pass) unused boilerplate Cargo deps stay removed > src/mimalloc_sys/Cargo.toml [1.49ms]
(pass) unused boilerplate Cargo deps stay removed > src/simdutf_sys/Cargo.toml [1.82ms]
(pass) unused boilerplate Cargo deps stay removed > src/sha_hmac/Cargo.toml [1.30ms]
(pass) dead symbols stay removed > src/runtime/bake/BakeSourceProvider.cpp has no "BakeRegisterProductionChunk" [2.30ms]
(pass) dead symbols stay removed > src/runtime/bake/BakeProduction.cpp has no "#include \"BakeProduction.h\"" [0.78ms]
(pass) dead symbols stay removed > src/runtime/api/bu
... (truncated)
release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 703ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/139] gen cpp.rs (cppbind)
[2/139] gen generated_host_exports.rs
generated_host_exports.rs: 94 exports (host=3, lazy=10, generic=81, rust=0); 239 extern-C blocks audited
[3/139] gen JS modules (bundle-modules)
Preprocess modules (8850ms)
Bundle modules (43ms)
Postprocesss modules (222ms)
Bundle Functions (774ms)
Generate Code (36ms)
[9.94s] Bundled "src/js" for production
2561 kb
193 internal modules
13 native modules
90 internal functions across 19 files
[3/139] 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
... (truncated)
diff hotspot
Cargo.lock | 393 ---------------------
src/ast/Cargo.toml | 2 -
src/ast_jsc/Cargo.toml | 8 -
src/base64/Cargo.toml | 7 -
src/boringssl/Cargo.toml | 7 -
src/boringssl_sys/Cargo.toml | 8 -
src/brotli_sys/Cargo.toml | 9 -
src/bun_alloc/Cargo.toml | 6 -
src/bundler/Cargo.toml | 2 -
src/bundler_jsc/Cargo.toml | 6 -
src/bunfig/Cargo.toml | 5 -
src/cares_sys/Cargo.toml | 7 -
src/clap/Cargo.toml | 6 -
src/crash_handler/Cargo.toml | 3 -
src/csrf/Cargo.toml | 7 -
src/css_jsc/Cargo.toml | 7 -
src/dns/Cargo.toml | 6 -
src/dotenv/Cargo.toml | 7 -
src/errno/Cargo.toml | 7 -
src/event_loop/Cargo.toml | 7 -
src/exe_format/Cargo.toml | 6 -
src/highway/Cargo.toml | 7 -
src/http/Cargo.toml | 5 -
src/http_jsc/Cargo.toml | 6 -
src/http_types/Cargo.toml | 5 -
src/ini/Cargo.toml | 7 -
src/install/Cargo.toml | 2 -
src/install_jsc/Cargo.toml | 6 -
src/install_types/Cargo.toml | 5 -
src/io/posix_event_loop.rs | 15 -
src/js_parser/Cargo.toml | 3 -
src/js_parser_jsc/Cargo.toml | 6 -
src/js_printer/Cargo.toml
... (truncated)
gate history · 4 passed · 1 rejected · iteration 7
evidence per changed file
file reads edits tests
Cargo.lock 0 0 0
src/ast/Cargo.toml 0 0 0
src/ast_jsc/Cargo.toml 0 0 0
src/base64/Cargo.toml 0 0 0
src/boringssl/Cargo.toml 0 0 0
src/boringssl_sys/Cargo.toml 0 0 0
src/brotli_sys/Cargo.toml 0 0 0
src/bun_alloc/Cargo.toml 0 0 0
src/bundler/Cargo.toml 0 0 0
src/bundler_jsc/Cargo.toml 0 0 0
src/bunfig/Cargo.toml 0 0 0
src/cares_sys/Cargo.toml 0 0 0
src/clap/Cargo.toml 0 0 0
src/crash_handler/Cargo.toml 0 0 0
src/csrf/Cargo.toml 0 0 0
src/css_jsc/Cargo.toml 0 0 0
(+ 63 more files)