Repository navigation
Conversation
…QUIC setters Delete 15 hand-written trait impls that no code selects (Debug, Display, Default, From, AsRef, Borrow, ErrName, Spanned). Delete JSCommonJSModule::create(Zig::GlobalObject*, const WTF::String&, ...) and HTTPHeaderMap::get(StringView). Neither has a caller. Delete us_nq_settings_set_scid_len and us_nq_settings_set_delay_onclose with their Rust declarations and setter rows. Neither setter has a caller. Delete the removable_host_function_definition! macro. It has no user.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
QUIC settings bindings packages/bun-usockets/src/node_quic_shim.c, src/lsquic_sys/lib.rs |
The scid_len and delay_onclose setting setters and FFI declarations are removed. The silent_close and cc_algo setters remain. |
JSC binding overloads src/jsc/bindings/JSCommonJSModule.*, src/jsc/bindings/webcore/HTTPHeaderMap.* |
The WTF::String overload of JSCommonJSModule::create and the StringView overload of HTTPHeaderMap::get are removed. The other described overloads remain. |
Value-type trait implementations src/bun_core/util.rs, src/ptr/lib.rs, src/zlib/stream.rs |
Selected Default, AsRef, Borrow, and Debug implementations are removed from Ordinal, ZStr, Interned, and ZStream. |
Formatting implementations src/css/properties/custom.rs, src/jsc/JSGlobalObject.rs, src/resolver/dir_info.rs, src/sys/lib.rs |
Selected Debug and Display implementations are removed from EnvironmentVariable, GlobalRef, DirInfoRef, SystemError, and net::Address. |
Error and helper interfaces src/lint/utils/estree_compat.rs, src/spawn/error.rs, src/sql_jsc/error.rs, src/trim/removable_features/entry_point.rs |
The Spanned implementation for Target, a system-error conversion, ErrName for SQL errors, and the removable host-function macro are removed. |
Suggested reviewers: jarred-sumner
Priority:
Merge Risk: 
Minimal · previous review 3b709
-
No merge-blocking risk is established by these dead-code removals.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the main change: removal of dead code, specifically 15 trait impls and two C++ overloads. The objectives also list two QUIC setters and an unused macro, which the title omits. The title is specific and accurate for the primary change.
Full details: Description check
-
Explanation
The description follows the repository template with both required sections, "What does this PR do?" and "How did you verify your code works?", and both are substantively filled. It states the problem, the fix, and the background. It lists each removed impl, method, and macro, and it names the candidates left in place and the reasons. Verification covers
bun run rust:check-allon 12 targets,cargo checkruns across several targets,bun bd, and specific test files with pass counts. The description is detailed and matches the objectives and the file summaries. Minor gaps: the 'What does this PR do?' section does not open with a one-line statement of purpose, and the author's notes are long and dense. Neither gap makes the description incomplete.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
|
Status
CI
|
#46528 already removes them. This change no longer touches node_quic_shim.c or bun_lsquic_sys.
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-29. The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR. |
Behaviour change: none
Problem
--gc-sectionslink keeps none of their methods, and the workspace compiles without them on all 12 targets.JSCommonJSModule::create(Zig::GlobalObject*, const WTF::String&, ...)andHTTPHeaderMap::get(StringView)have no caller.removable_host_function_definition!macro has no user.Fix
bun run rust:check-all(12 targets),cargo check --workspace --release, the unit tests and benches (--all-targetsfor Linux, macOS and Windows), andbun bd.headers.test.ts,node-module-module.test.js,deflate-streaming.test.tsandtest/cli/lint/bun-rules.test.tspass on the debug ASAN build.Background
dead_codelint does not report it, and neither does hawk (the cross-crate lint behindhawk.toml): both treat an impl as reachable.--gc-sections --print-gc-sections. The compiler then vetoed 68 of 84 candidates, and those stay.Downsides
--gc-sectionslink of the Linux debug binary keeps none of them, so no code that can run is removed.{:?},{},Default::default()or.into()on one of these types gets a compile error and must add the impl back.Notes
Removed
bun_core:impl Default for Ordinal,impl AsRef<ZStr> for ZStr.bun_css:impl Debug for EnvironmentVariable.bun_jsc:impl Debug for GlobalRef.bun_lint:impl Spanned for estree_compat::Target(the inherentTarget::spanstays).bun_ptr:impl AsRef<[u8]>,impl Borrow<[u8]>,impl Defaultandimpl DebugforInterned.bun_resolver:impl Debug for DirInfoRef.bun_spawn:impl From<bun_sys::Error> for Error.bun_sql_jsc:impl ErrName for Error.bun_sys:impl Display for SystemError,impl Debug for net::Address.bun_zlib:impl Default for ZStream.bun_removable_features:macro_rules! removable_host_function_definition.src/jsc/bindings/JSCommonJSModule.{cpp,h}: theconst WTF::String&overload ofcreate. Every caller passes aJSString*or aVM&.src/jsc/bindings/webcore/HTTPHeaderMap.{cpp,h}:get(StringView). Every caller passes anHTTPHeaderName.The two added lines are a narrowed import in
estree_compat.rsand a doc comment onSystemError::fmt_with_paththat named the removedDisplayimpl.impl ErrName for bun_archive::ErrorandError::namealso passed every check, but #47106 changed those lines on main while this ran. They are not in this PR.No silent change of method resolution
Internedderefs to[u8]. A.as_ref()or.borrow()call on it now resolves to the std impl on the slice and returns the same slice. A generic bound on the removed impl fails to compile.Target::spanis inherent, so atarget.span()call never selected the trait method.GlobalRefandDirInfoRefderef toJSGlobalObjectandDirInfo. Neither target implementsDebug, so a.fmt()call cannot fall through to the target.InternedcallsDebug::fmtby hand. A{:?}or a derive needs the removed impl, so it fails to compile and does not fall through to[u8].Drop,Clone,PartialEqorHashimpl is removed.How the candidates were found
--gc-sections --print-gc-sections. A hand-written, non-generic trait impl became a candidate when the linker dropped every one of its methods. A second batch took impls with no method symbol in the linked binary at all.cargo checkpasses with it. It vetoed 68 of 84 candidates: a#[derive(Debug)]container, a testassert_eq!, a?conversion, or a generic bound needs the impl.rust:check-allcaught four that only Windows or macOS code uses (AsRef<[u16]> for WStr,Default for store::Bytes,Display for FilePolland itsFlagsFormatter).#[inline]impls have no symbol even when code uses them, so the second batch lost most of its candidates.hawk.toml, rebuilt against the pinned nightly) forx86_64-unknown-linux-gnu,aarch64-apple-darwinandx86_64-pc-windows-msvc. Nopubfunction, method, type or const is dead on all three that an open PR does not already remove.Found dead, not in this PR
us_nq_settings_set_scid_lenandus_nq_settings_set_delay_onclose(node_quic_shim.c,bun_lsquic_sys): no caller. http, net, tls: consolidate the open fetch, Bun.serve, node:http, node:http2, HTTP/3, node:net and node:tls pull requests #46528 already removes them, so this PR does not.Zig::GlobalObject::create(JSC::VM&, JSC::Structure*)(ZigGlobalObject.cpp,ZigGlobalObject.h): no caller. The header is in the precompiled header, so the check needs a full C++ rebuild. Not done here.PerformanceResourceTiming::create, its constructor,entryStartTime,entryEndTime,ResourceTiming's constructor,populateServerTiming,url(),PerformanceServerTiming::createand its constructor,NetworkLoadMetrics(): no caller, about 68 lines. Remove dead code from bun_core, the JSC bindings, the debugger, and 24 other crates #41385 edits lines inside these bodies, so this PR leaves them.#elsestub ofBun__REPRL__resetCoverageinFuzzilliREPRL.cpp: the only caller is compiled only whenFUZZILLI_ENABLEDis set.#[no_mangle]Rust exports that the linker drops on Linux. Some are for macOS, Windows or lldb. Left alone.Checks
bun run rust:check-all: 12 of 12 targets pass with the workspace lint levels (dead_code,unused_importsand the rest at deny).cargo check --workspace --releaseon x86_64-unknown-linux-gnu, against release codegen (--profile=release --mode=codegen).cargo check --workspace --all-targetson x86_64-unknown-linux-gnu, so unit tests and benches compile too. The full pass ran before the last six impls were restored. A restored impl cannot break a test target, andcargo check -p bun_runtime --all-targetspassed afterwards.cargo check --workspace --all-targetsforaarch64-apple-darwinandx86_64-pc-windows-msvc, on the pushed tree. CI compiles test targets only for Linux, so this covers test-only code for macOS and Windows.cargo fmt --all -- --check.bun bd(debug, ASAN) builds and links.binary-sizejob compares the 12 release binaries with a main build that is 11 commits ahead of the base of this branch. Each is within 8 KB of it (116 to 142 MB per binary).rust:check-all, the release check,bun bdand the tests ran on a commit that also removedimpl ErrName for bun_archive::Errorand the two QUIC setters. This branch differs from it only by keeping that code, andcargo check -p bun_archive -p bun_lsquic_syspasses on it.test/js/web/fetch/headers.test.ts142 pass,test/js/node/module/node-module-module.test.js80 pass,test/js/bun/archive.test.ts136 pass,test/js/node/quic/quic-endpoint.test.ts9 pass,test/js/node/zlib/deflate-streaming.test.ts1 pass,test/cli/lint/bun-rules.test.ts115 pass (run with--timeout 120000: the debug ASAN binary exceeds the 5 s default here).