Repository navigation
Conversation
…lp, and bun_install
Collaborator
Author
|
Status: draft while a self-review of the diff runs. How each removal was checked: every removed name was searched in |
Collaborator
Author
|
Updated 3:18 AM PT - Oct 7th, 2026
✅ @robobun, your commit 5b23e7a5dc4861d757fe0b0c62033184f8f09983 passed in 🧪 To try this PR locally: bunx bun-pr 44687That installs a local version of the PR into your bun-44687 --bun |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behaviour change: none
Problem
Fix
bun bd,bun run rust:check-all(12 targets),cargo checkwith--all-targets, the debug cfgs and--release,cargo clippy, and the tests in Notes.Background
dead_code. But rustc countse == Error::EmptyASTas a use of the variant, and a store as a use of a field.returnthat a line break separates from its expression. Bun's parser carries the option that turns such warnings off, and no caller turns them on.Downsides
rgoversrc/,packages/andbuild/debug/codegen/, and each removed branch for a second path that reaches it.Notes
Removed, one group each
parse_task::ResultValue::Emptyandbun_bundler::Error::EmptyAST(30 lines).EmptyASThas no constructor: the only expression that names it isif e == crate::Error::EmptyASTinParseTask.rs, and noFromimpl or name table produces it. Thatifheld the one constructor ofResultValue::Empty. So the variant, its three match arms (source_index,drop_result_owned_fields,on_parse_task_complete) and the error variant go.Options.suppress_warnings_about_weird_codeistrueinOptions::default(),Options::init, the literal insrc/bundler/transpiler.rs, and the three assignments infunction_identities.rs,sema/mod.rsandpm_diff_normalize.rs.clone_for_lazy_exportcopies it. Its two readers are the ASI warning after a barereturn(parse/mod.rs) and an empty!a instanceof bblock whose body is aTODOcomment (parse_suffix.rs). With them goP::latest_return_had_semicolon(its one reader was the ASI block), the localreturn_without_semicolon_start, and the option.help_command::Reason::InvalidCommand(31 lines,src/runtime/cli/mod.rs). Nothing constructs it.exec()and the two other callers passReason::Explicit. The enum, thereasonparameter, theUh-oh not sure what to do with that commandarm and theexit(1)branch go.print_cli_helptext!loses its printer parameter, becausepretty!is its one printer now.Glob.scanandGlob.scanSync(27 lines,src/runtime/api/glob.rs). Each call created abun_alloc::Arena, passed it down toScanOpts::parse_cwd, where the parameter is_arena, and dropped it. A comment called it vestigial.impl Default for linker_graph::File(14 lines). Nothing calls it.LinkerGraph::loadcreates the rows zeroed, andMultiArrayList<File>has noFile: Defaultbound.HostProvider::from_shortcut(.., with_colon)(12 lines,src/install/hosted_git_info.rs). One call site, and it passesfalse. The function now has the shape offrom_domainnext to it.keep_catalog_referenceinPackageJSONEditor::edit(11 lines). The flag can betrueonly whenmanager.subcommand == Subcommand::Update. Its one reader is the last operand of a condition that hasmanager.subcommand != Subcommand::Updatebefore it.Open pull requests
git merge-tree) with each open pull request that touches a removed line shows three new conflicts. To resolve each: drop that hunk.drop_result_owned_fields, which loses one arm here (group 1).parse_cwdcalls and keeps thearenaargument (group 4).keep_catalog_reference(group 7).return_without_semicolon_startinside the removed ASI block (group 2). It conflicts with main already.Verified and left out, because an open pull request deletes the same lines
bun_bundler::cache::DISABLED, the resolver'sBundleOptions.{production, tree_shaking, allow_runtime}andresolver::Result.import_kind(all written, none read): Remove cross-crate layering workarounds #33152.os.networkInterfaces(): node:os, CompressionStream, TextEncoder/TextDecoder: remove unsafe #40244.H2FrameParser.used_window_sizeandStream.used_window_size(always 0): node:http2: keep setLocalWindowSize() off SETTINGS_INITIAL_WINDOW_SIZE #40180.MatchedRoute.needs_deinit(alwaystrue): fs_router: make MatchedRoute non-self-referential #37535.Scanner.exclusion_names(always empty): bun test: scan each directory once, however many symlinks lead to it #44487.TreeContext::clear_path_trackerofbun why: bun why: print a package's dependents once, mark repeats as *deduped #37922.StmtListWhich::AllStmts: Remove dead code from bun_core, bun_jsc, bun_css, react_compiler, and two C++ bindings #40367.Nonearms ofset_buffersinnode:zlib(node:zlib: avoid aliasing compression input/output buffers #31633),Error::FailedToCopyFile(Make the Windows hardlink install backend link serially #33113),PackageWorkspaceSearchPathFormatter.quoted(Add ForeignRef<T> and make FetchHeaders the owned handle #33820), theackparameter ofH2FrameParser::send_ping(Make unrooted JSValues, views across JS re-entry, and JSC buffer-ownership contracts compile errors #34230), thelockfileparameter ofScripts::create_list(install: fold the inline default node-gyp predicates into Scripts::wants_default_node_gyp #43912, install: derive the bun.lockb meta hash in the writer #44501).Leads, not proved to the end
LinkerOptions.modeis alwaysLinkerOptionsMode::Bundle, soshould_strip_exportsinconvertStmtsForChunk.rsis alwaystrue. The removal dedents about 100 lines in a file that 18 open pull requests touch.ServerComponentParseTask::Data::ClientEntryWrapperis constructed only as the placeholder ofimpl Default. The removal needs a constructor in place of that impl.NetworkTask.apply_patch_taskis written and never read.PatchTask::new_apply_patch_hash, which builds the value, callscompute_cache_dir_and_subpath, so its side effects need a review first.@layerrules" block offindImportedFilesInCSSOrder.rsnever runs, becausewip_orderis always empty there. esbuild's version of the block appends each entry towip_order. This is a missing step of the port, not dead code.How the candidates were found
src/install,src/runtime/cli,src/runtime/api,src/bundlerand part ofsrc/runtime/node) and listed about 140 places where a value has one possible state.src/runtime/webcore,src/runtime/server, the rest ofsrc/js_parser,src/http,src/runtime/shell,src/sql,src/css, the C++ bindings andsrc/js.Verification
The base is main at bbdc5a5.
bun bdpasses (debug build with ASAN).bun run rust:check-allpasses for 12 of 12 targets.cargo check --workspacepasses with--all-targets, with--cfg bun_asan --cfg bun_debug --cfg socket_fault_injection, and with--release.cargo clippy --workspaceandcargo fmt --all --checkare clean.test/bundler/bundler_edgecase.test.ts(182 pass),test/bundler/transpiler/transpiler.test.js(237 pass),test/cli/bun.test.ts(39 pass),test/cli/install/bun-update.test.ts(159 pass),test/cli/install/hosted-git-info/(673 pass),test/cli/install/catalogs.test.ts(88 pass),test/js/bun/glob/scan.test.ts(199 pass),match.test.ts(28 pass),path-length.test.ts(6 pass),proto.test.ts(1 pass).scan.test.tscompareGlob.scanwithfast-globover the checkout and have a 30 s limit. Under the debug JavaScriptCore,fast-globalone needs 156 s and 168 s for the two patterns.Glob.scanneeds 3.4 s and 9.4 s and returns the same number of entries (11,552 and 12,698). With the release binary the same comparison takes 3 s.Glob.match > braces(match.test.ts) takes 5.9 s against the 5 s default. It passes with--timeout. This PR does not touchGlob.match.catalogs.test.tstook 5.01 s in the full run. Alone it passes in 2.5 s.Glob.scanandGlob.scanSyncgive identical results with the debug build and with the release binary for four patterns, each with acwdstring, acwdoption,dotandabsolute, without an argument, and with an invalidcwd.bun --help,bun helpandbun --help --allprint the help and exit 0.