Skip to content

Remove dead code across foundation crates#32000

Open
alii wants to merge 3 commits into
mainfrom
claude/split/foundations
Open

Remove dead code across foundation crates#32000
alii wants to merge 3 commits into
mainfrom
claude/split/foundations

Conversation

@alii

@alii alii commented Jun 8, 2026

Copy link
Copy Markdown
Member

What this does

Small dead-code deletions and helper dedups across the foundation crates: collections (unused StaticHashMap/array_list/bit_set items), threading, paths, semver, sourcemap, ini, clap_macros, bun_core output/string, io (PipeWriter/event-loop macro extraction), router (deletes orphaned cfg(test) fixture scaffolding and its dev-dependency), and url (re-exports bun_opaque handle types; Cargo.lock updated accordingly). Net −1.5k lines.

This is the base of a small stacked chain (install-cli → jsc-runtime → webcore will be based on it).

Split from #31912 (whole-repo simplification pass; closing that PR in favor of module-scoped splits). This PR only moves and removes code — zero intended behavior change. Verified there by a per-file behavioral-equivalence audit and full CI (green on build 61383); verified here by a standalone full-workspace compile check.

Why no new test files

This diff removes unused code and dedups identical implementations, so there is no behavior change for a new test to pin down. Regression coverage is the existing suite, which already exercises every touched path: bundler/transpiler snapshots for the string printer, the io and spawn suites for FilePoll/PipeWriter (Windows lanes cover windows_event_loop), the install suites for semver string interning, and test/cli/install/public-hoist-pattern.test.ts for the ini matcher path. multi_array_list keeps its in-crate #[test] coverage.

@robobun

robobun commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator
Updated 3:05 AM PT - Jun 10th, 2026

@robobun, your commit 2f2b483 has some failures in Build #61692 (All Failures)


🧪   To try this PR locally:

bunx bun-pr 32000

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

bun-32000 --bun

@alii alii marked this pull request as ready for review June 9, 2026 20:18
@alii

alii commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@robobun adopt

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR consolidates shared output tag rewriting logic, optimizes string escaping through const-generic encoding dispatch, abstracts event loop storage behind a trait for cross-platform code reuse, and removes approximately 30 unused public APIs across collections and utilities while refactoring internal data structures including semver strings, URL FFI handles, and sourcemap generation.

Changes

Shared Output Tag Rewriting and String Escaping Optimization

Layer / File(s) Summary
Shared ANSI Tag Rewriting Library and Integration
src/bun_output_tags/lib.rs, src/bun_core/output.rs, src/clap_macros/lib.rs
bun_output_tags::pretty_fmt_runtime is introduced as the canonical runtime tag processor. bun_core/output.rs removes its local implementation and re-exports the shared function. clap_macros calls the shared function at macro-expansion time to precompute tag-stripped help text instead of using a local helper.
Const-Generic String Escaping for Monomorphization Reduction
src/bun_core/string/mod.rs
New Encoding enum (ASCII, UTF8, Latin1, UTF16) becomes a const-generic parameter to write_pre_quoted_string_inner, consolidating per-encoding loop logic and code-point extraction. can_print_without_escape becomes public. quote_for_json is updated to use the UTF-8 specialized escaping path.

Event Loop Storage Abstraction and Cross-Platform Unification

Layer / File(s) Summary
POSIX PollSlot Trait and Generic PollStore
src/io/posix_event_loop.rs
Introduces PollSlot unsafe trait to abstract intrusive free-list linkage and flag manipulation. Replaces concrete POSIX Store with generic PollStore<P: PollSlot>. impl_file_poll_flag_methods!() macro consolidates FilePoll flag accessors. Deferred-free processing updated to use trait methods instead of direct field access.
Windows Event Loop Migration to Shared Abstraction
src/io/windows_event_loop.rs
Removes Windows-specific Store struct and C-callback thunk. Adopts posix::PollStore<FilePoll> and impl_poll_slot!(FilePoll) macro. Eliminates duplicated flag methods by using the shared macro from POSIX.

Systematic API Surface Reduction

Layer / File(s) Summary
Collections API Surface Reduction
src/collections/StaticHashMap.rs, src/collections/array_hash_map.rs, src/collections/array_list.rs, src/collections/bit_set.rs, src/collections/lib.rs, src/collections/multi_array_list.rs, src/collections/pool.rs
Removes unused insertion/capacity/access methods from map and list types. Deletes non-mutating set operations (complement, union_with, intersect_with, xor_with, difference_with) from bitsets. Removes span-based sorting from MultiArrayList. Simplifies Node<T> by removing remove_next/find_last and adding count_children.
Threading and Path Utilities API Reduction
src/threading/WaitGroup.rs, src/threading/channel.rs, src/threading/guarded.rs, src/threading/work_pool.rs, src/paths/lib.rs, src/paths/resolve_path.rs
Removes unsynchronized increment from WaitGroup, non-blocking writer from Channel, raw mutex accessor from GuardedBy, and batch scheduling from WorkPool. Deletes path convenience accessors and platform separator function lookup.

Data Structure Refactoring

Layer / File(s) Summary
Semver, URL, and Sourcemap Changes
src/semver/lib.rs, src/url/lib.rs, src/url/Cargo.toml, src/sourcemap/Chunk.rs, src/semver/Version.rs
Semver string inline-eligibility consolidated through can_inline and inline_bytes helpers. URL FFI handle redefined via bun_opaque::opaque_ffi! macro; from_string now consumes owned String and new helper methods added. Sourcemap printing switches to generate from internal blob representation. VersionType::sort_gt removed, leaving order_fn as canonical comparison.
INI Matcher and I/O Consolidation
src/ini/lib.rs, src/io/PipeWriter.rs
Switches .npmrc pattern matching from local helper to bun_install_types::NodeLinker::PnpmMatcher::from_expr. Introduces write_sync_file helper to unify Windows synchronous write handling.
Build and Test Cleanup
src/router/Cargo.toml, src/router/lib.rs
Removes bun_js_parser dev-dependency and simplifies test module header by removing mock fixture infrastructure.

Suggested reviewers

  • RiskyMH
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Remove dead code across foundation crates' accurately summarizes the primary change: systematic removal of unused and duplicated code from foundation crates.
Description check ✅ Passed The description provides comprehensive detail about changes across multiple crates, the rationale for not adding tests, and verification approach, exceeding minimal template requirements.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@robobun

robobun commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Adopted. Went through the full diff: the moves and dedups are behavior-preserving, and the one external consumer of the changed URL::from_string signature (hosted_git_info) goes through from_utf8, so it is unaffected. CodeRabbit's one finding (the > handling in pretty_fmt_runtime) was a misread of the tag grammar and is withdrawn; thread resolved.

CI status: the diff is effectively green. On build 61692, all 284 jobs that ran passed; the build is marked failed only because the two darwin 14 aarch64 test shards expired in the agent queue and never ran. The earlier all-lane red on build 61499 was the @angular/cli release breaking bunx.test.ts everywhere (fixed on main by #32042, merged into this branch), where the darwin aarch64 lanes did run and failed only on that since-skipped test. No failure in either build implicates this diff. Needs a maintainer to retry the two expired darwin shards or merge as is.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/bun_output_tags/lib.rs`:
- Around line 125-143: The parser currently consumes raw '>' and drops a
trailing backslash at EOF; update the match arms handling b'\\' and b'>' so only
recognized tag/escape sequences are consumed: in the b'>' arm, push the literal
b'>' into out (instead of swallowing it) and advance i; in the b'\\' arm, if i+1
>= fmt.len() (trailing backslash) push the b'\\' into out and stop/advance
appropriately, otherwise keep the existing escape handling for recognized '<' or
'>' and for unknown escapes push both the backslash and the following byte
unchanged. Locate these edits around the match on fmt[i] in lib.rs where fmt,
out, and i are used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0b240f7-9211-43b1-aa09-cbf027083864

📥 Commits

Reviewing files that changed from the base of the PR and between 09703da and 2f2b483.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (29)
  • src/bun_core/output.rs
  • src/bun_core/string/mod.rs
  • src/bun_output_tags/lib.rs
  • src/clap_macros/lib.rs
  • src/collections/StaticHashMap.rs
  • src/collections/array_hash_map.rs
  • src/collections/array_list.rs
  • src/collections/bit_set.rs
  • src/collections/lib.rs
  • src/collections/multi_array_list.rs
  • src/collections/pool.rs
  • src/ini/lib.rs
  • src/io/PipeWriter.rs
  • src/io/posix_event_loop.rs
  • src/io/windows_event_loop.rs
  • src/paths/lib.rs
  • src/paths/resolve_path.rs
  • src/router/Cargo.toml
  • src/router/lib.rs
  • src/semver/Version.rs
  • src/semver/lib.rs
  • src/sourcemap/Chunk.rs
  • src/sourcemap/lib.rs
  • src/threading/WaitGroup.rs
  • src/threading/channel.rs
  • src/threading/guarded.rs
  • src/threading/work_pool.rs
  • src/url/Cargo.toml
  • src/url/lib.rs
💤 Files with no reviewable changes (16)
  • src/collections/StaticHashMap.rs
  • src/semver/Version.rs
  • src/collections/lib.rs
  • src/threading/guarded.rs
  • src/paths/resolve_path.rs
  • src/router/Cargo.toml
  • src/threading/work_pool.rs
  • src/threading/WaitGroup.rs
  • src/sourcemap/lib.rs
  • src/collections/array_hash_map.rs
  • src/sourcemap/Chunk.rs
  • src/collections/array_list.rs
  • src/threading/channel.rs
  • src/collections/pool.rs
  • src/paths/lib.rs
  • src/collections/bit_set.rs

Comment thread src/bun_output_tags/lib.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants