Skip to content

Remove dead code from C++ bindings, bindgen glue, ast, and orphaned scripts - #37149

Closed
robobun wants to merge 2 commits into
mainfrom
claude/farm/e6322eb1/dead-code-cpp-scripts-ast
Closed

robobun wants to merge 2 commits into
mainfrom
claude/farm/e6322eb1/dead-code-cpp-scripts-ast

Conversation

@robobun

@robobun robobun commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Deletes dead code whose last references are already gone. Every removed symbol was verified to have zero references across src/, scripts/, packages/, and freshly regenerated codegen output. A source-lint test (test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts) pins the removed paths and symbols so they do not drift back.

C++ (src/jsc/bindings):

  • ncrypto.cpp/h: 33 uncalled methods from the ncrypto port (bytesToKey, FIPS toggles, secure-heap helpers, X509 time/usages getters, unused AES CTR/GCM/KW factories, BIO/Bignum constructors), the 5 named Digest factories orphaned by the bytesToKey removal (only Digest::FromName has callers), and the DataPointer secure_ field plus constructor parameters that SecureAlloc was the sole producer for
  • DOMJIT IDL helper headers (DOMJITIDLTypeFilter.h, DOMJITIDLType.h, DOMJITIDLConvert.h, DOMJITHelpers.h/.cpp): zero instantiations of any template they define; include sites now pull FrameTracers.h directly where JITOperationPrologueCallFrameTracer is used
  • 13 empty stub files (MessagePortChannel*, MessagePortIdentifier.h, BroadcastChannelRegistry.h, JSDOMConvertSerializedScriptValue.h, JSDOMBuiltinConstructorBase.*) kept by an earlier cleanup only for its own verification mechanics
  • ZigGlobalObject: 19 accessors with zero callers (8 *SinkPrototype() getters, worldIsNormal, bunStdin/bunStderr/bunStdout, KeyObjectStructure, JSBufferStructure, JSCryptoKeyStructure, builtinInternalFunctions, performMicrotaskVariadicFunction, globalProxyStructure), the backing fields and initLater closures this orphaned, and jsFunctionPerformMicrotaskVariadic
  • BunString isCrossThreadShareable, NodeValidator validateArrayBufferView, JSDOMConvertBase convertResult, JSDOMConvertSequences reserveEstimated, EventNames isGamepadEventType (declaration with no definition), ExceptionDetails EnumTraits, ResourceTiming overrideInitiatorType, WebSocket hasNativeCallbacks, PerformanceObserverCallback hasCallback (never-invoked virtual pair), ScriptExecutionContext isDocument/isWorkerGlobalScope
  • io_darwin.cpp: io_darwin_close_machport (both cfg arms); unlike its siblings it has no Rust-side declaration and no caller anywhere

Rust:

  • jsc/bindgen.rs: BindgenOptionalRepr trait, BindgenOptionalCustom, BindgenExternalShared and their impls; the bindgen codegen emitters never name them. Also the Optional::adopt helper and ExternalSharedOptional<T> (bun_core/external_shared.rs plus its two re-exports) that this orphaned.
  • ast/binding.rs: BindingInit trait and Binding::init; all construction goes through Binding::alloc or literal struct init. Two doc comments that pointed at Binding::init are updated.
  • ast/runtime.rs: write-only ImportsIteratorEntry.value field and two commented-out leftover fields
  • runtime/webcore.rs: two unused flat re-exports
  • ini/lib.rs: commented-out Zig code from the port

Scripts (invoker .github/workflows/labeled.yml.disabled was deleted in #36778, or superseded):

  • label-issue.ts, read-issue.ts, handle-crash-patterns.ts, is-outdated.ts, associate-issue-with-sentry.ts
  • nav2readme.ts (imports docs/nav, deleted in Replace old docs with new docs repo #24201; cannot run)
  • buildkite-slow-tests.js (superseded by ci:slowest and update-test-durations)
  • check-node.sh, check-node-all.sh (superseded by bun run node:test)

How did you verify your code works?

  • Full debug build (bun bd) after the rebase onto current main
  • cargo check on every CI target triple before the rebase; cargo check -p bun_core -p bun_ptr after the follow-up removal
  • bun bd test test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts passes (4/4)
  • Reference checks: repo-wide greps for each removed symbol, including regenerated build/debug/codegen/ output, return only the deletion sites

[review] gate passed · iteration 0 · 63 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/mechgate.xml" test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts
bun test v1.4.0 (3bbdb60d4)

test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts:
(pass) orphaned scripts and dead C++ headers stay deleted [515.85ms]
(pass) dead ncrypto methods do not reappear [29.72ms]
(pass) dead C++ binding helpers do not reappear [81.84ms]
172 |     // unused flat re-exports; consumers spell bun_jsc:: paths directly
173 |     ["src/runtime/webcore.rs", /pub use bun_jsc::js_error_code::DOMExceptionCode;/],
174 |     ["src/runtime/webcore.rs", /pub use bun_jsc::web_worker;/],
175 |   ];
176 |   const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
177 |   expect(resurrected).toEqual([]);
                            ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/jsc/bindgen.rs: \bBindgenOptionalRepr\b",
+   "src/jsc/bindgen.rs: \bBindgenOptionalCustom\b",
+   "src/jsc/bindgen.rs: \bBindgenExternalShared\b",
+   "src/bun_core/external_shared.rs: \bExternalSh
... (truncated)

release without fix: 1 FAILED
bun test v1.4.0-canary.1 (eabb96de7)

test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts:
(pass) orphaned scripts and dead C++ headers stay deleted [23.98ms]
(pass) dead ncrypto methods do not reappear [3.64ms]
(pass) dead C++ binding helpers do not reappear [32.49ms]
172 |     // unused flat re-exports; consumers spell bun_jsc:: paths directly
173 |     ["src/runtime/webcore.rs", /pub use bun_jsc::js_error_code::DOMExceptionCode;/],
174 |     ["src/runtime/webcore.rs", /pub use bun_jsc::web_worker;/],
175 |   ];
176 |   const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
177 |   expect(resurrected).toEqual([]);
                            ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/jsc/bindgen.rs: \bBindgenOptionalRepr\b",
+   "src/jsc/bindgen.rs: \bBindgenOptionalCustom\b",
+   "src/jsc/bindgen.rs: \bBindgenExternalShared\b",
+   "src/bun_core/external_shared.rs: \bExternalSharedOptional\b",
+   "src/jsc/Strong.rs: fn adopt\(handle: Option<NonNull<Impl>>\)",
+   "src/ast/binding.rs: \btrait BindingInit\b",
+   "src/runtime/webcore.rs: pub use bun_jsc::js_error_code:
... (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-cpp-scripts-bindgen.test.ts
bun test v1.4.0 (3bbdb60d4)

test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts:
(pass) orphaned scripts and dead C++ headers stay deleted [514.82ms]
(pass) dead ncrypto methods do not reappear [31.02ms]
(pass) dead C++ binding helpers do not reappear [84.27ms]
(pass) dead Rust symbols do not reappear [16.38ms]

 4 pass
 0 fail
 4 expect() calls
Ran 4 tests across 1 file. [3.11s]
__F:0:S:0

release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped)
  target       linux-x64-gnu
  build type   Release
  build dir    ./build/release
  revision     2f15956e62
  features     baseline

22 deps, 120 codegen, 1175 objects in 751ms

ninja: Entering directory `/workspace/bun/build/release'
[1/1236] gen ErrorCode+*.h
[2/1236] gen bindgenv2
[3/1236] fetch tinycc
[tinycc] up to date
[4/1235] fetch zlib
[zlib] up to date
[5/1235] fetch libjpeg-turbo
[libjpeg-turbo] up to date
[6/1235] install /workspace/bun
bun install v1.4.0-canary.1 (eabb96de7)

Checked 107 installs across 153 packages (no changes) [77.00ms]
[7/1235] install /workspace/bun/packages/bun-error
bun install v1.4.0-canary.1 (eabb96de7)

Checked 1 install across 2 packages (no changes) [1.00ms]
[8/1235] gen .bind.ts → GeneratedBindings.cpp
[9/1235] install /workspace/bun/src/node-fallbacks
bun install v1.4.0-canary.1 (eabb96de7)

Checked 129 installs across 147 packages (no changes) [41.00ms]
[10/1235] gen JSBuffer.lut.h
Generating /workspace/bun/build/release/codegen/JSBuffer.lut.h from /workspace/bun/src/jsc/bindings/JSBuffer.cpp
[11/1235] gen ProcessBindingBuffer.lut.h
Gen
... (truncated)
diff hotspot
scripts/associate-issue-with-sentry.ts             |  51 ---
 scripts/buildkite-slow-tests.js                    | 107 -----
 scripts/check-node-all.sh                          |  34 --
 scripts/check-node.sh                              |  41 --
 scripts/handle-crash-patterns.ts                   | 111 ------
 scripts/is-outdated.ts                             |  61 ---
 scripts/label-issue.ts                             | 353 -----------------
 scripts/nav2readme.ts                              | 113 ------
 scripts/read-issue.ts                              |  56 ---
 src/ast/binding.rs                                 |  40 +-
 src/ast/runtime.rs                                 |   6 +-
 src/bun_core/external_shared.rs                    |  51 ---
 src/bun_core/lib.rs                                |   4 +-
 src/codegen/generate-classes.ts                    |   5 +-
 src/ini/lib.rs                                     |  17 +-
 src/io/io_darwin.cpp                               |   7 -
 src/js_parser/p.rs                                 |   3 +-
 src/js_printer/lib.rs                              |   2 -
 src/jsc/Strong.rs                                  |  10 -
 src/jsc/bindgen.rs                                 |  96 +----
 src/jsc/bindings/BunObject.cpp                     |   3 -
 src/jsc/bindings/BunString.cpp                     |  18 -
 src/jsc/bindings/BunString.h                       |   1 -
 src/jsc/bindings/JSBuffer.cpp                      |   5 +-
 src/jsc/bindings/JSFFIFunction.cpp                 |   4 -
 src/jsc/bindings/NodeValidator.cpp                 |  13 -
 src/jsc/bindings/NodeValidator.h                   |   1 -
 src/jsc/bindings/ScriptExecutionContext.h          |   2 -
 src/jsc/bindings/ZigGlobalObject.cpp               |  73 ----
 src/jsc/bindings/ZigGlobalObject.h                 |  28 --
 src/jsc/bindings/ncrypto.cpp                       | 437 +--------------------
 src/jsc/bindings/ncrypto.h                       
... (truncated)

gate history · 1 passed · 0 rejected · iteration 0

evidence per changed file
file                                    reads  edits  tests
scripts/associate-issue-with-sentry.ts      0      0      0
scripts/buildkite-slow-tests.js             0      0      0
scripts/check-node-all.sh                   0      0      0
scripts/check-node.sh                       0      0      0
scripts/handle-crash-patterns.ts            0      0      0
scripts/is-outdated.ts                      0      0      0
scripts/label-issue.ts                      0      0      0
scripts/nav2readme.ts                       0      0      0
scripts/read-issue.ts                       0      0      0
src/ast/binding.rs                          0      0      0
src/ast/runtime.rs                          0      0      0
src/bun_core/external_shared.rs             1      1      0
src/bun_core/lib.rs                         1      1      0
src/codegen/generate-classes.ts             0      0      0
src/ini/lib.rs                              0      0      0
src/io/io_darwin.cpp                        0      0      0
(+ 47 more files)

root cause · written by the author bot

The root cause was that removing the bindgen optional representation impls left ExternalSharedOptional<T> as dead code, but because the type was public and re-exported from two crate roots, the dead_code lint could not flag it. The fix removes the type along with its Default, Clone, and Drop impls and both re-exports, eliminating the orphaned symbol entirely. To prevent regression, the symbol is also pinned in the dead-symbols source-lint test alongside the rest of the bindgen machinery it belonged to.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review 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: Pro

Run ID: 6c3abdc7-961f-4cfd-8e49-b771dd40efd4

📥 Commits

Reviewing files that changed from the base of the PR and between aec33f5 and 3bbdb60.

📒 Files selected for processing (60)
  • scripts/associate-issue-with-sentry.ts
  • scripts/buildkite-slow-tests.js
  • scripts/check-node-all.sh
  • scripts/check-node.sh
  • scripts/handle-crash-patterns.ts
  • scripts/is-outdated.ts
  • scripts/label-issue.ts
  • scripts/nav2readme.ts
  • scripts/read-issue.ts
  • src/ast/binding.rs
  • src/ast/runtime.rs
  • src/codegen/generate-classes.ts
  • src/ini/lib.rs
  • src/io/io_darwin.cpp
  • src/js_parser/p.rs
  • src/js_printer/lib.rs
  • src/jsc/Strong.rs
  • src/jsc/bindgen.rs
  • src/jsc/bindings/BunObject.cpp
  • src/jsc/bindings/BunString.cpp
  • src/jsc/bindings/BunString.h
  • src/jsc/bindings/JSBuffer.cpp
  • src/jsc/bindings/JSFFIFunction.cpp
  • src/jsc/bindings/NodeValidator.cpp
  • src/jsc/bindings/NodeValidator.h
  • src/jsc/bindings/ScriptExecutionContext.h
  • src/jsc/bindings/ZigGlobalObject.cpp
  • src/jsc/bindings/ZigGlobalObject.h
  • src/jsc/bindings/ncrypto.cpp
  • src/jsc/bindings/ncrypto.h
  • src/jsc/bindings/sqlite/JSSQLStatement.cpp
  • src/jsc/bindings/webcore/BroadcastChannelRegistry.h
  • src/jsc/bindings/webcore/DOMJITHelpers.cpp
  • src/jsc/bindings/webcore/DOMJITHelpers.h
  • src/jsc/bindings/webcore/DOMJITIDLConvert.h
  • src/jsc/bindings/webcore/DOMJITIDLType.h
  • src/jsc/bindings/webcore/DOMJITIDLTypeFilter.h
  • src/jsc/bindings/webcore/EventNames.h
  • src/jsc/bindings/webcore/ExceptionDetails.h
  • src/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.cpp
  • src/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.h
  • src/jsc/bindings/webcore/JSDOMConvertBase.h
  • src/jsc/bindings/webcore/JSDOMConvertSequences.h
  • src/jsc/bindings/webcore/JSDOMConvertSerializedScriptValue.h
  • src/jsc/bindings/webcore/JSPerformance.cpp
  • src/jsc/bindings/webcore/JSPerformanceObserverCallback.h
  • src/jsc/bindings/webcore/MessagePortChannel.cpp
  • src/jsc/bindings/webcore/MessagePortChannel.h
  • src/jsc/bindings/webcore/MessagePortChannelProvider.cpp
  • src/jsc/bindings/webcore/MessagePortChannelProvider.h
  • src/jsc/bindings/webcore/MessagePortChannelProviderImpl.cpp
  • src/jsc/bindings/webcore/MessagePortChannelProviderImpl.h
  • src/jsc/bindings/webcore/MessagePortChannelRegistry.cpp
  • src/jsc/bindings/webcore/MessagePortChannelRegistry.h
  • src/jsc/bindings/webcore/MessagePortIdentifier.h
  • src/jsc/bindings/webcore/PerformanceObserverCallback.h
  • src/jsc/bindings/webcore/ResourceTiming.h
  • src/jsc/bindings/webcore/WebSocket.h
  • src/runtime/webcore.rs
  • test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts
💤 Files with no reviewable changes (49)
  • src/jsc/bindings/NodeValidator.h
  • src/jsc/bindings/ScriptExecutionContext.h
  • src/jsc/bindings/webcore/EventNames.h
  • src/jsc/bindings/webcore/MessagePortChannelProviderImpl.h
  • src/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.h
  • src/jsc/bindings/JSFFIFunction.cpp
  • scripts/label-issue.ts
  • src/jsc/bindings/sqlite/JSSQLStatement.cpp
  • src/jsc/bindings/webcore/DOMJITHelpers.cpp
  • src/jsc/bindings/webcore/JSDOMConvertSerializedScriptValue.h
  • src/jsc/bindings/webcore/MessagePortChannel.cpp
  • src/jsc/bindings/webcore/DOMJITIDLConvert.h
  • src/jsc/bindings/webcore/DOMJITIDLType.h
  • src/jsc/bindings/webcore/BroadcastChannelRegistry.h
  • src/jsc/bindings/webcore/MessagePortChannel.h
  • scripts/associate-issue-with-sentry.ts
  • src/jsc/bindings/webcore/MessagePortChannelRegistry.cpp
  • src/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.cpp
  • scripts/buildkite-slow-tests.js
  • src/jsc/bindings/webcore/ResourceTiming.h
  • src/jsc/bindings/webcore/DOMJITIDLTypeFilter.h
  • scripts/check-node-all.sh
  • src/jsc/bindings/webcore/JSDOMConvertSequences.h
  • src/jsc/bindings/webcore/MessagePortChannelProvider.h
  • src/jsc/bindings/webcore/MessagePortChannelRegistry.h
  • src/jsc/bindings/webcore/WebSocket.h
  • src/runtime/webcore.rs
  • src/jsc/bindings/webcore/ExceptionDetails.h
  • src/jsc/bindings/BunString.h
  • src/jsc/bindings/NodeValidator.cpp
  • scripts/nav2readme.ts
  • src/jsc/bindings/BunObject.cpp
  • src/jsc/bindings/webcore/JSPerformanceObserverCallback.h
  • src/jsc/bindings/BunString.cpp
  • src/jsc/bindings/webcore/MessagePortChannelProviderImpl.cpp
  • src/jsc/bindings/webcore/MessagePortIdentifier.h
  • src/jsc/bindings/webcore/PerformanceObserverCallback.h
  • src/js_printer/lib.rs
  • src/jsc/bindings/ZigGlobalObject.cpp
  • scripts/is-outdated.ts
  • scripts/check-node.sh
  • src/jsc/bindings/webcore/MessagePortChannelProvider.cpp
  • src/jsc/Strong.rs
  • src/io/io_darwin.cpp
  • scripts/read-issue.ts
  • scripts/handle-crash-patterns.ts
  • src/jsc/bindings/webcore/JSDOMConvertBase.h
  • src/jsc/bindings/webcore/DOMJITHelpers.h
  • src/jsc/bindings/ZigGlobalObject.h

Included review availability: Your plan includes up to 5 reviews per rolling hour; 0 remain after this review.


Walkthrough

The pull request removes obsolete automation scripts, Rust and C++ helpers, WebCore stubs, binding APIs, and legacy ncrypto interfaces. It updates generated includes and adds a source-lint test that checks deleted paths and symbols.

Changes

Repository cleanup

Layer / File(s) Summary
Rust runtime and binding cleanup
src/ast/*, src/ini/lib.rs, src/io/io_darwin.cpp, src/js_parser/p.rs, src/js_printer/lib.rs
Removes BindingInit, Binding::init, obsolete import fields, and the Darwin Mach-port helper. Updates binding construction guidance and simplifies INI array-key detection.
Bindgen and string sharing cleanup
src/jsc/Strong.rs, src/jsc/bindgen.rs, src/jsc/bindings/BunString.*
Removes optional custom representations, external shared-pointer adapters, Optional::adopt, and isCrossThreadShareable.
JavaScriptCore and WebCore binding cleanup
src/codegen/*, src/jsc/bindings/*, src/jsc/bindings/webcore/*, src/runtime/webcore.rs
Removes obsolete DOMJIT and WebCore stubs, unused validators and accessors, global-object state, callback helpers, and selected runtime re-exports. Updates generated includes.
ncrypto API reduction
src/jsc/bindings/ncrypto.*
Removes legacy digest, cipher, certificate, BIO, bignum, key-check, secure-memory, and FIPS APIs. DataPointer now always uses cleared freeing without secure-state parameters.
Deletion enforcement
test/internal/source-lints/dead-symbols-cpp-scripts-bindgen.test.ts
Adds checks for deleted scripts, C++ files, ncrypto APIs, binding helpers, Rust symbols, and runtime exports.

Possibly related PRs

Suggested reviewers: jarred-sumner, cirospaciari

🚥 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 and concisely summarizes the removal of dead code across the main affected areas.
Description check ✅ Passed The description completes both required sections and provides detailed scope, rationale, and verification evidence.

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

@robobun
robobun force-pushed the claude/farm/e6322eb1/dead-code-cpp-scripts-ast branch from 5ac671c to 69a9823 Compare August 7, 2026 16:46
@github-actions github-actions Bot added the claude label Aug 7, 2026
Comment thread src/ast/binding.rs
Comment thread src/jsc/bindings/ncrypto.h
Comment thread src/jsc/bindings/ZigGlobalObject.h
Comment thread src/ast/binding.rs
Comment thread src/js_parser/p.rs
@robobun
robobun force-pushed the claude/farm/e6322eb1/dead-code-cpp-scripts-ast branch from 4cca497 to 15fddf0 Compare August 7, 2026 17:13
Comment thread src/jsc/bindgen.rs
@robobun

robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review in 15fddf0: completed the DataPointer secure_ cascade in ncrypto, removed the orphaned ZigGlobalObject backing fields plus their initLater closures and jsFunctionPerformMicrotaskVariadic, and fixed the two doc comments that still referenced the deleted Binding::init. Full build, all-triple cargo check, and crypto/webcrypto smoke tests pass after the change. PR is now net -2001 lines.

Jarred-Sumner added a commit that referenced this pull request Aug 16, 2026
…egen, build scripts, and misc crates (#39249)

Removes 2772 lines that nothing references (136 lines of signature,
import and formatting adjustments added, plus a 214-line source lint
pinning the removed symbols) across the WebCrypto bindings, the
node:http internal binding and the C++/Rust behind it, the class code
generator, the build scripts, and four Rust crates. No behavior change.

### Problem

**WebCrypto (`src/jsc/bindings/webcrypto/`, about 560 lines)**
- `SubtleCrypto.cpp` has had `isRSAESPKCSWebCryptoDeprecated()`
returning `true` unconditionally since 2023, so every RSAES-PKCS1-v1_5
operation is rejected with `NotSupportedError` before the algorithm
class is reached. Its
`encrypt`/`decrypt`/`generateKey`/`importKey`/`exportKey` overrides, the
whole of `CryptoAlgorithmRSAES_PKCS1_v1_5OpenSSL.cpp`, and
`JSRsaKeyGenParams.{cpp,h}` (whose only caller was the unreachable
generateKey branch) were dead. `isSafeCurvesEnabled()` is the same
shape: always `true`, one never-taken branch.
- `CryptoAlgorithmEcdsaParams::encoding` (DER signatures) and the
`padding` fields of `RsaPssParams`/`RsaOaepParams` were only ever set by
the old `src/bun.js/bindings/KeyObject.cpp`, deleted in April 2025.
Since then the DER branches in `CryptoAlgorithmECDSAOpenSSL.cpp`, the
padding branches in the PSS/OAEP OpenSSL files, and
`platformEncryptWithHash`/`platformDecryptWithHash` ran on constant
inputs. The same file left behind the `ignoreExtAndKeyOps` parameter of
`convertDictionaryToJS(JsonWebKey)` (no caller passes `true`) and
include blocks copied verbatim into `node_crypto_binding.cpp` and
`AsymmetricKeyValue.cpp` (neither file uses any of them).
- `CryptoAlgorithmMlDsaParams::isolatedCopy()` has no `crossThreadCopy`
instantiation, `CryptoAlgorithm::VoidCallback` has no user,
`SubtleCrypto::addAuthenticatedEncryptionWarningIfNecessary` is an empty
body with two calls, and `CryptoKey.cpp`/`CryptoAlgorithmX25519.cpp`
carried includes nothing in the file uses.

**node:http binding (`src/js/internal/http.ts`, `NodeHTTP.cpp`, and the
Rust it reached, about 880 lines)**
- `internal/http.ts` destructures the object returned by
`createNodeHTTPInternalBinding` and re-exports the members, but no
module imports `getHeader`, `setHeader`, `Headers`, `assignHeaders`,
`setRequestTimeout`, `headersTuple`, `webRequestOrResponseHasBodyValue`
or `getCompleteWebRequestOrResponseBodyValueAsArrayBuffer` (the last
users left with the http client rewrite); `assignEventCallback`,
`Request`, `Response` and `Blob` were registered but not even
destructured. A few symbols (`kDeprecatedReplySymbol`,
`controllerSymbol`, `runSymbol`, `deferredSymbol`, `firstWriteSymbol`,
`kEmptyObject`) and `isAbortError`/`get|setIsNextIncomingMessageHTTPS`
lost their last reader in earlier sweeps.
- That binding object is the only way into `NodeHTTP.cpp`'s
`jsHTTPAssignHeaders`, `jsHTTPAssignEventCallback`, `jsHTTPSetTimeout`,
`jsHTTPGetHeader` and `jsHTTPSetHeader`, which in turn were the only
callers of `assignHeadersFromFetchHeaders`,
`assignHeadersFromUWebSockets` (the `...ForCall` variant used by the
request path stays) and the `RequestHeaderKind` helpers: about 600 lines
of C++.
- Those host functions were the only callers of the Rust exports
`jsFunctionRequestOrResponseHasBodyValue`,
`jsFunctionGetCompleteRequestOrResponseBodyValueAsArrayBuffer`
(`Response.rs`), `Request__getUWSRequest`,
`Request__setInternalEventCallback`, `Request__setTimeout`
(`Request.rs`) and `NodeHTTPResponse__setTimeout`
(`NodeHTTPResponse.rs`). `Request__setInternalEventCallback` was the
only writer of `Request::internal_event_callback`, and the JS side
stopped calling it in 2024, so `InternalJSEventCallback`, the
`RequestContext::on_timeout` handler, `set_timeout_handler`, the
`HAS_TIMEOUT_HANDLER` flag and its three clear sites, and
`AnyRequestContext::enable_timeout_events` have not been reachable since
then; `Body::Value::is_definitely_empty` was only used by the removed
host function.

**Code generators and build scripts (about 1000 lines)**
- `generate-classes.ts`/`class-definitions.ts` still emitted code for
`.classes.ts` keys no class file sets: `own` (and the
`ZigGeneratedClasses.lut.txt` -> `.lut.h` build step in
`scripts/build/codegen.ts`, whose output was an empty header),
`callbacks`, the `accessor` field variant, `supportsObjectCreate`,
`custom`, `zigOnly`, `defaultValue`, plus the `ONLY_ZIG` and
`BUN_SILENT` environment switches nothing sets (`git grep` over all 30
`*.classes.ts` files, and `git log -G` for the keys that ever existed).
`bundle-functions.ts` handled `$nakedConstructor`, `$sloppy` and
`$intrinsic` directives no file in `src/js/builtins` uses, and tracked
write-only fields; `generate-jssink.ts`, `replacements.ts`
(`OutOfMemoryError` rewrite, no builtin throws it) and `cppbind.ts` had
smaller leftovers. `src/runtime/bake/bake.bind.ts` was 100% comments and
produced an empty `GeneratedBake.h` nothing includes.
- `scripts/utils.mjs` (379 lines: `downloadTarget` and its helpers,
`getBuildArtifacts` and its helpers, `getChangedFiles`,
`isDocumentation`, `getPullRequestRepository`, `getRepositoryOwner`,
`escapeYaml`, `escapeGitHubAction`, `parseNumber`, `getUser`, `isArm64`)
and `scripts/runner.node.mjs` (`listArtifactsFromBuildKite`, a local
`escapeGitHubAction`) exported functions none of the 11 importers
import. `glob-sources.ts` globbed two patterns that have never matched a
file; `flags.ts` defined `LIBUS_USE_BORINGSSL`, which nothing in `src/`,
`packages/` or `vendor/` reads; `config.ts` carried three resolved
fields nothing reads (the `PartialConfig` inputs stay);
`depVersionsHeader.ts` and five `deps/*.ts` emitted seven version macros
with no consumer in `BunProcess.cpp`, the header's only includer.

**Rust crates (about 140 lines)**
- `CssModuleReference::Local`/`Global` are never constructed (only
`Dependency` is) and `eql` has no caller; `bun_sys` duplicated
`NT_UNC_OBJECT_PREFIX`/`_U8` (the live copies are in `bun_paths`) and
two Windows send-flag constants the wrappers do not use;
`cares_sys::AddrInfo::name` has no caller; `libuv_sys` kept
`Loop::{ref_, unref, unref_count, run, tick_with_timeout, wakeup}`,
`uv_write_t::write_raw`, `uv_async_t::send`, `Process::get_pid`,
`uv_stat_t::{atime, ctime}`, `ReturnCode::from_raw`,
`ReturnCodeI64::init`, five type aliases and the two externs only those
methods used. These come from the workspace reachability analysis in
`tools/hawk/`, run for linux-gnu, darwin and windows-msvc and then
re-checked by hand; the items it reported that are used only from
`debug_assertions` code (which the release-profile analysis does not
see) or only on FreeBSD were kept.

### Fix
- Deletes the items above. The only non-deletion edits are the ones the
deletions force: the three RSAES rejections in `SubtleCrypto.cpp` become
unconditional (same error strings, pinned by
`test/js/web/crypto/web-crypto.test.ts`), `isSupportedExportKey` loses
an unused parameter, `platformEncrypt`/`platformDecrypt` in RSA-OAEP
absorb their one-line `WithHash` wrappers, `RequestContext::set_timeout`
keeps its `clear_timeout()` for `0`, one `const` destructure in
`internal/http.ts` is reflowed, and `generate-classes.ts` conditions
that became constant are folded.
- Generator changes were verified by re-running `generate-classes.ts`,
`generate-jssink.ts` and `bundle-modules.ts` into a scratch directory
and comparing with the output generated before the change:
byte-identical except for the dropped `#include
"ZigGeneratedClasses.lut.h"` line and the two deleted webcrypto files
disappearing from the `NativeFilenameCPP` union. `bun scripts/build.ts
--configure-only` confirms `build.ninja` no longer references
`GeneratedBake.h`, the `.lut` pair, or `LIBUS_USE_BORINGSSL`, and that
the C++ source list changed only by the three deleted files.
- Verified: `bun bd` builds; `bun run rust:check-all` passes on all 12
target triples; `cargo fmt --check`, prettier and clang-format are
clean. `bun bd test` passes on `test/js/web/crypto/web-crypto.test.ts`
(94),
`test/js/node/crypto/{crypto.key-objects,crypto-rsa,sign-jwk-ieee-p1363,crypto-pqc,x509}`
(162),
`test/js/node/http/{node-http,node-http-server-timeouts,node-http-server-abort-events,node-http-res-settimeout-unref}`
(151; the one failure, the http proxy test, fails identically with the
released binary in this container), `test/js/bun/http/serve.test.ts`
(283; the 4 failures, requestIP v6, root-range port, #6583 and
/bun:info, fail identically with the released binary here),
`test/js/node/http2/node-http2.test.js`,
`test/js/node/fs/fs-leak.test.js`, `test/js/bun/udp/dgram.test.ts`,
`test/js/node/readline/readline.node.test.ts`,
`test/bundler/css/css-modules.test.ts`,
`test/js/node/process/process.test.js` (dependency version assertions
pass; the `USER` env assertion fails on both binaries here), the nine
`test/internal/build-*`/`bindgen`/`macos-cross-config`/`rust-*` tests,
`test/js/bun/perf/linker-order.test.ts`, and all of
`test/internal/source-lints/` (166). The new
`dead-symbols-webcrypto-nodehttp-codegen.test.ts` fails on main and
passes here.
- Cross-checked against the 19 open dead-code PRs at the line level: no
deleted line here is deleted by any of them, except boilerplate lines
(`auto& vm = ...`) that #35437 also deletes from a different function in
`NodeHTTP.cpp`. Hunks adjacent to open PRs, which will need a trivial
rebase on whichever side lands second: the `internal/http.ts`
destructure and `NodeHTTP.cpp` registration block (#35437 removes
`setServerIdleTimeout` there), the `CryptoKey.cpp` include block (#38005
removes the neighbouring line), `CryptoAlgorithmRSA_PSSOpenSSL.cpp`
(#38005's hunk still applies), `class-definitions.ts` (#37208 removes
`isEventEmitter`), `generate-classes.ts` (#37149 removes four DOMJIT
includes), and `c_ares.rs` (#38703 removes a method 30 lines below).

### Background
- `createNodeHTTPInternalBinding` is the C++ function behind
`$cpp("NodeHTTP.cpp", ...)` in `internal/http.ts`; it builds a plain
object whose properties are JS functions wrapping C++ host functions. A
host function registered there is reachable only if some builtin reads
the property, which is why the JS import graph decides what is dead in
the C++ file.
- Rust functions marked `export_name`/`uws_callback(export = ...)` exist
for C++ callers; `cppbind`/js2native codegen emits the glue from the
sources, so once the last C++ caller is gone they are unreachable, and
the workspace lints (`dead_code`/`unused_imports` are `deny`) then flag
whatever only they called, which is how the
`Request.rs`/`RequestContext.rs` cascade was found and bounded.
- `Request::internal_event_callback` was the hook node:http used to be
told about per-request timeouts and aborts;
`RequestContext::set_timeout_handler` registered the uWS timeout
callback only when that hook was set. With no setter, the flag was never
set and the handler never registered, so removing them changes nothing
at runtime; `server.timeout()` still arms the socket timeout and the
abort path is untouched.
- `generate-classes.ts` reads every `src/**/*.classes.ts` and emits
`ZigGeneratedClasses.{h,cpp}` plus `generated_classes.rs`; a feature of
the class definition format that no class uses is dead code in the
generator, and its removal is checkable by diffing the generated files.
- `tools/hawk/README.md` describes the workspace-wide reachability
analysis used for the Rust items: rustc's per-crate `dead_code` lint
treats every `pub` item of a library crate as live, so cross-crate dead
`pub` items need this separate pass.

<details>
<summary>Found dead but deliberately left alone</summary>

- `bun_shim_impl::read_without_launch` and `FromBunShellContext`
(`src/install/windows-shim/bun_shim_impl.rs`) have no caller, but the
`LauncherMode::ReadWithoutLaunch` mode is threaded through the launcher,
so removing it cleanly means de-generifying `launcher()`; better as its
own change.
- The write-only `CssModule::references` map itself (this PR removes
only the never-constructed variants); the `#[cfg(target_arch =
"wasm32")]` branches scattered through the parser/output code (no wasm32
target is built, but earlier commits describe it as "not built yet", so
that is a product call); `windows_errno::posix::{mode_t, E}` and
`bun_sys::File::write` (unused, but intentional API parity with the
POSIX side); `WindowsLoop::{wait, unref}` and the Windows
`us_socket_t::write_fd` stub (8 and 7 lines in files three open PRs are
editing).
- `AnyResponse::on_timeout` / `uws_res_on_timeout` in `bun_uws_sys` lose
their last caller with this PR (`set_timeout_handler` was it); left for
the next pass since those files are in open PRs.
- DOMJIT support in `generate-classes.ts` is disabled on purpose
(`define()` strips it), not dead; the split CI build modes in
`scripts/build/profiles.ts` were explicitly kept by #37733 four days
ago; the `*.idl` files in webcrypto are kept as documentation as in the
previous sweeps; the AES-GCM `> UINT64_MAX` checks are
upstream-identical.
- Every item carrying `#[allow(dead_code)]` in the tree was re-verified
and is live on some platform or under `debug_assertions` (the inventory
in `dead-code-escape-limits.json` is accurate), so nothing was taken
from there.
- `CryptoAlgorithmAKPShared.h` does not include
`CryptoAlgorithmParameters.h`, so `CryptoAlgorithmMLDSA.cpp` only
compiles inside its unified bundle; pre-existing and unrelated to this
change.
</details>

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

@robobun rebase

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

conflicts

@robobun robobun reopened this Aug 16, 2026
Comment thread src/jsc/bindgen.rs
…cripts

Every deleted symbol was verified to have zero references across src/,
scripts/, packages/, and freshly regenerated build/debug/codegen/ output,
then validated with a full debug build and cargo check on every CI
target triple.

C++ (src/jsc/bindings):
- ncrypto.cpp/h: 33 uncalled methods from the ncrypto port (bytesToKey,
  FIPS toggles, secure-heap helpers, X509 time/usages getters, unused
  AES CTR/GCM/KW factories, BIO/Bignum constructors), the 5 named Digest
  factories orphaned by the bytesToKey removal (only Digest::FromName
  has callers), and the DataPointer secure_ field plus constructor
  parameters that SecureAlloc was the sole producer for
- DOMJIT IDL helper headers (DOMJITIDLTypeFilter.h, DOMJITIDLType.h,
  DOMJITIDLConvert.h, DOMJITHelpers.h/.cpp): zero instantiations of any
  template they define; include sites now pull FrameTracers.h directly
  where JITOperationPrologueCallFrameTracer is used
- 13 empty stub files (MessagePortChannel*, MessagePortIdentifier.h,
  BroadcastChannelRegistry.h, JSDOMConvertSerializedScriptValue.h,
  JSDOMBuiltinConstructorBase.*) kept by an earlier cleanup only for
  its own verification mechanics
- ZigGlobalObject: 19 accessors with zero callers (8 *SinkPrototype()
  getters, worldIsNormal, bunStdin/bunStderr/bunStdout, KeyObjectStructure,
  JSBufferStructure, JSCryptoKeyStructure, builtinInternalFunctions,
  performMicrotaskVariadicFunction, globalProxyStructure), the backing
  fields and initLater closures this orphaned, and
  jsFunctionPerformMicrotaskVariadic
- BunString isCrossThreadShareable, NodeValidator validateArrayBufferView,
  JSDOMConvertBase convertResult, JSDOMConvertSequences reserveEstimated,
  EventNames isGamepadEventType (declaration with no definition),
  ExceptionDetails EnumTraits, ResourceTiming overrideInitiatorType,
  WebSocket hasNativeCallbacks, PerformanceObserverCallback hasCallback
  (never-invoked virtual pair), ScriptExecutionContext isDocument/
  isWorkerGlobalScope
- io_darwin.cpp: io_darwin_close_machport (both cfg arms); unlike its
  siblings it has no Rust-side declaration and no caller anywhere

Rust:
- jsc/bindgen.rs: BindgenOptionalRepr trait, BindgenOptionalCustom,
  BindgenExternalShared and their impls; the bindgen codegen emitters
  never name them. Also the Optional::adopt helper this orphaned.
- ast/binding.rs: BindingInit trait and Binding::init; all construction
  goes through Binding::alloc or literal struct init. Two doc comments
  that pointed at Binding::init are updated.
- ast/runtime.rs: write-only ImportsIteratorEntry.value field and two
  commented-out leftover fields
- runtime/webcore.rs: two unused flat re-exports
- ini/lib.rs: commented-out Zig code from the port

Scripts (invoker .github/workflows/labeled.yml.disabled was deleted in
 #36778, or superseded):
- label-issue.ts, read-issue.ts, handle-crash-patterns.ts,
  is-outdated.ts, associate-issue-with-sentry.ts
- nav2readme.ts (imports docs/nav, deleted in #24201; cannot run)
- buildkite-slow-tests.js (superseded by ci:slowest and
  update-test-durations)
- check-node.sh, check-node-all.sh (superseded by bun run node:test)

A source-lint test pins the removed symbols so they do not drift back.
@robobun
robobun force-pushed the claude/farm/e6322eb1/dead-code-cpp-scripts-ast branch from 15fddf0 to 3bbdb60 Compare August 16, 2026 07:16
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@robobun

robobun commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main in 3bbdb60 and reopened. Two conflicts, both resolved by keeping the code main added next to the deleted lines. Two items dropped because main moved first: clearDOMGuardedObjects() is now defined and called on main so its declaration stays, and WTFTimer__runIfImminent was already removed on main. Everything else re-verified against the new main; full build, cargo check on every triple, the source-lint suite, and crypto/performance smoke tests pass post-rebase. Net -1993 lines.

…removal

The BindgenOptionalRepr impls for BindgenString and BindgenExternalShared
were its only consumers. It escaped the dead_code lint because it is pub
and re-exported from two crate roots. Also drops the two re-exports and
pins the symbol in the source-lint test.
@robobun

robobun commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up after the rebase: removed ExternalSharedOptional and its two re-exports in 2f15956 (the review caught that deleting the bindgen optional-repr impls orphaned it) and pinned the symbol in the source-lint test. Verified with a full debug build and the lint test (4/4 pass). Also restored the PR description, which the rebase had cleared.

@robobun

robobun commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 12:54 AM PT - Aug 16th, 2026

✅ @robobun, your commit 2f15956e62f644c21b718b065389b529b4f88f8f passed in Build #99283! 🎉


🧪   To try this PR locally:

bunx bun-pr 37149

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

bun-37149 --bun

Jarred-Sumner pushed a commit that referenced this pull request Aug 17, 2026
… loader column, unused native bindings, builtins.d.ts and misc crates (#39448)

Net -2,649 lines under `src/` (29 files, +28 / -2,677 by `git diff
--minimal`), plus a 249-line source lint pinning the removals. No
behavior change: everything removed had no caller, and for the Rust
parts rustc is the reference check (see Verification).

Nothing here overlaps the 20 dead-code PRs currently open; their diffs
were compared line by line, and files they edit near these hunks were
left alone (see the last section).

### node:http2: the legacy inbound frame path (-2,148 in
`h2_frame_parser.rs`, -154 in C++)

Since the engine rewrite (#31584) every inbound byte goes through
`rewrite_read()` into `api/h2/connection.rs`; the pre-engine inbound
half of `h2_frame_parser.rs` has been unreachable since, and the file
carried a file-level `#![allow(dead_code)]` with a comment saying so.
This PR drops `dead_code` from that attribute and deletes exactly what
rustc then reports (the list below is rustc's, not grep's), so the file
is now under the workspace's `dead_code = deny` like every other file
and the retired path cannot grow back.

- The reader and dispatcher: `read_bytes`, `dispatch_frame`,
`lookup_inbound_stream`.
- The 14 frame handlers (`handle_incomming_payload`,
`handle_data_frame`, `handle_headers_frame`,
`handle_continuation_frame`, `handle_settings_frame`,
`handle_window_update_frame`, `handle_rst_stream_frame`,
`handle_ping_frame`, `handle_go_away_frame`, `handle_priority_frame`,
`handle_push_promise_frame`, `handle_altsvc_frame`,
`handle_origin_frame`, `handle_unknown_frame`) plus
`decode_header_block`, `finish_headers_end_stream`, and the `Payload`
struct they returned.
- Helpers with no remaining caller: `H2FrameParser::{decode,
adjust_window_size, increment_window_size_if_needed, send_settings_ack,
dispatch_with_3_extra}`, `get_http2_common_string` and its extern
declaration.
- Decode-direction wire helpers: `u32_from_bytes`, `SettingsFlags`,
`UInt31WithReserved::{from, from_bytes}`, `StreamPriority::from`,
`SettingsPayloadUnit` (and its `from`),
`FullSettingsPayload::{update_with, write}`, `type HeaderValue`,
`ErrorCode::FLOW_CONTROL_ERROR`.
- Write-only state those handlers maintained:
`H2FrameParser::{current_frame, remaining_length,
expecting_continuation, preface_received_len, read_buffer}` (the last
one was only ever reset; the engine keeps its own `rewrite_tail`) and
`Stream::{is_waiting_more_headers, header_block_size,
header_block_count, pending_header_block, pending_header_flags,
padding}`.
- `FullSettingsPayload::write` was the only thing that used the struct's
on-wire shape (the live serializer, `write_settings_payload`, writes ids
as literals and reads only the value fields), so the seven `_*_type`
fields, `#[repr(C, packed)]`, the bytemuck impls, `BYTE_SIZE` and its
size assert, and the `SettingsType` constants that only initialized
those fields go with it. `to_engine_settings`, `to_js` and `default()`
are unchanged; the two struct literals lose a `..Default::default()`
that no longer fills anything.
- C++: `JSC__JSGlobalObject__getHTTP2CommonString`
(`ZigGlobalObject.cpp`) lost its only caller above, and
`Bun::Http2CommonStrings` (`BunHttp2CommonStrings.h/.cpp`: 61 lazily
created JSStrings for the HPACK static table, one slot per global
object) had no reader other than that function, so both files, the
`m_http2CommonStrings` member and its `initialize()` call are removed.
The entry for the deleted header in
`dead-symbols-ffi-sys-test-runner-cpp.test.ts` is dropped with it.

### Native class methods no built-in JS calls (-72)

Each was declared in a `.classes.ts` file and implemented in Rust, but
nothing in `src/js/` (or `test/`) invokes it; none of these classes is
reachable by user code (they live behind private fields of the JS
wrappers). The `.classes.ts` entry and the implementation are removed
together, so the regenerated bindings simply stop referencing them.

- `QuicSession.silentClose` (`quic.classes.ts`, `session.rs`) and
`QuicEndpoint.ref` (`fn: "doRef"`, `endpoint.rs`; the endpoint's
keepalive is driven natively, `poll_ref` stays).
- `NodeJSFS.unwatchFile` (`node.classes.ts`, `node_fs_binding.rs`,
`node_fs.rs`): a `Maybe::todo()` stub; `fs.unwatchFile` is implemented
in `internal/fs/watchfile.ts` and never called the binding. The
`args::UnwatchFile` / `ret::UnwatchFile` aliases only it used go too. It
was also the only stub that called `Maybe::todo()` on every target; the
three remaining stubs (Windows `lchmod`, the `FICLONE_FORCE` arm of
`copy_file` and its fallback arm) now spell `Err(sys::Error::todo())`,
which is all the `MaybeTodo` extension trait in `node.rs` did, so the
trait is removed as well.
- `FSWatcher.hasRef` (`node.classes.ts`, `node_fs_watcher.rs`);
`internal/fs/watch.ts` only calls `ref`/`unref`/`close`. The `hasRef` of
`Timeout` and `Immediate` is public API and untouched.

### The watcher's write-only `loader` column (-65 across 8 files)

`WatchItem.loader` was stored for every watched file and directory and
never read (no `WatchItemColumns` accessor, no `items::<"loader">`
anywhere). Removing the field removes the `bun_watcher::Loader` newtype
in `watcher/lib.rs`, which existed only to carry it across the crate
boundary, the drift-guard `const _` assert in `hot_reloader.rs` that
kept its `File` constant in sync with `bun_ast::Loader`, and the
`loader` parameter of `Watcher::{add_file, add_file_by_path_slow}` and
the private add helpers, `ImportWatcher::{add_file,
add_file_by_path_slow}` and `jsc_hooks::maybe_watch_file`, along with
the argument at every call site (`bundle_v2.rs` x2,
`RuntimeTranspilerStore.rs` x2, `jsc_hooks.rs` x4, `VirtualMachine.rs`,
`test_command.rs`; `add_main_to_watcher_if_needed` and the `bun test
--changed` seeding loop no longer compute a loader they only passed
along).

### `pub` helpers with no caller in any crate (-65)

- `bun_core`: `Unaligned::new`, `util::Mutex::get_mut`,
`util::RwLock::get_mut` (and the mention in the module note),
`Timespec::new`, `RawSlice::from_raw`.
- `bun_sys`: `DynLib::handle` (the only `DynLib` user, `bun:ffi`, never
reads the raw handle) and `posix::read` (nothing imports
`bun_sys::posix::read`; the live raw reader is `bun_sys::linux::read`),
with the two comments that listed it.
- `bun_jsc`: `JSValue::cast`. `tcc_sys`: the `SymbolCallback` type alias
and its re-export.

### `src/js/builtins.d.ts` (-131)

Declarations of `$`-names no file under `src/js/` references (checked as
exact tokens across `src/`, `src/codegen/`, `scripts/` and `test/`): 31
JSC intrinsic functions that were either `(): TODO` stubs or unused
(`$getByValWithThis`, `$getPrototypeOf`, `$fulfillPromise`, the
generator / iterator / module-record internal-field accessors,
`$isConstructor`, `$isGenerator`, `$toNumber`, `$toObject`,
`$newArrayWithSpecies`, ...), 41 intrinsic constants (`$iterationKind*`,
`$generatorField*`, `$AsyncGeneratorState*`, ... , all typed `TODO`
except the `$MAX_*` limits and the unused `$Module*` phases), `$trunc`,
`$newHandledRejectedPromise`, `$enqueueJob`, `$Object`, five `$ERR_*`
signature overrides whose codes are only thrown from C++ (the generated
`ErrorCode.d.ts` still declares them), a duplicate
`$ERR_INVALID_HANDLE_TYPE` declaration, and the five `$ReadableStream*`
type aliases. The only script that reads this file is
`generate-node-errors.ts`, which uses it to decide whether to emit the
generic `$ERR_*` declaration. `tsc -p src/js` reports byte-for-byte the
same diagnostics before and after (the baseline is not clean, but
nothing new appears and nothing disappears).

The private-name block further down the file (`$body`, `$close`, ...)
has unused entries too, but #38900 is already editing that block, so it
is left for after that lands.

### Verification

- `bun bd` (full debug build; regenerates the class bindings, which is
what stops referencing the four removed methods) builds, and `cargo
check --workspace` is clean: removing a Rust item that still had a
caller fails to compile, which is the reference check for everything
above. `GenericIndexOptional::{get, is_some, is_none}`, which an earlier
sweep had flagged, turned out to have gained callers since and were kept
because of exactly this check.
- `bun run rust:check-all`: every CI target triple checks (covers the
Windows and macOS watcher backends and the `cfg(unix)`-only
`posix::read`).
- `cargo fmt --all --check` clean.
- `bun bd test` on `test/js/node/http2/node-http2.test.js` (360 pass),
`h2-conformance`, `node-http2-continuation`,
`node-http2-invalid-padding`, `node-http2-streams-rehash` (88 pass),
`test/js/node/watch/fs.watch.test.ts`, `fs.watchFile.test.ts`,
`test/js/node/quic/quic-endpoint.test.ts`, `quic-stream.test.ts`,
`test/cli/watch/watch.test.ts`, `test/js/bun/ffi/ffi.test.js`.
- `test/internal/source-lints/` (all 25 files) passes, including the new
`dead-symbols-h2-inbound-watcher-loader-misc.test.ts`; all seven of its
tests fail against `main` (every one of its 94 checks fires there) and
pass here. Because that lint reads `src/js/builtins.d.ts`, which was not
among the paths that trigger the source-lints workflow, the file is
added to `.github/workflows/source-lints.yml` so a PR reintroducing a
declaration runs the lint itself instead of failing the next unrelated
PR.

### Found but left for a later run

- `ManifestLoad::LoadFromMemory` (`src/install`): every caller passes
`LoadFromMemoryFallbackToDisk`, so the variant, the `cache_behavior`
parameter and the memory-only arm in
`PackageManifestMap::by_name_hash_allow_expired` are dead; touching it
means one-line hunks in nine `src/install` files that change daily, so
it is better done on its own.
- The 27 `internalBinding('quic')` constants nothing in
`src/js/internal/quic` destructures (`DEFAULT_MAX_*`, the numeric
`CC_ALGO_*`, the `IDX_STATE_ENDPOINT_*_SIZE` entries, ...):
unreferenced, but the table deliberately mirrors node's binding surface,
so it is noted rather than trimmed.
- `ExternalShared::as_ptr`, `UTIME_OMIT` and the unused `builtins.d.ts`
private names: either adjacent to hunks in open PRs (#37149, #38900) or
part of a constant pair, so left alone.
Jarred-Sumner pushed a commit that referenced this pull request Aug 18, 2026
… and misc crates (#39574)

### Problem
- `src/jsc/bindings/libuv/` is only on the include path for non-Windows
builds (`scripts/build/flags.ts`, "libuv stubs for unix"). `uv/win.h`
(703 lines) and `uv/tree.h` (512 lines, included only by `win.h`) are
never reached.
- `uv/sunos.h`, `uv/os390.h`, `uv/aix.h` and `uv/posix.h` are selected
by `uv/unix.h` only on Solaris, z/OS, AIX, IBM i, Cygwin, Haiku, QNX and
Hurd. Bun builds for linux, macOS and FreeBSD.
- `packages/bun-error` is embedded in the dev error page
(`src/runtime/server/dev-error-page.html`). The page calls the function
behind `Symbol.for("Bun__renderFallbackError")` and nothing else.
`renderRuntimeError`, the abort state `dismissError` kept for it, and
the two modules only it imported (`sourcemap.ts`,
`stack-trace-parser.ts`) have no callers. #37081 lists this path as a
follow-up.
- `bun_zlib_sys::posix` and `bun_zlib_sys::win32` declare zlib functions
that nothing calls. `bun_zlib` declares its own. The only use of the two
modules was as re-exports of the types in `shared.rs`.
- A set of `pub` items in other crates has no user in any crate. rustc
cannot report them because `pub` items count as used.

### Fix
- Delete the six libuv headers. `uv.h` now includes `uv/unix.h`
directly. `uv/unix.h` keeps the linux, darwin and BSD branches.
`uv-posix-polyfills.c` drops the commented-out copies of the removed
branches.
- Delete `renderRuntimeError`, `sourcemap.ts` and
`stack-trace-parser.ts`. `dismissError` keeps the part that removes the
overlay. `runtime-error.ts` stays (it has a test).
- Delete `bun_zlib_sys/posix.rs` and `win32.rs`. `bun_zlib` imports the
types from `bun_zlib_sys::shared`, which is where the removed modules
took them from.
- Delete the unused Rust items listed below, plus the trait
implementations and imports that only they needed.

Verification:
- Every Rust item was found by making the unexported items crate-private
and compiling the workspace. An item is deleted only if rustc reports it
dead on x86_64 linux (dev, release, and with the `bun_debug` and
`bun_asan` cfgs), aarch64 linux, x86_64 musl, x86_64 Windows and aarch64
macOS.
- Each removed name was also searched in `src/codegen/`, the
`*.classes.ts` files, `src/js/` and the C++ bindings. Items that a
codegen template can emit were kept.
- `bun run rust:check-all`: 12 of 12 targets pass. `cargo check
--workspace --all-targets` passes (benches and unit tests still
compile). `cargo check -p bun_shim_impl --features shim_standalone` for
the Windows target passes.
- `bun bd` builds. The build recompiles `uv-posix-stubs.c` and
`uv-posix-polyfills.c` against the trimmed `uv.h`, and rebuilds the
bun-error bundle, which no longer exports `renderRuntimeError`.
- New test in `test/js/bun/http/serve.test.ts`: it takes the bun-error
bundle out of a real 500 page, evaluates it outside a browser, and
checks that the bundle registers the renderer and that `dismissError` is
a no-op when nothing is rendered. This is the surface the
`packages/bun-error` change touches.
- `bun bd test` passes for `test/js/bun/http/serve.test.ts -t "dev error
page"` (including the new test), `test/js/bun/runtime-error.test.ts`,
`test/js/bun/util/{zstd,arraybuffersink,filesink}.test.ts`,
`test/js/node/zlib/deflate-streaming.test.ts`,
`test/js/web/encoding/text-{encoder,decoder}.test.*`,
`test/js/workerd/html-rewriter.test.js`,
`test/js/bun/css/nth-anplusb-ident.test.ts`,
`test/js/web/fetch/blob.test.ts` and
`test/internal/source-lints/dead-code-escapes.test.ts`.
- `cargo fmt --check`, clang-format on the touched C file and prettier
on the touched TypeScript files pass.

<details>
<summary>Removed Rust items</summary>

- `bun_zlib_sys`: modules `posix` and `win32` (`struct_gz_header_s`,
`gz_header`, `gz_headerp`, `in_func`, `out_func`, and the `deflate*`,
`inflate*`, `compress*`, `uncompress`, `adler32`, `crc32`, `zlibVersion`
declarations), `shared::voidpf`.
- `bun_zlib`: declarations `compress`, `compressBound`, `uncompress`,
and the `internal` module that selected between the two removed modules.
- `bun_zstd`: `decompress` (every caller uses `decompress_append`).
- `bun_libdeflate_sys`: `libdeflate_deflate_decompress` (the `_ex`
variant is the one in use).
- `bun_mimalloc_sys`: `mi_strdup`, `mi_heap_collect`,
`mi_thread_set_in_threadpool`.
- `bun_cares_sys`: `ares_strerror`.
- `bun_windows_sys`: `SetHandleInformation`, `closesocket`.
- `bun_alloc`: `default_alloc::calloc`.
- `bun_core`: `GenericIndexInt::from_usize` and its macro-generated
implementations.
- `bun_css`: the four deprecated `to_css` methods on
`GenericSelectorList`, `GenericSelector`, `GenericComponent` and
`Combinator`. Their bodies were `unreachable!()`; the serializer
functions replaced them.
- `bun_runtime`: `JsSinkType::done` and its six overrides,
`FileCloser::update` and its implementations, `ReadableStream::to_js`,
`node_fs::Null::to_js`.

</details>

<details>
<summary>Overlap with open pull requests</summary>

The deletions here were checked against the open dead-code pull requests
(#35437, #35775, #35880, #36115, #36237, #37012, #37149, #37181, #37208,
#37301, #37454, #37659, #37788, #38005, #38900, #39319, #39561) and
against #38958 and #35075. Nothing deleted here is deleted by any of
them. Candidates they already cover were left out: `src/jsc/bindgen.rs`
(#37149), the dead `pub use` re-exports (#39319), the simdutf big-endian
and UTF-32 wrappers (#38958), and the items named in the skip lists of
the others. Some files here (`bun_alloc/lib.rs`, `bun_core/util.rs`,
`libdeflate.rs`, `mimalloc.rs`, `node_fs.rs`, `Blob.rs`, `FileSink.rs`,
`ReadableStream.rs`, `streams.rs`, `windows_sys/externs.rs`) are also
touched by open pull requests in different hunks. #36437 edits
`packages/bun-error` from a base that predates #37081; it changes one
import line in `stack-trace-parser.ts` and keeps `renderRuntimeError`,
so it does not overlap with this deletion but will need a rebase.

</details>

<details>
<summary>Found but not deleted (judgment calls for a
maintainer)</summary>

- `packages/bun-inspector-protocol/src/protocol/v8/` (about 32,600
lines): not exported by the package index since 2023 and regenerated
only with the opt-in `--v8` flag of `scripts/generate-protocol.ts`.
#39110 kept the flag, so this needs a decision.
- `packages/h3blast` (1,468 lines) and `packages/bun-build-mdx-rs` (558
lines): nothing in the repository references them. They may be kept on
purpose as a load generator and a proof of concept.
- `packages/bun-error/runtime-error.ts` is unused by the page but
covered by `test/js/bun/runtime-error.test.ts`. The four images in
`packages/bun-error/img/` are referenced only by the source glob in
`scripts/glob-sources.ts`.
- `HotReloadTaskView` in `src/jsc/hot_reloader.rs`: both `reload`
implementations ignore the task, and `VirtualMachine::reload` ignores
its `Option<HotReloadTask>` argument. Removing the plumbing is a small
refactor rather than a deletion.
- `react_compiler/compile_result.rs` has constructors and fields with no
users, but the file says the types are waiting to be wired up.
- The streams-era private globals in `BunBuiltinNames.h`
(`makeGetterTypeError`, `makeDOMException`, `addAbortAlgorithmToSignal`,
`removeAbortAlgorithmFromSignal`, `isAbortSignal`,
`createUninitializedArrayBuffer`, about 100 lines of
`ZigGlobalObject.cpp`) have no JS callers. Both files are being edited
by several open dead-code pull requests, so they were left for a later
run.

</details>

### Background
- rustc's `dead_code` lint treats every `pub` item in a library crate as
used, because another crate could import it. In this workspace every
crate is an implementation detail of one binary, so a `pub` item with no
importer in any crate is dead in the same sense as a private one. Making
such items crate-private for one compile lets rustc report the ones with
no users at all. The visibility changes themselves are not part of this
pull request.
- On POSIX, bun does not link libuv. Node-API addons that reference
libuv symbols get `uv-posix-stubs.c` and `uv-posix-polyfills*.c`, which
are compiled against the copied headers in `src/jsc/bindings/libuv/`. On
Windows the real libuv is linked and that directory is not used.
- `JsSinkType` is the Rust trait behind the native sink classes
(`FileSink`, `ArrayBufferSink`, the HTTP response sinks). Its methods
are called from the shared sink glue in `Sink.rs`; `done` was declared
there but the glue never called it.

<!-- robobun:evidence:begin -->

---

**no test proof** · iteration 1 · Platform-specific test(s) that do not
run on this machine. Deferring to CI, which covers all platforms:
test/js/bun/http/serve.test.ts

<!-- robobun:evidence:end -->
@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

Closing as stale: this has merge conflicts with main. If the dead code is still present, please open a fresh PR against current main.

Jarred-Sumner pushed a commit that referenced this pull request Aug 18, 2026
…cy edges (#37301)

Scheduled dead-code sweep. This run scanned areas not claimed by the
open dead-code PRs (#37208, #37272, #37229, #37181, #37149, #37089,
#37062, #37012, #36237, #36115, #35880, #35775, #35437):
src/runtime/crypto, src/runtime/node, src/runtime/webcore,
src/runtime/api, src/runtime/socket, src/runtime/image,
src/runtime/webview, src/http, src/dns, src/dotenv, src/which, src/glob,
src/s3_signing, src/patch, src/router, src/semver, src/paths,
src/threading, src/event_loop, src/io, src/transpiler, src/sourcemap,
src/ast, src/parsers, src/options_types, src/platform, src/analytics,
src/base64, src/standalone_graph, src/shell_parser, src/md, src/output,
src/ptr, src/safety, src/perf, src/dispatch, src/uws, all 697 headers
and 572 cpp files under src/jsc/bindings, src/js, scripts/, and
commented-out blocks repo wide.

The yield is small because the workspace denies `dead_code` and
`unreachable_pub`, and prior sweeps plus the 13 open PRs hold everything
else. Everything that survived verification:

## Removed

- `ToJSError::MacroError` (src/ast/nodes.rs): never constructed
anywhere; its only mention was a defensive match arm in
src/runtime/api/YAMLObject.rs, now folded into the remaining defensive
arm. (The `MacroError` enum in src/js_parser_jsc/Macro.rs is a
different, live type.)
- `pub use crate::webview::chrome_process as ChromeProcess`
(src/runtime/api.rs): zero references to the alias; the module stays
reachable via `crate::webview::chrome_process` and its `host_fn`
exports.
- `strum::IntoStaticStr`, `PartialEq`, `Eq` derives on `Algorithm`
(src/runtime/crypto/PasswordObject.rs): the generated `From<Algorithm>
for &'static str` and equality impls have zero call sites. Name parsing
goes through `algorithm_from_zig_string` and hash-string formatting
through `pwhash`.
- Commented-out `globalThis.ASSERT` draft (src/runtime/bake/debug.ts
lines 1-11): superseded verbatim by the live `globalThis.DEBUG.ASSERT`
directly below it.
- Unused Cargo dependency edges: `bun_runtime` does not reference
`bun_css` (only `bun_css_jsc`) or `bun_transpiler`; `bun_spawn` does not
reference `bstr`. Verified by zero textual references including
cfg-gated code; note `rust-argon2` looks unreferenced by the same
textual check but is live via `use ::argon2 as vendor` (lib name differs
from package name), so it stays.

## Verification

- rg zero references for each symbol across src/, scripts/, packages/,
and build/debug/codegen output
- `bun bd` builds clean
- `bun scripts/rust-check-all.ts`: 10 ok, 0 failed, 0 skipped
- `bun bd test` on password.test.ts (71 pass), yaml.test.ts (642 pass),
bake/deinitialization.test.ts (1 pass)

## Not removed (follow-up notes)

- src/runtime/webcore/TextEncoder.rs defines `unsafe extern "C" fn c`, a
byte-identical duplicate of the adjacent `TextEncoder__encode16`,
exported under the global symbol name `c`. No C++ declaration or caller
was found, but extern "C" items are excluded from this sweep on
principle. Looks like a rename accident worth a human look.
- The h2 send-side cluster in src/runtime/api/bun/h2/connection.rs (~200
LOC, test-only callers) is scaffolding for the node:http2 rewrite, as
already noted in #35880.
- scripts/find-dead-exports.ts and scripts/trace.sh have no in-repo
referencers but look like manual dev tools; left alone.
- The boilerplate dep edges in
src/{collections,css,glob,io,paths,router}/Cargo.toml are already
removed by #35437 and #37229, so they are deliberately not duplicated
here.

<!-- robobun:evidence:begin -->

---

**[review]** gate passed · iteration 0 · 9 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-runtime-ast-deps.test.ts
bun test v1.4.0 (3cadf9f48)

test/internal/source-lints/dead-symbols-runtime-ast-deps.test.ts:
33 |     // hash-string formatting goes through pwhash); PartialEq/Eq were likewise
34 |     // never used.
35 |     ["src/runtime/crypto/PasswordObject.rs", /\bstrum\b/],
36 |   ];
37 |   const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
38 |   expect(resurrected).toEqual([]);
                           ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/ast/nodes.rs: \bMacroError\b",
+   "src/runtime/api/YAMLObject.rs: Up::MacroError",
+   "src/runtime/api.rs: chrome_process as ChromeProcess",
+   "src/runtime/crypto/PasswordObject.rs: \bstrum\b",
+ ]

- Expected  - 1
+ Received  + 6

      at <anonymous> (/workspace/bun/test/internal/source-lints/dead-symbols-runtime-ast-deps.test.ts:38:23)
(fail) dead Rust symbols (ast, runtime) do not reappear [38.66ms]
48 | });
49 | 
50 | test("dead built-in JS co
... (truncated)

release without fix: 3 FAILED
bun test v1.4.0-canary.1 (9008ae7)

test/internal/source-lints/dead-symbols-runtime-ast-deps.test.ts:
33 |     // hash-string formatting goes through pwhash); PartialEq/Eq were likewise
34 |     // never used.
35 |     ["src/runtime/crypto/PasswordObject.rs", /\bstrum\b/],
36 |   ];
37 |   const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
38 |   expect(resurrected).toEqual([]);
                           ^
error: expect(received).toEqual(expected)

- []
+ [
+   "src/ast/nodes.rs: \bMacroError\b",
+   "src/runtime/api/YAMLObject.rs: Up::MacroError",
+   "src/runtime/api.rs: chrome_process as ChromeProcess",
+   "src/runtime/crypto/PasswordObject.rs: \bstrum\b",
+ ]

- Expected  - 1
+ Received  + 6

      at <anonymous> (/workspace/bun/test/internal/source-lints/dead-symbols-runtime-ast-deps.test.ts:38:23)
(fail) dead Rust symbols (ast, runtime) do not reappear [0.59ms]
48 | });
49 | 
50 | test("dead built-in JS code does not reappear", () => {
51 |   // bake/debug.ts: commented-out globalThis.ASSERT draft superseded verbatim
52 |   // by the live globalThis.DEBUG.ASSERT directly below it.
53 |   expe
... (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-runtime-ast-deps.test.ts
bun test v1.4.0 (3cadf9f48)

test/internal/source-lints/dead-symbols-runtime-ast-deps.test.ts:
(pass) dead Rust symbols (ast, runtime) do not reappear [33.71ms]
(pass) dead built-in JS code does not reappear [2.28ms]
(pass) unused Cargo dependency edges do not reappear [5.20ms]

 3 pass
 0 fail
 7 expect() calls
Ran 3 tests across 1 file. [2.35s]
__F:0:S:0

release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 669ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/119] gen bake.{client,server,error}.js
-> bake.client.js, bake.server.js, bake.error.js
[2/119] gen generated_host_exports.rs
generated_host_exports.rs: 93 exports (host=3, lazy=10, generic=80, rust=0); 239 extern-C blocks audited
[2/119] 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   Compili
... (truncated)
```

</details>

<details><summary>diff hotspot</summary>

```
Cargo.lock                                         |  3 --
 src/ast/nodes.rs                                   |  1 -
 src/runtime/Cargo.toml                             |  2 -
 src/runtime/api.rs                                 |  2 -
 src/runtime/api/YAMLObject.rs                      |  9 ++--
 src/runtime/bake/debug.ts                          | 11 ----
 src/runtime/crypto/PasswordObject.rs               |  6 +--
 src/spawn/Cargo.toml                               |  1 -
 .../dead-symbols-runtime-ast-deps.test.ts          | 63 ++++++++++++++++++++++
 9 files changed, 68 insertions(+), 30 deletions(-)
```

</details>

**gate history** · 1 passed · 0 rejected · iteration 0

<details><summary>evidence per changed file</summary>

```
file                                                      reads  edits  tests
Cargo.lock                                                    0      0      0
src/ast/nodes.rs                                              1      1      0
src/runtime/Cargo.toml                                        1      1      0
src/runtime/api.rs                                            1      1      0
src/runtime/api/YAMLObject.rs                                 2      3      0
src/runtime/bake/debug.ts                                     1      1      0
src/runtime/crypto/PasswordObject.rs                          1      1      0
src/spawn/Cargo.toml                                          1      1      0
…rnal/source-lints/dead-symbols-runtime-ast-deps.test.ts      0      2      0
```

</details>

<!-- robobun:evidence:end -->

---------

Co-authored-by: Alistair Smith <hi@alistair.sh>
@robobun

robobun commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

Reopened against current main as #39581. The dead code is still present there. The port resolves the ZigGlobalObject.h conflict (m_worldIsNormal is still dead), adds a direct JSPromise.h include that WorkerMessagingProxy.cpp previously got transitively through a deleted file, and drops the source-lint test per the new guidance in test/internal/source-lints. Verified with a full debug build on 6948a12.

Jarred-Sumner pushed a commit that referenced this pull request Aug 23, 2026
…cripts (#39581)

### What does this PR do?

Reopens #37149 against current main, as requested there. It deletes dead
code whose last references are already gone. Every removed symbol was
verified again on current main: zero references across src/, scripts/,
packages/, and freshly regenerated codegen output.

C++ (`src/jsc/bindings`):
- ncrypto.cpp/h: 33 uncalled methods from the ncrypto port (bytesToKey,
FIPS toggles, secure-heap helpers, X509 time/usages getters, unused AES
CTR/GCM/KW factories, BIO/Bignum constructors), the 5 named Digest
factories orphaned by the bytesToKey removal (only `Digest::FromName`
has callers), and the `DataPointer` `secure_` field plus constructor
parameters that `SecureAlloc` was the sole producer for
- DOMJIT IDL helper headers (DOMJITIDLTypeFilter.h, DOMJITIDLType.h,
DOMJITIDLConvert.h, DOMJITHelpers.h/.cpp): zero instantiations of any
template they define; include sites now pull FrameTracers.h directly
where `JITOperationPrologueCallFrameTracer` is used
- 13 empty stub files (MessagePortChannel*, MessagePortIdentifier.h,
BroadcastChannelRegistry.h, JSDOMConvertSerializedScriptValue.h,
JSDOMBuiltinConstructorBase.*) kept by an earlier cleanup only for its
own verification mechanics
- ZigGlobalObject: 19 accessors with zero callers (8 `*SinkPrototype()`
getters, `worldIsNormal`, `bunStdin`/`bunStderr`/`bunStdout`,
`KeyObjectStructure`, `JSBufferStructure`, `JSCryptoKeyStructure`,
`builtinInternalFunctions`, `performMicrotaskVariadicFunction`,
`globalProxyStructure`), the backing fields and initLater closures this
orphaned, and `jsFunctionPerformMicrotaskVariadic`
- BunString `isCrossThreadShareable`, NodeValidator
`validateArrayBufferView`, JSDOMConvertBase `convertResult`,
JSDOMConvertSequences `reserveEstimated`, EventNames
`isGamepadEventType` (declaration with no definition), ExceptionDetails
`EnumTraits`, ResourceTiming `overrideInitiatorType`, WebSocket
`hasNativeCallbacks`, PerformanceObserverCallback `hasCallback`
(never-invoked virtual pair), ScriptExecutionContext
`isDocument`/`isWorkerGlobalScope`
- io_darwin.cpp: `io_darwin_close_machport` (both cfg arms); unlike its
siblings it has no Rust-side declaration and no caller anywhere
- WorkerMessagingProxy.cpp gains a direct `#include
<JavaScriptCore/JSPromise.h>`. It got the header transitively through a
unified-source neighbor that this PR deletes.

Rust:
- jsc/bindgen.rs: `BindgenOptionalRepr` trait, `BindgenOptionalCustom`,
`BindgenExternalShared` and their impls; the bindgen codegen emitters
never name them. Also the `Optional::adopt` helper and
`ExternalSharedOptional<T>` (bun_core/external_shared.rs plus its two
re-exports) that this orphaned.
- ast/binding.rs: `BindingInit` trait and `Binding::init`; all
construction goes through `Binding::alloc` or literal struct init. Two
doc comments that pointed at `Binding::init` are updated.
- ast/runtime.rs: write-only `ImportsIteratorEntry.value` field and two
commented-out leftover fields
- runtime/webcore.rs: two unused flat re-exports
- ini/lib.rs: commented-out Zig code from the port

Scripts (invoker `.github/workflows/labeled.yml.disabled` was deleted in
#36778, or superseded):
- label-issue.ts, read-issue.ts, handle-crash-patterns.ts,
is-outdated.ts, associate-issue-with-sentry.ts
- nav2readme.ts (imports docs/nav, deleted in #24201; cannot run)
- buildkite-slow-tests.js (superseded by `ci:slowest` and
update-test-durations)
- check-node.sh, check-node-all.sh (superseded by `bun run node:test`)

Differences from #37149: the port resolves one conflict in
ZigGlobalObject.h (main replaced `JSDOMStructureMap m_structures` with
the `m_domStructures` array; `m_worldIsNormal` is still dead and stays
deleted), adds the WorkerMessagingProxy include, and drops the
dead-symbols source-lint test per test/internal/source-lints/CLAUDE.md.

Rebase notes (ab55966): main moved the ZigGlobalObject lazy-property
registration from per-field `initLater` calls into `OBJECT_OFFSETOF`
tables. The rebase re-applies the deletions in that shape: the table
entries for `m_cachedGlobalProxyStructure`, `m_JSCryptoKey`, and
`m_performMicrotaskVariadicFunction` are removed with their fields. One
deletion from #37149 is dropped:
`m_bunStdin`/`m_bunStderr`/`m_bunStdout` are live again (BunObject.cpp
reads the fields directly), so the fields and their initializers stay.
Only their unused accessor methods remain deleted.

Rebase notes (72ec6e2): parallel dead-code sweeps on main deleted
neighbors of lines this PR deletes. Resolved by checking each symbol on
current main: `BIOPointer::NewFile` and `X509View::enumUsages` still
have zero callers, so their removal stands, next to main's removal of
`NewFp`, `ifRsa`, and `ifEc`. The `performMicrotaskVariadicFunction()`
accessor removal stands next to main's removal of `performanceObject()`.

### How did you verify your code works?

- Full debug build (`bun bd`) on this branch at current main
(6948a12)
- Repo-wide greps on current main for each removed symbol, the deleted
script names, and the deleted header names return only the deletion
sites
- `bun bd test test/js/node/crypto/crypto.key-objects.test.ts`: 95 pass,
0 fail
- `bun bd test test/js/web/workers/worker.test.ts`: 4 debug-ASAN timeout
failures, identical on a main debug build, release bun passes 37/37

This PR adds no test files on purpose. Every hunk deletes unreferenced
code or keeps behavior identical (the ini hunk keeps the same expression
and drops commented-out code, the iterator hunk drops a write-only
field, the codegen hunk swaps deleted includes for FrameTracers.h). No
test can distinguish the tree before and after this change, and
test/internal/source-lints/CLAUDE.md forbids dead-symbol pin tests. The
build is the check.
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