Repository navigation
Conversation
Delete items that no code uses on any of the 12 build targets: trait impls, error variants, write-only fields, re-exports, log scopes and Cargo dependencies.
|
Updated 7:43 PM PT - Nov 17th, 2026
✅ @robobun, your commit eefaaefdea1dec148c076e832fd7b216b0ac67d8 passed in 🧪 To try this PR locally: bunx bun-pr 49237That installs a local version of the PR into your bun-49237 --bun |
|
Status: ready for review. How each deletion was checked:
|
|
No actionable comments were generated in the recent review. WalkthroughThis change removes public exports, trait implementations, error variants, dependencies, and selected parser and bundler state across Rust crates. It also removes generated CSS color conversions and disabled derive declarations. ChangesRust API and implementation removals
Suggested reviewers: Merge Risk:
|
There was a problem hiding this comment.
LGTM — a mechanical dead-code sweep where any remaining use of a deleted item is a compile error, and the behavior-relevant removals check out by reading.
What was reviewed:
- Grepped for consumers that a Linux-only compile could miss:
win32_name/win32_errno_name, the five removeddeclare_scope!names,delimit_quote,jsx_optimization_inline/can_be_inlined,StmtListWhich::AllStmts,PercentEncodeError::OutOfMemory,.to_uuid(),CookieMapRefclones, and the dropped re-exports (FeaturesFormatter,MetafileBuilder,Package::Serializer,jsx::Defaults,simdutf_sys::validate_*,bun_collections::ObjectPool/StaticHashMap,bun_js_parser_jsc::data_to_js/string_to_js) — no remaining references outside the diff;build_command.rsreachesmetafile_builderby its own path. - Checked the
From<RGBA>lattice removal againstFromAnyColorspace/Colorspaceinsrc/css/values/color.rs—RGBAis not aColorspaceand the bound never requiredFrom<RGBA>;from_rgbagoes throughinto_srgb().into(), and onlySRGB/HSL/HWB -> RGBAare used. - Checked the Windows spawn path in
src/spawn/process.rsfor?relying onFrom<bun_sys::Error>(it uses explicitmap_err(Error::Sys)),hot_reloader.rsfor?onbun_watcher::Error(usesmatch),ToUTF16Errorfor?intoCrateError(none), and#[derive(Default)]structs embeddingThreadCell/RwLock/Once/WeakPtr/PathName/VersionedURLType(none); the seven dropped Cargo deps are mentioned only in comments in their crates, andCargo.lockmatches theCargo.tomledits. - Not run here:
cargo check/rust:check-allacross the 12 targets, mordant and clippy — the PR's claim that they pass rests on CI.
Extended reasoning...
The change is a single commit of +6/-610 across 73 Rust files in 38 crates that only deletes items: unused ErrName/Display/Default/Clone/From trait impls, error enum variants nothing constructs, two write-only fields, five unused log scopes, dead re-exports, no-op cfg_attr(any()) lines, and seven Cargo dependency edges. It touches no security-sensitive surface (no parsing, auth, crypto, or FFI signature changes; the only platform hook removed, ErrnoNames::win32_name, had no caller anywhere in src). Approval rests on two facts: almost every deletion is self-verifying because any surviving consumer would fail to compile, and the handful of removals that are not compile-checked (write-only fields, log scopes, Cargo deps, cfg-gated consumers) were grepped and found to have no remaining users. The bug hunt ran dry, there are no outstanding reviewer objections, and no CODEOWNERS entry covers the changed paths.
Behaviour change: none
Problem
dead_codeskips trait impls andpubitems.unused_pub(mordant) checks items, not variants or impls.Fix
cargo check --workspace --all-targets,rust:check-all(12 of 12), mordant, clippy,cargo fmt, a debug build and 16 test files.Background
ErrNameis the trait thatOutput::errandthrow_errortake. 17 error enums implement it, and no call passes one of them.cfgarms for targets that Bun does not build, and code that open pull requests edit. The Notes list those parts.Downsides
Notes
Removed: trait impls that nothing uses
impl bun_core::output::ErrName for Errorin 17 crates: bun_clap, bun_crash_handler, bun_css, bun_dotenv, bun_exe_format, bun_io, bun_js_parser, bun_js_parser_jsc, bun_js_printer, bun_options_types, bun_router, bun_s3_signing, bun_shell_parser, bun_sourcemap, bun_spawn_sys, bun_sql, bun_standalone_graph.Error::name()of five of them (bun_css, bun_io, bun_router, bun_s3_signing, bun_sql). The impl was its only caller. rustc (dead_code) or mordant (unused_pub) reportsname()when only the impl goes.DisplayforE::EString,expr::Tag,ConsoleObject,SystemError,PathOrFileDescriptor,UUID5,UUID7(with theirto_uuidhelpers),bake::router::pattern::Part, andmd::ParserError(with itscore::error::Errorimpl).DefaultforThreadCell<T>,RwLock<T>,Once<T>,VersionedURLType,PathNameandWeakPtr<T>.Clone for CookieMapRef,SymbolTable for Vec<Symbol>,ExprJsc for ExprData,From<ToUTF16Error> for CrateErrorandFrom<bun_sys::Error> for bun_spawn::Error.Fromimpls betweenRGBAand the other color spaces: the 24convert_via!rows ofsrc/css/values/color_generated.rsthat nameRGBA, andFrom<RGBA> for SRGBincolor.rs, whose last users were those rows.From<SRGB>,From<HSL>andFrom<HWB> for RGBAstay.Removed: variants that nothing constructs
Each one goes with its match arms.
Error:InvalidDataURL,InvalidURL,TarballFailedToExtract,MissingDebugInfo,EndOfFile,Watcher,Ast,Patch.Error:InvalidDependencyName,FailedToCopyFile.Error:UTF8Fail,UnexpectedSyntax,JSONStringsMustUseDoubleQuotes.Error::Core,lexer::Error::{UTF8Fail, ParserError}.EncodeError::OutOfMemory,DecodeDataError::OutOfMemory.bun_core::PercentEncodeError::OutOfMemory, with its two arms inbake/dev_server/source_map_store.rs.bun_runtime::Error::NotFound,bun_spawn::Error::Core,bundler::StmtListWhich::AllStmts.#[from]variant is proved by the 12-target compile only: a name search cannot see a?.Removed: fields and hooks with no reader
Runtime::Features.jsx_optimization_inline: its comment calls it a vestigial stub. Nothing sets it, and its one reader fed the localcan_be_inlinedinparse_jsx.rs, which nothing reads.Lexer.delimit_quote: eight places write or copy it, and no condition reads it.ErrnoNames::win32_namehook, its implementationwin32_errno_namein bun_errno, and the unit test of that function. Replace bun_core::Error intern machinery with per-crate thiserror enums #33909 removed the only caller on 2026-07-10.Removed: attributes with no effect
#[cfg_attr(any(), derive(..))]lines of the tree (src/css/properties/masking.rstwice,background.rsonce), each with its comment.any()with no argument is never true.Removed: re-exports, log scopes, dependencies
analytics::FeaturesFormatter,LinkerContext::MetafileBuilder,bundler::defines::are_parts_equal,bundler_jsc::{ErrorableString, JsError},collections::{ObjectPool, ObjectPoolType, PoolGuard, StaticHashMap},crash_handler::{is_panicking, sleep_forever_if_another_thread_is_crashing},Package::Serializer,js_parser::parser::{renamer, P},js_parser_jsc::{data_to_js, string_to_js},jsx::Defaults,simdutf_sys::{validate_ascii, validate_utf8}. The items stay reachable by their own paths.declare_scope!log scopes that no log statement names:STR,Store,hot_reloader,quic_session,S3Client.scopeguard(bun_crash_handler, bun_http, bun_js_printer),const_format(bun_js_printer),bstr(bun_css_jsc) andenum-map(bun_bunfig), which no file of the crate names, andbun_patch(bun_jsc), whose only user was the removedError::Patchvariant.Checks
All on main 30261e2 plus this change. The 12-target check, mordant, clippy and the tests ran on a tree that also removed two empty modules in
napi_body.rs. That file has the text of main again.cargo check --workspace --all-targets --keep-going --lockedpasses on Linux x64.bun run rust:check-all: 12 of 12 targets pass.bun run rust:mordant(Linux, Windows, macOS): no finding over the baseline.bun run rust:clippyandcargo fmt --all -- --check: clean.bun bd(debug build with ASAN) builds and links.test/bundler/transpiler/transpiler.test.js,test/bundler/{bundler_jsx,bundler_cjs2esm}.test.ts,test/js/bun/shell/bunshell.test.ts,test/js/bun/md/{md-spec,md-edge-cases}.test.ts,test/js/bun/css/css.test.ts,test/js/bun/cookie/cookie-map.test.ts,test/js/bun/util/{inspect,randomUUIDv5,randomUUIDv7},test/js/bun/s3/s3-argument-validation.test.ts,test/js/bun/test/bun_test.test.ts,test/js/bun/spawn/spawn.test.ts,test/js/node/fs/fs.test.ts,test/cli/test/coverage.test.ts.Open pull requests
git merge-tree) with each head adds no conflict.Held: an open pull request owns it
platform::Auto = Looseinsrc/paths/resolve_path.rs(paths: one path type for every backend, unit and platform #49146 deletes the file), thelibcdependency of bun_paths, and thePathsvariant ofbun_jsc::ErrorwithUrlon the next lines: paths: one path type for every backend, unit and platform #49146.strings::{starts_with_generic, ends_with_generic}andErrNameinsrc/archive/error.rs: paths: one path type for every backend, unit and platform #49146.ErrNameinsrc/http_jsc/error.rsandbun_core::timespec_mode: http, net, tls: consolidate the open fetch, Bun.serve, node:http, node:http2, HTTP/3, node:net and node:tls pull requests #46528.IoRequestLoop::tick: blob: file reads and writes share one job, and a table owns the jobs that wait for a descriptor #49167 deletes the type.http_types::wtf: websocket client: frames are read and written by a codec without I/O or JS #49148 edits the next line.CodeCoverage.rs, with the write-onlyFraction.stmts: bun test --coverage reports branches #46534. The commented-outnapi_get_property_namesstub and two emptycfgmodules innapi_body.rs: napi: take the Node-API lifecycle code to safe Rust #40260.Ast.runtime_imports(nothing reads it since Remove dead code from js_printer, bundler, js_parser, patch, shell, http #35978): bundler(splitting): keep import order when an entry point's chunk takes no fold #44028 edits the next lines.ErrNameandname()insrc/ast/error.rs: node: ESM resolver error-code parity — ERR_PACKAGE_PATH_NOT_EXPORTED and friends (+4 tests) #35711.Default for StepResult: cli: remove unsafe from bun run / bun test / --filter and the other CLI commands #40242.import_record::Flags::WAS_ORIGINALLY_REQUIREhas no writer on main, but draft bundler: keep the CommonJS wrapper of a package that a file writes to through require() #46216 sets and reads it.ErrNameinsrc/brotli/error.rs(Replace brotli with an encoder and decoder in safe Rust #49035),src/uws_sys/error.rsandsrc/install/NetworkTask.rs(open sweeps touch the files).Held: it needs a decision
cfgarms for targets that Bun does not build (wasm32, NetBSD, RISC-V, "neither unix nor windows"), about 285 lines in 12 files. Say the platform once: real #[cfg] in place of stubs, placeholders, let _ = x and allow(...) #44086 left that class alone on purpose, and Remove dead code from webcrypto, the node:http binding, the class codegen, build scripts, and misc crates #39249 calls it a product call. It belongs in one change atsrc/bun_core/env.rs.crash_handler::Error::UnsupportedOperatingSystemgoes with itsSelfInfo::openarm.add_mappingpairs insrc/css/rules/*.rs(57 lines in 19 files): main rewrote those files last week.resolver::Error::{MissingResolveDir, InvalidResolveDir}: commented-out returns under the TODO for Missing Esbuild plugin API options (resolveDir, pluginData) #8994 name them.globalarm ofobject_pool!and theHasLengthimpls for[u8],&strand&String: doc comments next to them describe them, and the removal leaves a parameter or a trait with one use.ErrnoNames::max_dense: its only caller went with Replace bun_core::Error intern machinery with per-crate thiserror enums #33909, butsystem_errno_max_densealso serves a unit test.module.exports = {..}detection block insrc/js_parser/fold.rswithP.stmt_expr_valueandP.commonjs_replacement_stmts, the ASI warning thatsuppress_warnings_about_weird_codeturns off at every construction (now js_parser: remove the ASI warning that cannot print and its always-true option #49253), andLexer.source_mapping_url(its write can abort on a comment past 1 GiB). Each one is a behaviour question, not a deletion.HashMapMixinmethods that only a unit test calls, rows of binding tables, the HTTP/2 engine items behind#![allow(dead_code)], and hand-writtenDebugimpls.What the classes still hold
pubenums have no constructor. Five are in files of this change:bun_jsc::Error::ParserError,bun_runtime::Error::WriteError,bun_spawn::Error::Unexpected,bun_ast::Error::SyntaxError,bun_js_parser_jsc::Error::ModuleNotFound. They were not in the closed sweeps, so they did not get the two-pass check.declare_scope!scopes without a log statement exist. This change takes the five that the closed sweeps named.How the candidates were found
git merge-file, a conflict keeps the text of main). 26 of them supply this diff.WTFString,NodeEncoding, the source map name table, and the react_compiler API that bun_lint now uses.WeakRefType::PostgreSQLQueryClient, whichhawk.tomlpins as an external code table.[policy-decision:dep] gate passed · iteration 0 · 73 files touched
passes on PR (with fix)
Dependency/toolchain change; no test proof to run.diff hotspot
gate history · 1 passed · 0 rejected · iteration 0
evidence per changed file