Repository navigation
Remove dead code from the bundler, the resolver, bun_css, the Valkey client, and six smaller areas - #45723
Remove dead code from the bundler, the resolver, bun_css, the Valkey client, and six smaller areas#45723robobun wants to merge 1 commit into
Conversation
…client, and six smaller areas Each removed line cannot run or holds a value that nothing reads: options that only ever hold their default, hooks with an empty body, parameters with one value at every call site, and results that are never an error. No behaviour changes.
|
Updated 9:00 AM PT - Oct 17th, 2026
✅ @robobun, your commit 65603939a444750aad1d3cda4fa22d23f53290b9 passed in 🧪 To try this PR locally: bunx bun-pr 45723That installs a local version of the PR into your bun-45723 --bun |
|
Status: ready for review. How each removal was confirmed:
CI on |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Behaviour change: none
Problem
Err.Fix
ifwrapped). The Notes give each item and its proof.bun bd,cargo checkfor the 12 CI targets,cargo clippy, 17 test files with the debug build (Notes).Background
BundleOptions.writeisfalseat every assignment, soopen_output_dircannot run.ParseOptions.macro_remappingswas deep-cloned per module load and then dropped.Downsides
Notes
Removed, by area
Bundler (
src/bundler, callers insrc/jscandsrc/runtime)allocator_to_useofIntermediateOutput::code,code_standaloneandcode_with_source_map_shifts, withallocator_for_sizeand the arena argument ofalloc_buf.type DynAlloc = (), and all 7 callers passNone.BundleOptions.write,TransformOptions.write,output_dir_handle,open_output_dirandTransformOutstream.writeisSome(false)at each of its three assignments.ParseOptions.macro_remappings, its three producers (a deep clone of the macro map) andVirtualMachine.has_any_macro_remappings. The only reader waslet _ = &this_parse.macro_remappings;.BundleOptions.out_extensionsandTargetExt::out_extensions. The map was built on eachTranspilerinit and cloned into each worker. Nothing looks anything up in it.ServerComponentParseTask::Data::ClientEntryWrapper, theClientEntryWrapperstruct andgenerate_client_entry_wrapper. The variant existed only as the placeholder ofimpl Default, which the one caller overwrote.ServerComponentParseTask::newreplaces thatDefaultimpl.client_entry_point_ofTranspiler::parse,parse_maybe_return_file_only,parse_maybe_return_file_only_allow_shared_bufferandbuild_with_resolve_result_eager, andentry_points::ClientEntryPoint. Every call site passesNone.to_parser_module_typeandto_bundle_enums_target(argument and result are the same type), and the emptyimpl Drop for BundleOptions.Resolver (
src/resolver)8.
cache::Fs.stream(alwaysfalse) andsize_hint(alwaysNone) of the file reader. With them go theSTREAMconst generic, the re-stat and re-read loop, bothsize_hintmatches, and the unreadpathofread_file_contents_in_arena.9. The
platformparameter of the five helpers of the privatebun_pathsshim, anddispatch_platform!. Every caller passesPlatform::AUTO, which names the same platform asplatform::Autoon each target.Valkey client (
src/runtime/valkey_jsc,src/valkey)10. The
ResultofJSValkeyClient::send,ValkeyClient::send,enqueue,Entry::createandCommand::serialize. The only fallible step writes to aVec<u8>, andbun_io::Write for Vec<u8>always returnsOk. With it gosend_err_to_js, 31 "Failed to send" arguments,RedisError::JSErrorand thestrum::EnumStringderive ofRedisError.11.
_this_valueofJSValkeyClient::sendand thethis_jsarguments that fed it.12.
ValkeyClient.connection_strings. Built, cloned byduplicate(), never read. The three strings it backed are now boxed directly, with the same contents.Password hashing (
src/runtime/crypto)13.
bcrypt::Params.silently_truncate_passwordandbcrypt::VerifyOptions. The value istrueat both call sites and was read only by twodebug_assert!s of that value.14.
pwhash::Encodingand the twoHashOptions.encodingfields. Each has one value at its one call site, so the twoInvalidEncodingreturns cannot fire.bun_core, crash handler, watcher15.
USE_SIMDUTFandLIBDEFLATE_SUPPORTED. Both areenv::IS_NATIVE, which istrueon every target that is not wasm. The scalar fallbacks inunicode.rsgo.16.
DumpStackTraceOptions.skip_stdlib,skip_file_patterns,skip_function_patternsand the frame-skipping block inwrite_stack_trace. No caller sets them.17.
kind,hashandparentsofWatcher::remove_at_index, and its directory branch. All four callers passKind::File, _, 0, &[].CLI (
src/runtime/cli)18. Eleven arms of
tag_print_help(PatchCommand,OutdatedCommand,PackageManagerCommandand eight more) andpm_print_help.tag_print_helpis reached only for tags withUSES_GLOBAL_OPTIONS, and these eleven have itfalse. These commands print--helpthroughCommandLineArguments::print_help.19.
bun upgrade: theSILENTconst generic ofget_latest_version(one instantiation,false, so it never returnedOk(None)), and theOptionofVersion::name()(alwaysSome).CSS (
src/css,src/css_jsc)20.
Component::DefaultNamespace,QNamePrefix::ImplicitDefaultNamespace,SelectorParsingState::SKIP_DEFAULT_NAMESPACEandSelectorParser::default_namespace(), which always returnedNone. The other hash tags and flag bits keep their values.21.
Bun.color(): the locallogwas never written, so the error arm always returnednull. The throw behind it goes, withParseError::basic(that throw was its only caller).22. 24
convert_via!lines withRGBAas source or target, andimpl From<RGBA> for SRGB. Nothing invokes them.23.
BackgroundHandler::resetandTransitionHandler::reset. They assignNoneto fields thatflushhas alreadytake()n.Parser (
src/ast,src/js_parser,src/js_printer)24.
ImportRecordFlags::WAS_ORIGINALLY_REQUIREand the three branches that test it. Nothing sets the flag. The other bits keep their positions.Install (
src/install)25.
StartManifestTaskError. A copy ofForManifestErrorwith the same two variants and the same conversion tocrate::Error.26. The
ResultofResolverContext::resolve(no impl returnsErr) and thejsonparameter ofcountandresolve(no impl reads it).Not a port regression
For each flag or option that is never set (
write,cache::Fs.stream,was_originally_require,defaultNamespace,macro_remappings,client_entry_wrapper),git grepond4514457e8^(the last tree with the Zig sources) shows the same picture: declared and read, never set.Open pull requests
MaxHeapAllocatortype (Remove dead code from bun_jsc, bun_core, the bindgenv2 codegen, 15 error types, and the C++ bindings #40915), strict percent-decoding inresolver/data_url.rs(Remove dead code from the WebCore bindings and 20 Rust crates #40525), thebun_routererror module (Remove dead code from bun_jsc, bun_core, the bindgenv2 codegen, 15 error types, and the C++ bindings #40915) andPrinterOptions.pseudo_classes(Remove dead code from the code generators, the build scripts, and ten crate roots #45709 removes the re-export ofPseudoClasses).TransformOptions.writeinoptions_types/schema.rs(Remove dead code from the WebCore bindings and 20 Rust crates #40525),Transpiler::transform(Remove dead code from bun_core, the JSC bindings, the debugger, and 24 other crates #41385),entry_points.rs(Remove dead code from bun_collections, bun_core, the JSC bindings, and 37 re-exports #41268),RedisErrorinvalkey_protocol.rs(Remove dead code from bun_css, bun_react_compiler, bun_jsc, and smaller crates #40690).Verification
bun bd(debug, ASAN) links.cargo check --workspace --all-targetson the host, andcargo check --workspace --target <t>for the 12 targets ofscripts/rust-check-all.ts: no error.cargo check --workspace --all-targets --release(with the release codegen) andcargo clippy --workspace --no-deps: no error.cargo fmt --all --check: clean.test/js/bun/css/css.test.ts(1314 pass),color.test.ts(1022), four selector and loader files intest/js/bun/css(39),test/bundler/css(3 files, 17),test/js/bun/util/password.test.ts(76),test/bundler/transpiler/transpiler.test.js(238),macro-test.test.ts(28),test/bundler/bundler_bun.test.ts(12),test/js/bun/resolve/resolve.test.ts(100),test/cli/install/bun-add.test.ts(221),test/cli/hot/hot.test.ts(16),test/js/valkey/valkey.test.ts(61, the rest needs Docker),test/internal/source-lints(182, three of them need more than the default 5 s timeout on a debug build).test/bundler/bundler_edgecase.test.ts: 182 pass. One test,edgecase/DeepImportDiamondDAG, gives a 20,000-module build 60 seconds. The debug build needed 46 to 70 seconds on my machine, which depends on the load, so that test passed on the second run.set,get,incr,hmset,hmget,sadd,send, aWRONGTYPEserver error, 50 pipelined commands,duplicate()with subscribe, publish and unsubscribe, and a command on a dead connection. Same output.Self-review
How the candidates were found
hawk(dead_public) andhawk --fixfollowed by rustc'sdead_code.Leads, not applied
src/css/prefixes.rsandsrc/css/compat.rs(generated bybuild-prefixes.js): 88 and 103Featurevariants are never constructed, about 1,900 lines with their arms and rows. They belong to lightningcss handlers that are not ported yet, so this needs the owner's decision.Global::configure_allocatoris an empty function with five call sites. Its comment says it is kept on purpose.LinkerContext::check_for_memory_corruptionhas an empty body and 7 call sites. Its comment says it waits for the graph heap to become aMimallocArena.LinkerOptions.modeis alwaysBundle(a lead of Remove dead code from bun_bundler, the JS parser, the help command, and PackageJSONEditor #44687 too). The removal re-indents about 130 lines ofconvertStmtsForChunk.rs, a file that many open PRs touch.node::util::validators::validate_numberandvalidate_array: themin,maxandmin_lengtharguments areNoneat every call site. They mirror Node's validators.E::RegExp.flags_offsetis write-only. Its removal leaves a length check inreact_compiler/codegen.rswith no purpose, so it needs a decision there.