Repository navigation
Conversation
Delete two `Spanned` impls that nothing uses (`FormatExpr` and `FormatSpecifier`) and `Bun__napi_get_version`, which has no caller.
|
Updated 12:05 AM PT - Oct 17th, 2026
❌ @robobun, your commit 83386fc has 2 failures in
The baseline build contains instructions not available on Static scan violations
|
|
Status: ready for review. The diff is green. CI is red on two lanes that this change does not touch. CI on the head commit
How the dead code was confirmed:
PR: #45420 |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe change removes two ChangesFormatter span implementations
N-API version function
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
Problem
bun_formathave no user:Spanned for FormatExpr(src/format/js/format.rs) andSpanned for FormatSpecifier(src/format/js/print/import_declaration.rs). rustc'sdead_codelint exempts trait impls, so the deny lints do not report them.Bun__napi_get_version(src/jsc/bindings/napi.cpp) has no caller.Fix
spanmethod. A relink with--gc-sectionsdropsBun__napi_get_version, andrgfinds only its definition. It is not insrc/symbols.txtorsrc/symbols.def.bun run rust:check-all(12 targets),cargo check --workspacewith--all-targetsand--release,bun bd,test/cli/format/format.test.ts, and thenapi_get_versiontests oftest/napi/napi.test.ts.Background
Spanned(bun_lint::span) gives a value its source range.FormatExprandFormatSpecifierare private wrapper types of the formatter. The formatter asks the wrapped node for its range, not the wrapper.Spannedimpls of the same kind. These two have no symbol in any object file, because no crate instantiates them, so a scan for dropped sections does not list them.Downsides
Bun__napi_get_version.Behaviour change: none
Notes
How the candidates were found
-Wl,--gc-sections -Wl,--print-gc-sections. It drops 13,148 Rust function sections and 380 functions in handwritten C++ objects.pubitems got a temporary#[deprecated]mark (not committed). rustc then reports each use. Passes: the 12 CI targets,--all-targetson three of them,--release, and--cfg bun_asan --cfg bun_debug --cfg socket_fault_injection.cargo check --workspace, put back each impl that an error names, repeat.cargo mordantat the pinned rev with an empty baseline, on main and on the candidates. No file on main is over itsunused_pubbaseline.Checks in detail
test/cli/format/format.test.tswith the debug ASAN build: 1015 pass, 0 fail with--timeout 120000. With the default 5 s timeout, 15 tests that start a JavaScript config loader time out on this machine.test/napi/napi.test.ts -t napi_get_version: 2 pass.cargo clippy -p bun_format --no-deps: clean.What the scan found and where it went
pubitems have no use on any target. Open dead-code PRs already delete 138 of them.bun_zstd::inflate_embeddedandinflate_embedded_nul(bun_codegen_embed), two functions insrc/bun_core/code_generation.rs(bun_disallow_code_generation_from_strings).src/codegen/generate-classes.ts:host_fn_this_value,host_fn_setter.src/errno/windows_errno.rs,Tag::fchownat, the macOSO::EVTONLY,fault_inject::SHUTDOWN,posix::mode_t.ArrayListAlignedIn::{init, init_capacity, from_unmanaged, append_assume_capacity}. Their only user issrc/jsc/bindgen.rs, which an open PR deletes.O::NOATIME(Remove libuv on Windows #42819),O::NOFOLLOW_ANY(archive: refuse symlinks in the destination with openat2(RESOLVE_NO_SYMLINKS) and O_NOFOLLOW_ANY #41750),posix::s_isdir(fs.watch: watch symlink entries of a recursive tree on Linux #43090, bun patch: keep the copy of a global store package in the project #43556), the Windowsumask(Remove libuv on Windows #42819, ini: reject a source of 2 GiB or more in Parser::parse instead of aborting on an int cast #45206), the WindowsUTIME_NOW(Remove libuv on Windows #42819, shell(touch): let the OS pick the time so that write access is enough #44937),SSL_set0_verify_cert_store(Add ForeignRef<T> and make FetchHeaders the owned handle #33820, Fold CppWebSocketRef onto ForeignRef with a release marker #33889).StoredTrace::from, which Remove dead code from bun_format, bun_sema, bun_install, and bun_core #45402 removes.Debug) that were added since the base of Remove dead code: 49 trait impls nothing uses, across 12 crates #43664 have no kept function in the link.Locatedimpls that the trait's doc comment lists, threeStaticallyNamedimpls,Emit for f64andSpanned for Targetinbun_lint(the API that lint rules are written against), andAsAstNodes for Classinbun_format(one of a family with one impl per handle kind).Hash,Clone,PartialEq,Default,From,Deref,Display). This PR removes none of them, as in Remove dead code: 49 trait impls nothing uses, across 12 crates #43664.extern "C"functions. Open PRs delete 86. The rest have a caller on macOS or Windows, are--wrapshims, are vendored llhttp, or are in the follow-up list..rsfiles outside every mod tree, unused Cargo dependencies (cargo'sunused_dependencieslint on every target),src/js(tsc --noUnusedLocalsreports 5 locals),scripts/,src/codegen/,packages/.Follow-up candidates, not in this diff
hawk.toml: 12[[override]]entries name enum variants that no longer exist (11NapiStatus::*, andserialized_failure::ErrorKind::JsError). They touch the hunk of Remove dead code from libtcc1.c, four C++ preprocessor conditions, JSPropertyIterator, and hawk.toml #44126.ResourceTiminghas a private constructor and no caller, soPerformanceResourceTiming::create, its constructor,ResourceTiming::populateServerTiming,PerformanceServerTiming::createandNetworkLoadMetrics.cppare unreachable (about 159 lines). Remove dead code from bun_core, the JSC bindings, the debugger, and 24 other crates #41385 and Remove dead code from the build scripts, the vscode and debug-adapter packages, the bake overlay, and two WebCore files #40122 edit the same functions.Bun__allocUint8ArrayForCopy(every call ofArrayBuffer::allocpassesJSType::ArrayBuffer) andBun__JSBigIntStatsObjectConstructor(onlyStatsSmall::get_constructorhas a caller). A removal edits live generic code.mordant-baseline.toml: once Remove dead code from bun_format, bun_sema, bun_install, and bun_core #45402 lands,"unused_pub:src/bun_core/Global.rs" = 1is stale. mordant reports 0 findings in that file withoutStoredTrace::from.Debugimpls that nothing formats, mostly inbun_lintandbun_format. They are a debugging aid, so they stay.