Skip to content

Remove dead code from bun_sourcemap - #34878

Merged
Jarred-Sumner merged 1 commit into
mainfrom
claude/farm/06a2c6d3/dead-code-sourcemap
Jul 21, 2026
Merged

Remove dead code from bun_sourcemap#34878
Jarred-Sumner merged 1 commit into
mainfrom
claude/farm/06a2c6d3/dead-code-sourcemap

Conversation

@robobun

@robobun robobun commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Removes two unreferenced public items from src/sourcemap/ (net -11 lines).

Removed

  • SourceMapper<T> (Chunk.rs): type alias for SourceMapFormat<T>. Carried over from the Zig port; never referenced in Rust.
  • FindCache::invalidate (InternalSourceMap.rs): per-blob invalidation. Only invalidate_all is called (from SavedSourceMap::put_value).

Two other items (Chunk::print_source_map_contents and append_source_mapping_url_remote) are also dead but already removed by #32000, so they are left out of this PR to avoid a conflict.

Verification

  • rg for each symbol across src/, build/debug/codegen/, *.classes.ts, and packages/: zero hits outside the definition for both.
  • No #[no_mangle] / extern "C" exports touched.
  • bun bd builds clean.
  • bun run rust:check-all passes on all 10 targets.
  • bun bd test test/js/bun/sourcemap/: all pass.

Followup (not in this PR)

InternalSourceMap::find_with_cache and the FindCache struct itself appear to be write-only: SavedSourceMap allocates a ~21KB FindCache and calls invalidate_all() on it in put_value, but nothing ever calls find_with_cache to populate or read it; stack remapping goes through the uncached find(). Removing that would also touch SavedSourceMap's layout and a test that references FindCache by name, so I've left it for a separate pass.

@robobun

robobun commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 10:05 PM PT - Jul 20th, 2026

@robobun, your commit 8adba4c is building: #76613

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 86c90886-ceb2-44eb-b923-08cc43452126

📥 Commits

Reviewing files that changed from the base of the PR and between c07aae7 and 8adba4c.

📒 Files selected for processing (2)
  • src/sourcemap/Chunk.rs
  • src/sourcemap/InternalSourceMap.rs

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

@robobun

robobun commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

No test added: this is pure dead-code removal with no observable behavior change, so there is no fail-before case a regression test could cover. Verification is bun bd + bun run rust:check-all (all 10 targets) + the existing sourcemap/bundler tests, all of which pass. Same shape as #34837 and #34759.

@github-actions

Copy link
Copy Markdown
Contributor

This PR may be a duplicate of:

  1. Remove dead code across foundation crates #32000 - Also removes dead code from src/sourcemap/, including the same Chunk::print_source_map_contents and append_source_mapping_url_remote functions (as part of a broader cross-crate cleanup)

🤖 Generated with Claude Code

@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 dead-code removal, all four symbols verified unreferenced.

What was reviewed:

  • Grepped src/ for each removed symbol (SourceMapper, append_source_mapping_url_remote, print_source_map_contents without _from_internal, FindCache::invalidate): zero callers.
  • Confirmed print_source_map_contents_from_internal (the surviving variant) and invalidate_all remain wired to their call sites in VirtualMachine.rs / SavedSourceMap.rs.
  • No #[no_mangle] / extern "C" exports touched; nothing reachable from codegen or FFI.
Extended reasoning...

Overview

This PR deletes four unreferenced public items from src/sourcemap/ (net -44 lines): the SourceMapper<T> type alias, the free function append_source_mapping_url_remote, Chunk::print_source_map_contents (raw-VLQ variant), and FindCache::invalidate. No behavior is added or modified — every hunk is a pure deletion.

Security risks

None. Deletions only; no input handling, no FFI, no auth/crypto surface touched.

Level of scrutiny

Low. This is a mechanical dead-code cleanup in an internal Rust crate. I independently grepped the workspace for each symbol and confirmed the PR description's claims: only the _from_internal variant of print_source_map_contents is called (src/jsc/VirtualMachine.rs:2751), only invalidate_all is called on FindCache (src/jsc/SavedSourceMap.rs:315), and neither SourceMapper nor append_source_mapping_url_remote appears anywhere else. None of the removed items are #[no_mangle] / extern "C", so there's no risk of a hidden C++ caller. rust:check-all would fail on any missed reference.

Other factors

The one inline nit (bun_url now unused in src/sourcemap/Cargo.toml) is build-graph hygiene only — it doesn't affect the compiled binary or block merge. The PR description already documents verification (bun bd, rust:check-all on all 10 targets, sourcemap test suites), and the followup note about find_with_cache being write-only is correctly scoped out.

Comment thread src/sourcemap/lib.rs
- SourceMapper<T>: unused type alias for SourceMapFormat<T>, carried over
  from the Zig port with no Rust callers
- FindCache::invalidate: only invalidate_all is called (from
  SavedSourceMap::put_value); per-blob invalidation has no callers

Verified with rg across src/, build/debug/codegen/, and *.classes.ts.
bun bd and rust:check-all pass on all targets.
@robobun
robobun force-pushed the claude/farm/06a2c6d3/dead-code-sourcemap branch from 2f9f4b7 to 8adba4c Compare July 21, 2026 03:43
@robobun

robobun commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Narrowed in 8adba4c to avoid overlap with #32000: dropped the print_source_map_contents and append_source_mapping_url_remote removals (both already in that PR), kept SourceMapper<T> and FindCache::invalidate which #32000 does not touch. Net -11 lines across 2 files now.

The bun_url Cargo.toml nit no longer applies since append_source_mapping_url_remote (its only consumer) is back; #32000 can handle that cleanup when it lands.

@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 dead-code removal, both symbols verified unreferenced.

Disregard my earlier inline comment about bun_url / append_source_mapping_url_remote — that function isn't removed by this PR (it's in #32000, as the description notes), so the Cargo.toml cleanup doesn't belong here.

What was reviewed:

  • rg confirms SourceMapper has zero references anywhere in src/.
  • FindCache::invalidate has no callers; the only consumer (SavedSourceMap.rs:315) calls invalidate_all(). Unrelated .invalidate() hits in html_rewriter/dev_server are different types.
  • Neither item is #[no_mangle]/extern "C", re-exported, or referenced from codegen/.classes.ts.
Extended reasoning...

Overview

Net -11 lines across two files in src/sourcemap/. Removes (1) pub type SourceMapper<T> = SourceMapFormat<T> — an unused type alias carried over from the Zig port, and (2) FindCache::invalidate(&mut self, data: *const u8) — per-blob cache invalidation that nothing calls (only invalidate_all is used, from SavedSourceMap::put_value).

Security risks

None. Pure deletion of unreferenced Rust items with no FFI exposure, no runtime behavior change, no user-reachable surface.

Level of scrutiny

Low. This is the canonical safe-to-auto-approve shape: deletion-only, verified dead by repo-wide grep, no extern/#[no_mangle], and bun run rust:check-all passes on all 10 targets per the PR description. If anything still referenced these, the build would fail — Rust's compiler is the test here.

Other factors

  • I independently confirmed via rg that SourceMapper has zero hits in src/ and that the only FindCache-related invalidate call is invalidate_all() at src/jsc/SavedSourceMap.rs:315. The .invalidate() calls in html_rewriter.rs and bake/dev_server are on unrelated types.
  • My earlier inline comment (about dropping bun_url from src/sourcemap/Cargo.toml) was misplaced: it referenced the removal of append_source_mapping_url_remote from lib.rs, but this PR does not touch lib.rs — that removal is in #32000, which the PR description explicitly calls out to avoid conflict. The comment does not apply here and can be ignored.
  • The PR description's followup note about find_with_cache/FindCache being write-only is out of scope and correctly deferred.
  • No outstanding human reviewer comments; no test needed (no observable behavior to regress).

@Jarred-Sumner
Jarred-Sumner merged commit 6e446d4 into main Jul 21, 2026
54 of 64 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/farm/06a2c6d3/dead-code-sourcemap branch July 21, 2026 04:02
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