Repository navigation
Conversation
…uild scripts
Delete items that nothing uses on any target:
- StringHashMap::{new_in, put_borrowed, get_or_put_borrowed}, and the
From<&'static [u8]> impl for StringHashMapKey that only they used
- bun_core::strings::split_once
- eight unused libuv extern declarations and one kernel32 declaration
- the isGithubAction and endGroup re-exports in scripts/build/ci.ts
- the per-dependency re-export block in scripts/build/deps/index.ts
- a loop in scripts/run-clang-format.sh that sets a variable nothing reads
|
Status: the diff is ready for review.
No item in this diff is deleted by another open pull request. This PR adds no test on purpose. Every removed line is unreferenced, so no behavior changes and no test can observe a difference. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (8)
💤 Files with no reviewable changes (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. WalkthroughThe pull request removes unused CI exports, dependency re-exports, Rust utility APIs, and Windows FFI declarations. It also simplifies clang-format check configuration lookup and updates ChangesPublic surface cleanup
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This cleanup removes unused APIs and declarations while retaining the owned-key StringHashMap behavior; no current merge-readiness risk remains. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
The automated review reports no actionable comments, so there is nothing to change. One correction to its walkthrough: check mode in CI so far: Format, Lint JavaScript, Source lints, cargo clippy, and lol-html cargo test pass. Buildkite build 110036 is in progress. |
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline finding, I checked that the removed StringHashMap borrowed-key fast paths have no remaining callers — the parser's declare_symbol / scope-hoisting sites the deleted doc comments named as the hot path were already migrated (only a historical comment in src/js_parser/p.rs:5142 remains), and Scope::EMPTY still folds as a const via Members::EMPTY (scope.rs:127). Also confirmed all four deps/index.ts importers take allDeps only, and isGithubAction/endGroup still live in scripts/utils.mjs where their callers import them.
Extended reasoning...
Verified the load-bearing deletions have no remaining consumers: grepped for put_borrowed/get_or_put_borrowed across src/ (one hit, a historical comment in p.rs), confirmed Members::EMPTY is a real const at scope.rs:127 so the updated doc comment is accurate and Scope::EMPTY remains a compile-time value, and confirmed the four scripts/build/deps/index.ts importers (bun.ts, clean.ts, depVersionsHeader.ts, prefetch-deps.ts) import allDeps only. The clippy.toml stale-reference issue is covered by the inline comment.
|
Updated 11:08 PM PT - Sep 3rd, 2026
✅ @robobun, your commit 5805d922965203cd7a1e2de759431fba36c0b7c8 passed in 🧪 To try this PR locally: bunx bun-pr 41335That installs a local version of the PR into your bun-41335 --bun |
clippy.toml names bun_core::strings::split_once as the replacement for str::split_once, str::splitn, and bstr::ByteSlice::split_once_str.
|
The review finding is addressed in 5805d92. The rest of the review needs no change. It confirms that the removed |
There was a problem hiding this comment.
LGTM — thanks for keeping strings::split_once; the clippy.toml disallowed-methods entry now stays consistent.
What was reviewed:
- Grepped for callers of every removed symbol:
deps/index.tsimporters (4) all takeallDepsonly;build.ts(soleci.tsimporter) doesn't useendGroup/isGithubAction. - Removed libuv/Win32 externs: remaining hits are independent local declarations (
napi_body.rs,Progress.rs,bun_core/windows_sys.rs) or a same-named Rust fn inspawn_sys, not references to the deleted externs. Scope::EMPTYalready usesMembers::EMPTY, so the doc-comment edit andStringHashMap::new_inremoval are consistent; no callers ofput_borrowed/get_or_put_borrowedremain (one historical comment inp.rsonly).
Extended reasoning...
Overview
Pure dead-code removal across seven files: two TS build-script re-export blocks, a no-op shell loop, three unsafe StringHashMap entry points plus a supporting From impl, eight Windows-only libuv extern declarations, and one Win32 kernel32 extern. The only added lines are a doc-comment fix in scope.rs and a shortened doc comment on get_or_put. The second commit reverts the strings::split_once deletion in response to the earlier inline comment about clippy.toml:75 referencing it.
Security risks
None. Nothing is added; only unreferenced declarations, re-exports, and unsafe helper methods with no callers are deleted. No auth, crypto, input-parsing, or user-facing behavior is touched.
Level of scrutiny
Low-to-moderate — the risk with dead-code PRs is a false positive (something still referenced under a cfg gate or via re-export). I grepped every removed identifier across src/ and scripts/: the libuv symbols that still appear (uv_getrusage, uv_disable_stdio_inheritance, uv_buf_init, SetConsoleCursorPosition, etc.) each have their own local extern block or are a distinct Rust function at the hit site, not a use of the deleted libuv_sys/windows_sys declarations. Scope::EMPTY was confirmed to use Members::EMPTY, so removing StringHashMap::new_in is safe and the updated doc comment is accurate. The four importers of deps/index.ts and the sole importer of build/ci.ts were checked directly.
Other factors
No CODEOWNERS paths match the changed files. The prior review's single concern was addressed by commit 5805d92. The PR description's verification methodology (#[deprecated] probes across seven target configs plus rust:check-all) is the right approach for cfg-gated crates, and spot-checking its results found no counterexamples.
|
The second review finds nothing to change, and no review thread is open. CI on 5805d92: Buildkite build 110042 is still running. 154 jobs pass so far, and none fail. |
### Problem - 49 hand-written trait impls across 12 crates have no user: no call, and no bound that needs them. - rustc's `dead_code` lint exempts trait impls, so the workspace's deny lints never report them. ### Fix - Delete the 49 impls and `hash_array_list` (`src/css/generics.rs`), whose only caller was a removed impl. 25 files, 436 lines removed. - Candidates come from the linker: in a relink of the debug build with `--gc-sections`, an impl block with no kept function address is a candidate. The compiler decides next: an impl that a bound, a supertrait, another target, or a unit test needs does not compile away, so it stays. That kept 128 of 233 candidates. - 56 more stayed by choice: open PRs use them, docs describe them, or they are std ergonomics impls on shared containers. See the Notes. - Verified: `bun run rust:check-all` (12 targets), `cargo check --release` (3 targets), `cargo check --tests`, `cargo clippy`, `bun bd`, 11 test files, and a scan of all open PRs for users. ### Background - To rustc a trait impl is always reachable: generic code could call it. Only a whole-program view shows that nothing does. - The debug build uses opt-level 0 and one section per function, so `--gc-sections` drops every function with no caller. Callers in generic instantiations and macro-expanded code count. - That link proves linux only. `cargo check` covers the other targets. - #39795 removed 92 impls this way. <details><summary>Notes</summary> **Removed impls, by file** - `src/ast/e.rs` - `impl From<f64> for Number` - `src/bun_alloc/baby_vec.rs` - `impl<'a, 'b, T: Copy> Extend<&'b T> for BabyVec<'a, T>` - `impl<'a, 'b, T> IntoIterator for &'b BabyVec<'a, T>` - `impl<'a, 'b, T> IntoIterator for &'b mut BabyVec<'a, T>` - `impl<'a, T> core::borrow::Borrow<[T]> for BabyVec<'a, T>` - `impl<'a, T> AsRef<[T]> for BabyVec<'a, T>` - `src/bun_alloc/lib.rs` - `impl<const N: usize> BSSAppendable for [&[u8]; N]` - `src/bun_core/atomic_cell.rs` - `unsafe impl<U> Atom for *const U` - `src/bun_core/fmt.rs` - `impl From<InvalidCharacter> for crate::CrateError` - `src/bun_core/output.rs` - `impl<T: fmt::Display> FmtTuple for &[T]` - `src/bundler/Chunk.rs` - `impl core::ops::Index<usize> for CompileResultSlots` - `src/bundler/bundle_v2.rs` - `impl Ord for StableRef` - `impl PartialOrd for StableRef` - `src/collections/array_hash_map.rs` - `impl<K, V, C, A: MapAllocator> ArrayHashMapExt for ArrayHashMap<K, V, C, A>` - `src/css/generics.rs` - `impl<'bump, T: DeepClone<'bump>> DeepClone<'bump> for &'bump T` - `impl<T: CssEql, const N: usize> CssEql for [T; N]` - `impl CssHash for ()` - `impl<T: CssHash, const N: usize> CssHash for [T; N]` - `impl<'bump, T: CssHash> CssHash for ArrayList<'bump, T>` - `impl CssHash for bun_ast::Loc` - `impl<T: IsCompatible, const N: usize> IsCompatible for [T; N]` - `impl<'bump, T: ToCss> ToCss for ArrayList<'bump, T>` - `impl ToCss for CustomIdent` - `impl ToCss for DashedIdent` - `impl ToCss for Ident` - `src/css/media_query.rs` - `impl crate::generic::ToCss for MediaList` - `src/css/properties/mod.rs` - `impl crate::generics::ParseWithOptions for css_values::length::Length` - `impl<S, const P: u8> crate::generics::Parse for GenericBorder<S, P>` - `src/css/rules/supports.rs` - `impl crate::generics::CssEql for SupportsCondition` - `impl css::generic::ToCss for SupportsCondition` - `src/css/selectors/parser.rs` - `impl<Impl: SelectorImpl> Default for GenericSelector<Impl>` - `impl<Impl: BunSelectorImpl> CssEql for GenericSelectorList<Impl>` - `impl<Impl: BunSelectorImpl> CssHash for GenericSelectorList<Impl>` - `impl<Impl: BunSelectorImpl> CssEql for GenericComponent<Impl>` - `impl<Impl: BunSelectorImpl> CssHash for GenericComponent<Impl>` - `src/css/values/alpha.rs` - `impl crate::generics::CssHash for AlphaValue` - `src/install/lockfile/lockfile_json_stringify_for_debugging.rs` - `impl<const N: usize> JsonScalar for &[u8; N]` - `src/install/resolution.rs` - `impl Default for Tag` - `src/install_types/resolver_hooks.rs` - `impl<I: VersionInt> Default for ResolutionValue<I>` - `impl Default for Resolution` - `src/jsc/JSPropertyIterator.rs` - `impl IntoIterObject for *const JSObject` - `src/jsc/JSValue.rs` - `impl FromAny for ()` - `impl FromAny for &str` - `impl<T: FromAny> FromAny for Option<T>` - `src/jsc/host_fn.rs` - `impl<T> IntoHostConstructReturn for *mut T` - `src/react_compiler/hir/mod.rs` - `impl From<FloatValue> for f64` - `src/runtime/bake/DevServer.rs` - `impl From<OpaqueFileId> for OpaqueFileIdOrOptional` - `src/runtime/error.rs` - `impl From<Error> for bun_jsc::CrateError` - `src/tcc_sys/tcc.rs` - `impl<ErrCtx> Default for Config<ErrCtx>` **Candidates that stayed (184 of 233)** - 128: the workspace does not compile without the impl (a bound, a supertrait, another target, or a unit test needs it). - 8: open PRs use them. The six `SmallList` impls (`Deref`, `DerefMut`, `IntoIterator` x2, `FromIterator`, `Extend`) for #39497, #38692 and #36605. `Default for Wyhash` for #40372. `AsRef<[u8]> for Utf8Bytes` for #40708. This branch merged with #39497, #38692 and #40708 passes `cargo check --workspace`. #36605 and #40372 conflict with main on their own. - 19: std ergonomics impls on widely shared types. This is a design call, so it needs a maintainer decision and its own PR: `Interned` (`Deref`, `AsRef<[u8]>`, `Borrow<[u8]>`), `ZStr` (`AsRef<ZStr>`, `PartialEq<[u8]>`, `PartialEq<&[u8; N]>`), `StoreStr` (`PartialEq<[u8]>`), `StoreSlice` (`AsRef<[T]>`, `From<&[T]>`, `From<ArenaVec>`), `IntoIterator for &HashMap` and `&mut HashMap`, `BoundedArrayAligned` (`Deref`, `DerefMut`, `fmt::Write`), `AsRef<[T]> for RawSlice`, `Deref for ArenaString` (also the only caller of `ArenaString::as_str`), `Display for GenericIndex`, `Display for CowSliceZ`. - 21: docs or comments describe the impl as part of a design. `ArrayHashContext<Box<[u8], A>> for BoxedSliceContext<C>` (its doc comment records it as the fix for lookups reached through `Deref`), `Default for Ordinal` (the default is `INVALID`, not 0), `IntoLogWrite for &mut W`, `ThrowFmtArgs for fmt::Arguments`, `PoolStorage for UnwiredStorage`, `StringBuilder for semver_string::Builder`, `fmt::Write for FmtAdapter`, `AsFd for &File`, and the css blanket impls that the `css_derive` module docs and the `Parse` section of `src/css/generics.rs` name (`Option<T>`, `SmallList`, `bool`, `str`, `[u8]`, `[T]`, `Size2D`, `Rect`). - 6: next to a hunk of an open dead-code PR (#40690, #41335, #43010, #42278), left alone to avoid a conflict. - 2: the removal leaves something else half-used. See the follow-up list. **Method details** - Link: the debug link command from `build.ninja` plus `-Wl,--gc-sections`. `-rdynamic`, `--dynamic-list` and the version script stay, so the exported NAPI/V8/uv surface is still a root. - Liveness: `llvm-nm` lists the 669,524 kept function symbols and `llvm-symbolizer` maps each address to `file:line`. An impl block is a candidate when no kept address falls inside it and a rust-analyzer SCIP index shows that linux compiles every method in it. - Limit of the finder: it reads impl blocks from source text. Impls that a `macro_rules!` type list generates are not candidates, so unused arms of such lists are not in this PR. - Restore loop: delete all candidates, run `cargo check --workspace --keep-going --message-format=json`, put back each impl that an error names, repeat until clean. Targets in the loop: linux-gnu, windows-msvc, darwin, freebsd, android, musl, then `--tests`. - Method resolution: on linux the link proves that no call to a removed impl remains, so no call can resolve differently. On other targets a call that used a removed impl fails to compile. - Open PRs: main has no merge queue, so a green PR that uses a removed impl would break main when it merges. I fetched the heads of all 5474 open non-draft PRs, took the Rust lines each one adds against its merge base, and searched them for the types and traits of the 49 impls. No PR uses one. - Base: main at 18fe86e. The liveness data is from cf71211. The commits between them do not touch the 25 files, and every check above ran again on 18fe86e. - `cargo check --workspace --tests` reports one error, `src/bundler/options.rs:2328` (`expected ContentHash, found integer`). Clean main has the same error. This PR does not touch it. - Three tests fail in the local debug build with and without this change: `ffi.test.js` "FTL-compiled call site" (5 s timeout under ASAN), and two `serve.test.ts` tests that depend on the container (root can bind low ports, loopback check). **Other scans in this run** - Free functions, inherent methods, types, consts and statics: a name scan, the linker scan, and a rust-analyzer zero-reference scan for linux, windows and darwin. Every hit was platform code with a caller on another target, test-only code, or a deletion that an open PR already carries. - Also clean or already claimed: `.rs` files outside every mod tree, unused Cargo dependencies, extern declarations without a Rust caller, commented-out code in C++/TS, unused `src/js` modules and internal exports, linker-dropped C++ functions in `src/jsc/bindings`. **Follow-up candidates, not in this diff** - 25 hand-written `Debug` impls that nothing formats. They are a debugging aid, so this PR keeps them. - `Clone for JsPoster` has no caller, and it is the only reader of the `JsPosterVTable::clone` slot. Removing both is a small refactor in `src/event_loop` and `src/jsc/VmHandle.rs`. - `Display for ErrorLocation` (`src/css/error.rs`) has no caller, and it is the only reader of `ErrorLocation::filename`. - The 19 std ergonomics impls above, if a maintainer wants shared containers to go through inherent methods only. - `Bun__napi_get_version` in `src/jsc/bindings/napi.cpp` has no caller. - The class generator emits `<Type>Class__call` shims for classes that set `call: true` and `noConstructor: true` (the seven `Expect*` matchers in `jest.classes.ts`). Nothing references those shims. </details>
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-09-04. The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR. |
Problem
StringHashMapmethods and oneFromimpl, nine extern declarations, and three blocks in the build scripts.dead_code = "deny"cannot report them. They arepubitems, trait impls, or extern declarations.Fix
#[deprecated]attribute. rustc reports every use of a deprecated item in every crate, and it does not change name resolution. No check reported a use of these items.bun bdbuilds.bun run rust:check-allpasses on all 12 targets.test/internal/source-lints/passes (172 tests).Background
bun_codegen_embed,bun_debug, andbun_asanare cfgs thatscripts/build/rust.tssets per profile. A plaincargo checkdoes not compile code under them.zstd::inflate_embeddedlooks dead without them, so it stays.#[host_fn]pastes names, so a name that appears as a suffix of another identifier is kept.clippy.tomlnamesstrings::split_onceas the replacement for banned methods, so it stays.Notes
Method. Candidates came from two passes.
pubin the crate topub(crate), thencargo check -p <crate>. rustc then lists the items that the crate itself does not use. This ran for linux, windows x64, and macOS arm64.pub, then putpubback on each item that a compile error names. This converged after 75 rounds.#[allow(dead_code)]was stripped for the last check.That gave about 20,000 candidates. Each got a
#[deprecated(note = "DEADPROBE:<id>")]attribute, and the seven checks ran with--force-warn=deprecated. A candidate is dead only when every reported use sits inside another dead candidate.Why this is small. About 20 open dead-code pull requests hold most of what these passes find. The candidate list skips every item that those pull requests delete.
Tag::is_windowsis dead, but #40172 deletes it.Removed
src/collections/array_hash_map.rs:StringHashMap::{new_in, put_borrowed, get_or_put_borrowed}, andimpl From<&'static [u8]> for StringHashMapKey. Onlyget_or_put_borrowedcalledentry_ref, which needs that impl.Scope::EMPTYusesMembers::EMPTYnow, so the comment insrc/ast/scope.rsnames that instead.src/libuv_sys/libuv.rs:uv_default_loop,uv_now,uv_handle_size,uv_buf_init,uv_getrusage,uv_os_getpriority,uv_cwd,uv_disable_stdio_inheritance. The N-API symbol list innapi_body.rshas its own declarations.src/windows_sys/externs.rs:SetConsoleCursorPosition.scripts/build/ci.ts: theisGithubActionandendGroupre-exports. Callers import them fromscripts/utils.mjs.scripts/build/deps/index.ts: theexport { boringssl, ... }block. The four importers takeallDepsonly.scripts/run-clang-format.sh: a loop in check mode that setsdir. Nothing readsdir.Kept on purpose
bun_core::strings::split_once. No code calls it, butclippy.tomlnames it in threedisallowed-methodsreasons. The first commit removed it, and the second commit restores it.h2::wire::MAX_STREAM_ID. Thenode:http2engine is not wired up yet.WaitPidResultstub.src/spawn/lib.rsre-exports it. A deprecated item in auseis not reported.scripts/p-limit.mjslimitFunction. The file is a copy of p-limit.Probably dead, not in this diff.
scripts/gamble.ts,scripts/github-metrics.ts,scripts/lldb-inline.shwithscripts/lldb-inline-tool.cpp, andscripts/packer/build-image.pkr.hcl. Nothing references them, but a person can run them by hand.Scanned with nothing to add.
src/js. Every builtin is reachable, and the few unused exports mirror Node.js constants.Tests (
bun bd test):test/internal/source-lints/(172 pass),test/js/bun/transpiler/repl-transform.test.ts, andtest/bundler/bundler_naming.test.ts(63 pass, 3 todo).