-
Notifications
You must be signed in to change notification settings - Fork 4.7k
bun_alloc: delete unused MimallocHeapRef, TypedArena, BumpWithFallback #31542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,15 +69,9 @@ | |
| self._parent.as_ref() | ||
| } | ||
|
|
||
| pub fn into_parent(self) -> Option<A> { | ||
| // Zig: `defer self.* = undefined; return self.rawParent();` | ||
| // Taking `self` by value consumes it; no explicit invalidation needed. | ||
| self._parent | ||
| } | ||
|
|
||
| /// Used by smart pointer types and allocator wrappers. See `crate::borrow`. | ||
| pub fn borrow(&self) -> MaybeOwnedBorrowed { | ||
| // Borrowed view carries no allocator state — just the owned/borrowed bit. | ||
|
Check warning on line 74 in src/bun_alloc/maybe_owned.rs
|
||
|
Comment on lines
72
to
74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The trailing comment block at the bottom of this file still says "keeping one would also forbid moving Extended reasoning...What the issue isThis PR deletes
The bolded clause cites Step-by-step proof
Why nothing catches itThis is a plain ImpactNo runtime or compile-time effect. The cost is reader confusion: someone auditing why FixTrim the trailing clause so the comment ends after the first reason, e.g.: // Zig `deinit` only forwarded to `bun.memory.deinit(parent_alloc)` on the owned field.
// Per PORTING.md (Idiom map: `pub fn deinit`), that is exactly field drop glue on
// `_parent: Option<A>`, so no explicit `Drop` impl.The field-drop-glue rationale is sufficient on its own; the |
||
| MaybeOwned { | ||
| _parent: if self.is_owned() { Some(()) } else { None }, | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Removing the
TypedArena<T>alias drops the only reference to thetyped_arenacrate insidebun_alloc, butsrc/bun_alloc/Cargo.toml:30still declarestyped-arena.workspace = true. Since this PR is a dead-code sweep, drop the now-unused crate-level dependency too (the workspace root entry stays —ast,js_parser,css, etc. depend on it directly).Extended reasoning...
What the issue is
The PR deletes
pub type TypedArena<T> = typed_arena::Arena<T>;fromsrc/bun_alloc/lib.rs. That line was the only reference to thetyped_arenacrate anywhere undersrc/bun_alloc/. However, the crate manifest still lists it:After this PR, that dependency entry is dead weight in
bun_alloc'sCargo.toml.Step-by-step proof
rg -i 'typed.arena' src/bun_alloc/returned two hits: theCargo.tomldependency line and thepub type TypedArena<T> = typed_arena::Arena<T>;re-export inlib.rs.lib.rsline (the only.rsreference).src/bun_alloc/Cargo.toml:30:typed-arena.workspace = true— verified against the checked-out PR head. Nouse typed_arena, no path references, noextern crate, nothing inlib.rsor any submodule.typed-arenais compiled intobun_alloc's dependency graph but never used by it.Why nothing catches it
cargo check --workspace(which the PR description cites as passing) does not warn on unused[dependencies]entries — that's the domain ofcargo-udeps/cargo-machete, neither of which runs in this CI. So the leftover entry silently survives the build.Also note:
typed-arenaremains a legitimate workspace dependency —ast,js_parser,css, and others list it in their ownCargo.tomls and usetyped_arena::Arenadirectly (not via the removedbun_alloc::TypedArenaalias, which the PR description confirms was "never referenced"). So only thebun_alloccrate-level entry should go; the[workspace.dependencies]root entry stays.Impact
None at runtime. The only cost is a spurious edge in
bun_alloc's build graph and a stale manifest line that contradicts the PR's stated goal ("dead-code sweep ofbun_alloc. None referenced outside their own definitions"). Flagging it because incomplete cleanup in a cleanup PR is exactly the kind of thing that's easier to fix now than to rediscover later.Fix
Delete line 30 from
src/bun_alloc/Cargo.toml:-typed-arena.workspace = true