Repository navigation
Conversation
Nine trait impls, StoredTrace::from, and the default_of_module line of resolutions! have no user. The impls are six Spanned impls in bun_format, Default for Session in bun_sema, and PartialEq<crate::Error> for ForTarballError and Display for Id in bun_install. bun_lint_react does not use its bun_glob dependency.
|
Status
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe pull request removes several trait implementations and APIs, plus the ChangesFormatter span implementations
Installer trait implementations
Stored trace conversion
Semantic APIs
React lint dependency
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
LGTM — pure deletion of unused impls, one function, one macro-generated wrapper, and one dependency edge; each removed item was checked for remaining users.
What was reviewed:
- The six removed
Spannedimpls: everySpanned-bounded consumer inbun_format(JoinNodesBuilder::entries,entries_with_trailing_separator,FormatNodeWithoutTrailingComments,write_array_node,get_cached_element,text_for,speculate_will_break) is only ever handed AST handles or otherFormat*wrappers;f.join_with(..).entries(..)has noSpannedbound, soidentifier(part)atsrc/format/js/print/ts_types.rs:26still compiles. All six files importSpan/Spannedviacrate::prelude::*, so no unused-import warning. Files::default_of_module: the two remainingself.default_of_modulecalls atsrc/sema/program.rs:2003and:2033are insidetrait Resolve's default methods and resolve toResolve::default_of_module, not the deleted forwarding wrapper; no other crate names it.Display for IdandPartialEq<crate::Error> for ForTarballError: no{}/to_stringformatting of aTask::Idand no==againstcrate::Erroranywhere undersrc/install;Default for Session: every construction site usesSession::new()andnew_without_defaultis allowed at the workspace level;StoredTrace::fromhas no caller repo-wide andStackTraceis still used elsewhere inGlobal.rs.
Extended reasoning...
The change is a single 81-line, deletion-only commit across 12 files that removes trait impls, one inherent function, one macro-generated forwarding method, and the unused bun_glob dependency of bun_lint_react (with the matching Cargo.lock line). It touches no security-sensitive surface: no input parsing, auth, crypto, or allocation paths change, and no runtime behavior changes. Approval was decided by confirming via repo-wide search that each deleted item has no remaining caller, generic-bound use, or format-string use, that the files rely on glob prelude imports so no unused-import warning is introduced, and that no CODEOWNERS entry covers the changed paths. The compile could not be run in this session, so the verification is by reading every consumer of the relevant traits and types.
|
Updated 3:05 PM PT - Oct 15th, 2026
❌ @robobun, your commit 8efb153 has some failures in 🧪 To try this PR locally: bunx bun-pr 45402That installs a local version of the PR into your bun-45402 --bun |
Problem
rustc'sdead_codelint exempts trait impls andpubitems, so the deny lints do not report them.Spannedimpls inbun_format,Default for SessionandFiles::default_of_moduleinbun_sema,PartialEq<crate::Error> for ForTarballErrorandDisplay for Idinbun_install, andStoredTrace::frominbun_core.bun_lint_reactlistsbun_globas a dependency and does not use it.Fix
--gc-sectionsdrops every function that nothing reaches. The compiler decides next: a candidate stays deleted only if every configuration compiles without it.bun bd,bun run rust:check-all(12 targets),cargo check --workspace --all-targets,cargo clippy --workspace --no-deps. Five test files undertest/clipass (see Notes).Background
rustca trait impl is always reachable, because generic code could call it. Only a whole-program view shows that nothing does.resolutions!insrc/sema/program.rsgenerates one forwarding method onFilesfor each signature in its list. Thedefault_of_moduleline generated a public method that nothing calls. TheResolvemethod of the same name stays.StoredTrace::fromlost its last caller in install: consolidate the open package manager pull requests #44968.Downsides
Behaviour change: none
Notes
Removed, by file
src/bun_core/Global.rsStoredTrace::fromsrc/format/js/format.rsimpl Spanned for FormatIdentifierimpl Spanned for FormatDeclaration<'_>src/format/js/print/binary_like_expression.rsimpl Spanned for BinaryLikeExpression<'_>src/format/js/print/object_pattern_like.rsimpl Spanned for ObjectPatternLike<'_>src/format/js/print/template.rsimpl Spanned for TemplateExpression<'_>src/format/js/utils/conditional.rsimpl Spanned for Operand<'_>src/install/NetworkTask.rsimpl PartialEq<crate::Error> for ForTarballErrorsrc/install/PackageManagerTask.rsimpl core::fmt::Display for Idsrc/sema/session.rsimpl Default for Sessionsrc/sema/program.rsdefault_of_moduleline ofresolutions!src/lint/react/Cargo.toml,Cargo.lockbun_globdependency ofbun_lint_reactMethod
build.ninjaplus-Wl,--gc-sections -Wl,--print-gc-sections. The export list and the version script stay, so the exported NAPI, V8 and uv surface is still a root.#[deprecated], andcargo check --force-warn deprecatedlisted every use site for linux, windows and darwin. One function has no use on any target:StoredTrace::from. The others have a caller on another target, in a const context, in a release-only path, or in a test.Debugimpls, which Remove dead code: 49 trait impls nothing uses, across 12 crates #43664 kept as a debugging aid. OneCloneimpl and oneDropimpl were never candidates. Six stayed because a doc comment gives them a purpose or because they are the only reader of a field.cargo check --workspace --all-targets --keep-going, put back each impl that an error names, repeat. Seventeen came back. Three more stayed by choice (see the follow-up list). Nine are in this diff.--all-targets: linux,x86_64-pc-windows-msvc,aarch64-apple-darwin,--release, linux with--cfg bun_debug --cfg bun_asan --cfg socket_fault_injection, and--releasewith--cfg bun_codegen_embed.bun_lint*,bun_format*,bun_sema*): in a scratch worktree everypubfn, const, static and field whose name no other crate mentions becamepub(crate), so thatdead_codecould judge it. That foundFiles::default_of_module, which mordant'sunused_pubskips because a macro generates it.mordant-baseline.tomlis unchanged. Theunused_pubcount forsrc/bun_core/Global.rswas already 1 before install: consolidate the open package manager pull requests #44968 removed the caller ofStoredTrace::from, so that entry is for another item.Tests
--timeout 60000:test/cli/format/format.test.ts(1015 pass, 44 skip),test/cli/format/sort-imports.test.ts(64 pass),test/cli/lint/bun-rules.test.ts(100 pass),test/cli/check/entry-points.test.ts(160 pass),test/cli/install/bun-install-offline.test.ts(11 pass). No failure.Self-review
Scanned and clean, or already claimed
.rsfile is in a mod tree.unused_macro_rulesover the workspace: one unused arm (define_colorspacerule 5 insrc/css/values/color.rs, one line, in a file that Remove dead code from bun_parsers, bun_core, bun_css, and the base64-js fallback #41004 changes).bun_js_parserinbun_ini,bun_coreinbun_platform,scopeguardinbun_ptr). Remove dead code from bun-uws, bun-usockets, the require.extensions FFI, and unused Cargo dependencies #40294 already removes them.Follow-up candidates, not in this diff
Debugimpls that nothing formats, 24 of them inbun_lintandbun_format.Display for Difference(src/format/verify.rs) has no caller. It is the only reader of the fields ofDifference.impl StaticallyNamedforIdent,PatandNode(src/lint/types/utils/type_or_value_specifier.rs) have no caller. The doc comment ofvalue_matches_specifiernames them as accepted inputs.BaseTypeOfClassMember::heritage_tokenandFinallyCall::on_finallyinsrc/lint/types/utilsare written and never read. They mirror the typescript-eslint utilities that the files port.Default for SendWindowandDefault for RecvWindow(src/runtime/api/bun/h2/flow_control.rs) have no caller. Remove 7 stale module-level dead_code escapes from the node:http2 engine and react_compiler::hir #42278 changes that file.