Skip to content

bun_core: delete unused MapLike trait, FieldType marker, EmbedDir#31543

Merged
dylan-conway merged 1 commit into
mainfrom
claude/dead-code-bun-core
May 29, 2026
Merged

bun_core: delete unused MapLike trait, FieldType marker, EmbedDir#31543
dylan-conway merged 1 commit into
mainfrom
claude/dead-code-bun-core

Conversation

@dylan-conway

@dylan-conway dylan-conway commented May 29, 2026

Copy link
Copy Markdown
Member

Follow-up to #31536 — removes the remaining unused comptime-reflection placeholders from util.rs plus a few bun_core strays.

cargo check --workspace passes.

Why this code exists

src/bun_core/util.zig is not @imported anywhere in src/**/*.zig (every util import points at runtime/shell/util.zig, node/util/validators.zig, etc.; bun.zig does not re-export it). So everything ported from that file was dead from day one.

Item Zig original Zig callers Status
MapLike trait none — Zig used comptime duck-typing (Map.KV, @hasField, @FieldType builtin) n/a Rust-port artifact (translation of the comptime probes)
Key<M> / Value<M> src/bun_core/util.zig:3,7 0 — not even used inside util.zig (fromMapLike calls the @FieldType builtin directly) dead in Zig too
from_entries util.zig:11 (fromEntries) 0 external — only called by from() at :151,153, which has 0 callers dead in Zig too
from_map_like util.zig:80 (fromMapLike) 0 external — only called by from() at :139 dead in Zig too
FieldType enum util.zig:101 (a fn → ?type) 0 external — all grep hits are the Zig builtin @FieldType or unrelated SQL enums dead in Zig too (and obsoleted by Zig's builtin @FieldType)
EmbedDir none — neither EmbedDir nor EmbedKind exist in *.zig n/a Rust-port artifact (alias for an alternate Rust-side spelling)
buffered_reader_size src/bun_core/deprecated.zig:47 (bufferedReaderSize) 0 dead in Zig too
auto_format_label / _fallback deprecated.zig:639,631 2 — src/runtime/node.zig:342, src/runtime/test_runner/expect.zig:122 Zig callers' Rust ports use native Display/Debug instead of comptime format-label dispatch
PathString::USE_SMALL_PATH_STRING src/string/PathString.zig:12 (pub const use_small_path_string) 0 — PathString.zig only reads the file-private use_small_path_string_ (:2); the pub re-export has no consumers dead in Zig too (the public const; the private backing value is still load-bearing)

Also updates the stale port-note comment in bundler/options.rs that pointed at the deleted MapLike.

@robobun

robobun commented May 29, 2026

Copy link
Copy Markdown
Collaborator
Updated 11:05 PM PT - May 28th, 2026

@dylan-conway, your commit d8e76b3 has some failures in Build #58843 (All Failures)


🧪   To try this PR locally:

bunx bun-pr 31543

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

bun-31543 --bun

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR removes or simplifies several public APIs across core modules: the deprecated buffered_reader_size is replaced with a fixed-size buffered_reader variant; auto_format_label utilities and PathString::USE_SMALL_PATH_STRING are removed; generic map construction helpers (MapLike, from_entries, from_map_like) and FieldType are deleted from util.rs; and EmbedDir type alias is removed. Related comments in bundler/options.rs are updated accordingly.

Changes

API Surface Cleanup and Removal

Layer / File(s) Summary
Deprecated module API simplification
src/bun_core/deprecated.rs
buffered_reader_size<const SIZE> generic constructor is replaced with fixed-size buffered_reader returning BufferedReader<4096, R>; auto_format_label_fallback and auto_format_label functions are removed; RapidHash is re-exported from bun_hash to preserve the crate::deprecated::RapidHash resolution path.
PathString public constant removal
src/bun_core/string/PathString.rs
Public associated constant PathString::USE_SMALL_PATH_STRING is removed; internal USE_SMALL_PATH_STRING_ flag continues to control pointer bit width.
Util module public API removals
src/bun_core/util.rs
MapLike trait, Key/Value type aliases, from_entries and from_map_like constructors, and FieldType placeholder enum are deleted; EmbedDir type alias is removed leaving only EmbedKind for embed-root selection; needsAllocator comment block is deleted.
Comment updates reflecting API removals
src/bundler/options.rs
PORT NOTE comments are updated to remove references to MapLike/from_entries capacity behavior and clarify monomorphization to concrete LoaderHashTable type.

Possibly related PRs

  • oven-sh/bun#31536: Removes ArrayLike and related Vec<T> implementations from src/bun_core/util.rs, continuing the removal of generic ported helper traits and constructors alongside this PR's MapLike deletion.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly matches the main change: removing the MapLike trait, FieldType marker, and EmbedDir from bun_core utilities.
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.
Description check ✅ Passed The PR description provides a detailed explanation of what is being removed and why, with a comprehensive evidence table showing all removed items are genuinely dead code.

✏️ 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.

@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 deletion of unused port placeholders.

Extended reasoning...

Overview

Follow-up to #31536. Deletes unused Rust port placeholders from bun_core: the MapLike trait + Key/Value aliases + from_entries/from_map_like helpers, the unconstructible FieldType marker enum, the EmbedDir type alias, buffered_reader_size, auto_format_label/auto_format_label_fallback, the PathString::USE_SMALL_PATH_STRING re-export const, the now-orphaned use core::hash::Hash import, and a couple of stale port-note comments in bundler/options.rs. No logic is touched.

Verification

Grepped the full src/ tree (*.rs only) for each removed identifier. Zero references remain. The apparent hits for FieldType/from_entries in the broader grep are unrelated: Zig source files, JSValue::from_entries (different type/method), and doc comments referencing Zig's @FieldType builtin — none import or use the deleted bun_core::util items. USE_SMALL_PATH_STRING_ (the private module const with trailing underscore) remains in PathString.rs and is still used internally; only the never-read public re-export was removed.

Security risks

None. Pure deletions of code with zero callers and zero impls; no runtime behavior, auth, crypto, or I/O paths affected.

Level of scrutiny

Low. Mechanical dead-code removal in port-scaffolding modules (deprecated.rs, util.rs). The compiler is the proof here — cargo check --workspace passes, and Rust would fail the build if any of these were referenced. The bundler/options.rs change is comment-only.

Other factors

No prior reviewer comments to address. Bug-hunting system found nothing. Same shape as the already-merged #31536 (ArrayLike removal).

@dylan-conway dylan-conway merged commit 937b075 into main May 29, 2026
76 of 78 checks passed
@dylan-conway dylan-conway deleted the claude/dead-code-bun-core branch May 29, 2026 01:56
@coderabbitai coderabbitai Bot mentioned this pull request May 29, 2026
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