Skip to content

Remove dead code: 17 log scopes nothing logs to and four fields nothing reads, in 10 crates - #44050

Open
robobun wants to merge 1 commit into
mainfrom
robobun/a11e46ad/dead-code-sweep
Open

robobun wants to merge 1 commit into
mainfrom
robobun/a11e46ad/dead-code-sweep

Conversation

@robobun

@robobun robobun commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Behaviour change: none

Problem

  • 17 declare_scope! log scopes have no scoped_log! user, four struct fields have no reader, and two empty cfg modules have no user.
  • No lint reports them. rustc does not lint an item that the macro of another crate expands, a pub field, or a name that starts with _.

Fix

  • Remove the 17 scopes and the two empty modules in napi_body.rs (Notes). Each user of those names is behind the opposite cfg.
  • Remove the fields CommandLineArguments.lockfile, Runtime::Features.jsx_optimization_inline with the local can_be_inlined, DebugOptions.output_file, and ArgumentsSlice::_vm.
  • Verified: bun bd, bun run rust:check-all (12 targets ok), test/internal/source-lints/, and seven test files (Notes).
  • Self-reviewed: 7 concerns raised, 7 addressed (Notes).

Background

Downsides

  • None found. cargo check on 12 targets proves that no code names a removed item. No open PR adds a use of a removed scope.
Notes

Removed

  • Scopes: JSC (bun_core/Global.rs, mark_binding! logs to the hand-written JSC_SCOPE), STR, Bundle and scan_counter (outer pair), Store, hot_reloader, SYS (spawn/stdio.rs, with the log! macro that define_scoped_log! made), GetHostByAddrInfoRequest, CAresNameInfo, GetNameInfoRequest, CAresReverse, CAresLookup, quic_session, S3Client, S3Stat, AWS, uws (uws_sys/socket.rs, us_socket_t.rs and Timer.rs have their own).
  • CommandLineArguments.lockfile: nothing reads or sets it.
  • jsx_optimization_inline: always false. can_be_inlined in parse_jsx.rs was assigned and never read.
  • DebugOptions.output_file: its only source was a local that is always None.
  • ArgumentsSlice::_vm: always null.
  • This is the commit that Remove dead code from the class generator: the unreachable DOMJIT paths #43840 lists as "verified and held for the next run", plus the SYS scope, minus the items below.

Left out, because an open PR holds the same lines

Tests with the debug build, all pass

test/bundler/transpiler/jsx-production.test.ts (32), test/bundler/transpiler/jsx-tsconfig-react-jsx.test.ts (7), test/js/node/dns/dns-resolver-class.test.ts (6), test/js/sql/postgres-bytea-bind.test.ts (12), test/js/sql/postgres-bind-wire.test.ts (18), test/cli/install/bun-pm-diff.test.ts (46), test/js/bun/spawn/spawn-stdin-readable-stream.test.ts (37). rustfmt reports no change. cargo mordant did not run locally (the pinned toolchain is not installed here). Removals can only lower its counts.

Self-review

The review found each deletion correct and asked for a different unit. What changed:

  1. Width: 97 files became 20. Each sweep that merged after 2026-08-27 (14 of them) has 31 files or fewer. The last wider one is Remove dead code from the js lexer, bun_runtime, bun_alloc, and 20 other crates #40610 (83 files).
  2. The Rust commit that Remove dead code from the class generator: the unreachable DOMJIT paths #43840 held ships alone, as announced there.
  3. The overlap check compared titles ("dead code") and missed feature PRs. It now simulates the merge against the head of each open PR.
  4. Hunks that make a clean PR conflict are out (cli/mod.rs, libarchive/lib.rs).
  5. Hunks next to maintainer PRs are out (Remove libuv on Windows #42819, dns: remove the remaining unsafe from the resolver module #40190).
  6. total_scripts is out, because install: remove every unsafe from src/install #40284 uses it.
  7. The branch is cut by path from the verified tree, not by commit, and the body names each conflict.

Verified and held for the next runs (branch robobun/a11e46ad/dead-code-held, 65 files, 211 lines removed, based on 36cd151)

No user found, left alone on purpose

  • JSDOMConvertSequences.h: the ExceptionThrower overloads of the sequence converters (about 115 lines) and the std::array specialization of SequenceTraits (32 lines). Each Converter<T> has the same overload set, so this is an API shape.
  • #[derive(IsCompatible)] in src/css_derive/lib.rs (136 lines): no type derives it. The header of that file names it as one of five derives that a migration relies on.
  • 26 of the 34 open dead-code PRs conflict with main today. Their deletions stay out of each new sweep until they merge or close.

@robobun

robobun commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 5:32 AM PT - Sep 26th, 2026

❌ @robobun, your commit c762b7b has 1 failures in Build #120945 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 44050

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

bun-44050 --bun

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: oven-sh/bun/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Essentials

Run ID: e5990b66-d0c1-47a2-b8cb-61570469bcd4

📥 Commits

Reviewing files that changed from the base of the PR and between 36cd151 and c762b7b.

📒 Files selected for processing (20)
  • src/bun_core/Global.rs
  • src/bun_core/string/immutable.rs
  • src/bundler/bundle_v2.rs
  • src/install/PackageManager/CommandLineArguments.rs
  • src/install/isolated_install/Store.rs
  • src/js_parser/parse/parse_entry.rs
  • src/js_parser/parse/parse_jsx.rs
  • src/js_parser/parser.rs
  • src/jsc/hot_reloader.rs
  • src/options_types/context.rs
  • src/runtime/api/bun/spawn/stdio.rs
  • src/runtime/cli/Arguments.rs
  • src/runtime/dns_jsc/dns.rs
  • src/runtime/napi/napi_body.rs
  • src/runtime/node/quic/session.rs
  • src/runtime/webcore/S3Client.rs
  • src/runtime/webcore/S3Stat.rs
  • src/s3_signing/credentials.rs
  • src/sql_jsc/jsc.rs
  • src/uws_sys/socket.rs
💤 Files with no reviewable changes (18)
  • src/bun_core/string/immutable.rs
  • src/jsc/hot_reloader.rs
  • src/runtime/webcore/S3Client.rs
  • src/runtime/api/bun/spawn/stdio.rs
  • src/js_parser/parser.rs
  • src/js_parser/parse/parse_entry.rs
  • src/runtime/dns_jsc/dns.rs
  • src/install/isolated_install/Store.rs
  • src/s3_signing/credentials.rs
  • src/runtime/node/quic/session.rs
  • src/options_types/context.rs
  • src/runtime/napi/napi_body.rs
  • src/uws_sys/socket.rs
  • src/install/PackageManager/CommandLineArguments.rs
  • src/runtime/webcore/S3Stat.rs
  • src/runtime/cli/Arguments.rs
  • src/bundler/bundle_v2.rs
  • src/js_parser/parse/parse_jsx.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


Walkthrough

The changes remove JSX inlining state, option fields and related assignments, logging scope declarations, two empty platform-specific modules, and an unused VM pointer field.

Changes

Rust declaration and state cleanup

Layer / File(s) Summary
Remove JSX inlining feature state
src/js_parser/parser.rs, src/js_parser/parse/parse_entry.rs, src/js_parser/parse/parse_jsx.rs
The jsx_optimization_inline feature field and default value were removed. JSX parsing no longer initializes or updates the inlining state, and lazy-export options no longer copy it.
Remove option fields and CLI assignment
src/install/PackageManager/CommandLineArguments.rs, src/options_types/context.rs, src/runtime/cli/Arguments.rs
The lockfile and output_file fields and their default initializers were removed. The CLI placeholder and conditional assignment to ctx.debug.output_file were also removed.
Remove logging scope declarations
src/bun_core/Global.rs, src/bun_core/string/immutable.rs, src/bundler/bundle_v2.rs, src/install/isolated_install/Store.rs, src/jsc/hot_reloader.rs, src/runtime/api/bun/spawn/stdio.rs, src/runtime/dns_jsc/dns.rs, src/runtime/node/quic/session.rs, src/runtime/webcore/S3Client.rs, src/runtime/webcore/S3Stat.rs, src/s3_signing/credentials.rs, src/uws_sys/socket.rs
Scope declarations were removed from these modules. The Bundle and scan_counter declarations remain in bv2_impl, and selected DNS scope declarations remain.
Remove empty modules and VM pointer
src/runtime/napi/napi_body.rs, src/sql_jsc/jsc.rs
Two empty platform-specific modules were removed. ArgumentsSlice no longer stores or initializes its VM pointer; init still accepts the VM argument.

Suggested reviewers: jarred-sumner

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to c762b

This cleanup removes unused state and declarations without an established behavior change. No actionable merge-blocking risk remains; the PR is mergeable subject to normal checks.

🚥 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 summarizes the primary change: removal of unused log scopes and unread fields across multiple crates. It is specific and related to the changeset.
Description check ✅ Passed The description explains the problem, fix, verification steps, behavior impact, scope, and deliberate exclusions. It does not use the exact template headings, but it provides the required information …

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — pure deletion of unreferenced log-scope statics, never-read fields, and empty cfg placeholder modules; no behavior change.

What was reviewed:

  • Grepped every scoped_log!/.is_visible()/.log()/path-qualified use of the 17 removed scope names: the only survivors (uws in us_socket_t.rs/Timer.rs, Bundle/scan_counter inside mod bv2_impl) resolve to statics that remain declared in the same module.
  • napi_body.rs: every reference to posix_platform_specific_v8_apis/uv_functions_to_export is behind #[cfg(all(not(windows), ...))] or #[cfg(unix)], so removing the windows/non-unix empty stubs leaves no unresolved path on those targets.
  • Removed fields: no remaining struct-literal constructions of Features, CommandLineArguments, DebugOptions, or sql ArgumentsSlice name them; c_void is still used elsewhere in sql_jsc/jsc.rs; the rewritten mark_binding! comment matches the JSC_SCOPE static it now points at.
Extended reasoning...

Single-commit, 20-file, +2/-63 cleanup across 10 Rust crates that deletes declare_scope! statics nothing logs to, four struct fields with no reader (plus their initializers and the dead can_be_inlined/output_file locals), and two empty cfg-gated placeholder modules in napi_body.rs. It touches no security-sensitive surface: the S3/AWS and quic hunks remove only logger statics, not signing, TLS, or credential logic. Static grep confirmed no remaining reference to any removed name on any cfg arm, and the surviving scoped_log! call sites all resolve to statics still declared in their own module; none of the changed paths fall under .github/CODEOWNERS. The bug hunt ran dry, and the diff contains no new logic, so a human review would add nothing beyond what the compiler already enforces.

@robobun

robobun commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status

Verification on c762b7b

  • bun bd passes.
  • bun run rust:check-all passes on 12 targets.
  • Seven test files and test/internal/source-lints/ pass with the debug build. The PR description lists them.
  • The CI jobs mordant, cargo clippy, cargo miri test, Format and Source lints pass.

CI build 120945 (complete, 177 of 181 jobs passed)

  • The four failed jobs fail on one test: test/js/bun/s3/s3.test.ts, on debian 13 x64, debian 13 x64-asan, ubuntu 25.04 x64 and alpine 3.23 x64. The Docker pull of quay.io/minio/minio:latest returns 401 Unauthorized before the test starts.
  • This PR does not cause it. Builds 120949, 120948, 120940, 120939, 120934 and 120931, on unrelated branches, fail the same way. The failure is reported as a break on main, and ci: build the MinIO test image from source and fail the bake on a failed image pull #44041 changes how CI gets the MinIO image.
  • Each other failure passed on a retry: napi.test.ts, test_worker_buffer_callback, filesink.test.ts, bun-install-registry.test.ts, serve-http2-lifecycle.test.ts, worker-terminate-lifetime.test.ts. Builds 120936 and 120932 show napi.test.ts as flaky without this diff.
  • A new CI run fails the same test until the MinIO image pull works, so this PR did not start one.

This branch has not been deployed

No deployments
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