Remove dead code from sys/windows, cli, shell, test_runner, v8 shim
Closed
RO
3mo ago+66+66+01234567890123456789-208-208-012345678901234567890123456789
Net -142 LOC (208 deleted, 66 added for the source-lint test). Each symbol was verified to have zero references across src/ and build/debug/codegen/. bun bd and bun run rust:check-all (all 10 targets) pass.
Rust
| Symbol | Why dead |
|---|---|
sys::Tag::is_windows | rg '\.is_windows\(\)' → no hits |
sys::windows::GetEnvironmentVariableW wrapper + GetEnvironmentVariableError | getenv_w and every other caller uses kernel32_2::GetEnvironmentVariableW directly |
sys::windows::translate_ntstatus_to_errno | alias of translate_nt_status_to_errno; doc said "kept for external callers" but there are none |
runtime::cli::IS_MAIN_THREAD thread_local | write-only since the crash handler switched to comparing stored OS tids via bun_crash_handler::cli_state |
runtime::cli::test::parallel::Channel::close | Drop impl handles teardown; nothing calls close() explicitly (the (*p).close() in Worker.rs is on Process) |
runtime::shell::ShellErr::{InvalidArguments, Todo} | only ever matched (8 arms), never constructed anywhere |
runtime::test_runner::sequences_const | byte-identical duplicate of sequences(); two callers switched over |
runtime::test_runner::StepResult Default impl | rg 'StepResult::default' → no hits, no ..Default::default() |
Also updates run_command.rs:1 module doc to reference exec_with_cfg (the exec forwarder it named was removed on main by #36184).
C++
| Symbol | Why dead |
|---|---|
src/jsc/bindings/JSCInlines.h | never #included via the local path; all 100+ references use the framework <JavaScriptCore/JSCInlines.h> |
v8::Local<T>::reinterpret<U>() | added in the initial V8 impl (dc2929d4e), never called; real V8's Local has no such method so addons cannot link it |
v8::shim::Handle::Handle(const ObjectLayout*) | last caller removed in #13754's HandleScopeBuffer refactor |
Verification
bun bd # ok
bun run rust:check-all # 10 ok, 0 failed
bun bd test test/internal/source-lints/dead-symbols-threading-sys-cli.test.ts # 2 pass (fails on main)
Dropped after rebase
These were in the original version of this PR but are already handled on main:
bun_core::fmt::{CountingWriter, Null},clap::SliceIterator::init,Tag::logger,RunCommand::execforwarder: removed by #36184diff_match_patch#[cfg(test)] mod tests: fixed on main (tests now compile), so not deleting
[review] gate passed · iteration 9 · 16 files touched
fails on main (without fix)
ASAN without fix: 2 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-threading-sys-cli.test.ts
bun test v1.4.0 (b04748c3c)
test/internal/source-lints/dead-symbols-threading-sys-cli.test.ts:
39 | // StepResult::default never called
40 | ["src/runtime/test_runner/Execution.rs", /pub\(crate\) fn sequences_const\b/],
41 | ["src/runtime/test_runner/bun_test.rs", /impl Default for StepResult\b/],
42 | ];
43 | const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
44 | expect(resurrected).toEqual([]);
^
error: expect(received).toEqual(expected)
- []
+ [
+ "src/sys/lib.rs: pub const fn is_windows\(self\) -> bool",
+ "src/sys/windows/mod.rs: pub enum GetEnvironmentVariableError\b",
+ "src/sys/windows/mod.rs: ^pub fn GetEnvironmentVariableW\(",
+ "src/sys/windows/mod.rs: ^pub fn translate_ntstatus_to_errno\b",
+ "src/runtime/cli/mod.rs: static IS_MAIN_THREAD:",
+ "src/runtime/cli/test/parallel/Channel.rs: pub fn close\(&mut self\) \{",
+ "src/runtime/she
... (truncated)
release without fix: 2 FAILED
bun test v1.4.0-canary.1 (1498d7b77)
test/internal/source-lints/dead-symbols-threading-sys-cli.test.ts:
39 | // StepResult::default never called
40 | ["src/runtime/test_runner/Execution.rs", /pub\(crate\) fn sequences_const\b/],
41 | ["src/runtime/test_runner/bun_test.rs", /impl Default for StepResult\b/],
42 | ];
43 | const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`);
44 | expect(resurrected).toEqual([]);
^
error: expect(received).toEqual(expected)
- []
+ [
+ "src/sys/lib.rs: pub const fn is_windows\(self\) - bool",
+ "src/sys/windows/mod.rs: pub enum GetEnvironmentVariableError\b",
+ "src/sys/windows/mod.rs: ^pub fn GetEnvironmentVariableW\(",
+ "src/sys/windows/mod.rs: ^pub fn translate_ntstatus_to_errno\b",
+ "src/runtime/cli/mod.rs: static IS_MAIN_THREAD:",
+ "src/runtime/cli/test/parallel/Channel.rs: pub fn close\(&mut self\) \{",
+ "src/runtime/shell/shell_body.rs: ^\s*InvalidArguments \{ val: ",
+ "src/runtime/shell/shell_body.rs: ^\s*Todo\(Box\),",
+ "src/runtime/test_runner/Execution.rs: pub\(crate\) fn sequences_const\b",
+ "
... (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-threading-sys-cli.test.ts
bun test v1.4.0 (b04748c3c)
test/internal/source-lints/dead-symbols-threading-sys-cli.test.ts:
(pass) dead Rust symbols (sys, cli, shell, test_runner) do not reappear [48.64ms]
(pass) dead C++ v8 shim symbols do not reappear [8.02ms]
2 pass
0 fail
2 expect() calls
Ran 2 tests across 1 file. [2.11s]
__F:0:S:0
release with fix: all passed
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped) in 692ms (unchanged)
ninja: Entering directory `/workspace/bun/build/release'
[1/22] cxx obj/src/jsc/bindings/webcore/HTTPParsers.cpp.o
[2/22] cxx obj/src/jsc/bindings/BunProcess.cpp.o
[3/22] cxx obj/unified/UnifiedSource-src_jsc_bindings_v8_shim-0.cpp.o
[4/22] cxx obj/src/jsc/bindings/bindings.cpp.o
[5/22] cxx obj/unified/UnifiedSource-src_jsc_bindings_v8-0.cpp.o
[6/22] cxx obj/unified/UnifiedSource-src_jsc_bindings_webcore-3.cpp.o
[7/22] cxx obj/unified/UnifiedSource-src_jsc_bindings_webcore-4.cpp.o
[8/22] cxx obj/unified/UnifiedSource-src_jsc_bindings_webcrypto-2.cpp.o
[9/22] cxx obj/unified/UnifiedSource-src_runtime_webview-0.cpp.o
[10/22] cxx obj/unified/UnifiedSource-src_jsc_bindings_webcore-2.cpp.o
[11/22] cxx obj/unified/UnifiedSource-src_jsc_bindings-0.cpp.o
[12/22] cxx obj/src/jsc/bindings/ZigGlobalObject.cpp.o
[13/22] cxx obj/unified/UnifiedSource-src_jsc_bindings-4.cpp.o
[14/22] cxx obj/unified/UnifiedSource-src_jsc_bindings-1.cpp.o
[15/22] cxx obj/unified/UnifiedSource-src_jsc_bindings-3.cpp.o
[16/22] gen generated_host_exports.rs
generated_host_exports.rs: 94 exports (
... (truncated)
diff hotspot
src/jsc/bindings/JSCInlines.h | 57 ---------------------
src/jsc/bindings/v8/V8Local.h | 6 ---
src/jsc/bindings/v8/shim/Handle.cpp | 6 ---
src/jsc/bindings/v8/shim/Handle.h | 2 -
src/runtime/cli/mod.rs | 12 +----
src/runtime/cli/run_command.rs | 2 +-
src/runtime/cli/test/parallel/Channel.rs | 33 ++----------
src/runtime/shell/Builtin.rs | 12 -----
src/runtime/shell/shell_body.rs | 22 --------
src/runtime/test_runner/Execution.rs | 6 ---
src/runtime/test_runner/bun_test.rs | 5 --
src/runtime/test_runner/debug.rs | 2 +-
src/runtime/test_runner/jest.rs | 2 +-
src/sys/lib.rs | 9 ----
src/sys/windows/mod.rs | 40 ---------------
.../dead-symbols-threading-sys-cli.test.ts | 58 ++++++++++++++++++++++
16 files changed, 66 insertions(+), 208 deletions(-)
gate history · 4 passed · 1 rejected · iteration 9
evidence per changed file
file reads edits tests
src/jsc/bindings/JSCInlines.h 1 0 0
src/jsc/bindings/v8/V8Local.h 2 2 0
src/jsc/bindings/v8/shim/Handle.cpp 2 2 0
src/jsc/bindings/v8/shim/Handle.h 2 2 0
src/runtime/cli/mod.rs 4 4 0
src/runtime/cli/run_command.rs 5 5 0
src/runtime/cli/test/parallel/Channel.rs 5 5 0
src/runtime/shell/Builtin.rs 2 2 0
src/runtime/shell/shell_body.rs 3 2 0
src/runtime/test_runner/Execution.rs 2 2 0
src/runtime/test_runner/bun_test.rs 3 2 0
src/runtime/test_runner/debug.rs 2 2 0
src/runtime/test_runner/jest.rs 2 2 0
src/sys/lib.rs 2 2 0
src/sys/windows/mod.rs 2 2 0
…nal/source-lints/dead-symbols-threading-sys-cli.test.ts 4 9 0