Repository navigation
Conversation
Remove six hand-written trait impls that have no user. No call and no bound needs them. - bun_css: CssEql for (), Parse for Box<T>, ParseWithOptions for Box<T> - bun_jsc: IntoIterObject for &mut JSObject - bun_sql_jsc: MaybeBytes for String, JsClass for PostgresSQLConnection The workspace compiles without them for the 12 CI targets in four build configurations.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
💤 Files with no reviewable changes (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. WalkthroughThis pull request removes several Rust trait implementations, including CSS parsing and equality support, JavaScript property iterator conversion, MySQL message conversion, and PostgreSQL JavaScript class conversion methods. ChangesCSS trait implementations
JavaScript property iteration
MySQL error messages
PostgreSQL JavaScript class
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No merge-blocking behavior change is identified. The PR is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Status: ready for review.
|
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-07. 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
dead_codelint does not report a trait impl, so the workspace's deny lints do not catch them.Fix
bun bd,cargo check --workspacefor the 12 CI targets, nine more checks in three other build configurations,cargo fmt --check, and 12 test files of the touched areas.Background
--gc-sections: an impl block with no kept code. Then the compiler decides: an impl that a bound, another target, another build configuration or a unit test needs does not compile away.Downsides
Notes
Removed impls
src/css/generics.rs:impl CssEql for (),impl<T: Parse> Parse for Box<T>,impl<T: Parse> ParseWithOptions for Box<T>. TheDeepClone,CssEql,CssHash,IsCompatibleandToCssimpls forBox<T>stay: they have users.src/jsc/JSPropertyIterator.rs:impl IntoIterObject for &mut JSObject. The doc of the trait names*mut JSObjectand&JSObjectas the accepted arguments, and both stay.src/sql_jsc/mysql/protocol/any_mysql_error_jsc.rs:impl MaybeBytes for String. The callers ofmysql_error_to_jspass&str,&[u8],&[u8; N],Vec<u8>or anOptionof those.src/sql_jsc/postgres/PostgresSQLConnection.rs:impl jsc::JsClass for PostgresSQLConnection. The connection code calls the generatedjs::to_jsdirectly. Nothing asks forPostgresSQLConnection: JsClass.Verification
The base moved while this was checked, so each line names its base. The diff is the same 49 lines on each base.
bun check:bun bdbuilds and links (debug, ASAN).cargo check --workspace --keep-going --target <t>passes for the 12 targets ofbun run rust:check-all. linux-x64, windows-x64 and darwin-arm64 also pass with--all-targets.--cfg bun_debug --cfg bun_asan --cfg socket_fault_injection, then--release --cfg bun_codegen_embed, then--release --cfg bun_codegen_embed --cfg bun_asan --cfg socket_fault_injection -C debug-assertions=on.cargo fmt --all -- --checkis clean.css.test.ts,color.test.ts,nested-selector-expansion.test.ts,sql-connect-error-reporting.test.ts,postgres-row-decode-error.test.ts,postgres-error-then-datarow.test.ts,sql-mysql-bind-oob.test.ts,sql-mysql.test.ts,sql.test.ts,yaml.test.ts,inspect.test.jsandparse_args/default-args.test.mjs.nested-selector-expansion.test.tsand "handles stack overflow protection" inyaml.test.ts. They pass with--timeout 120000. On a faster machine they passed with the default timeout and this same diff.Why the release configuration is in the loop
cargo checkin the dev profile does not setbun_codegen_embed. A first pass deletedbun_zstd::inflate_embedded, which only the release arm ofembed_compressed!calls. The release check put it back.Found unused and left in place (51 of 57)
Debugimpls. They are a debugging aid.Deref,AsRef,Borrow,PartialEq<[u8]>,From,IntoIteratorandDisplayonInterned,ZStr,StoreStr,StoreSlice,RawSlice,ArenaString,BoundedArrayAligned,Utf8Bytes,StringHashMapKey,SmallList,HashMap,JsCell,IndexSetandGenericIndex. Remove dead code: 49 trait impls nothing uses, across 12 crates #43664 left this group to a maintainer decision, and open PRs use some of them.IntoLogWrite for &mut W,ThrowFmtArgs for fmt::Arguments,PoolStorage for UnwiredStorage,StringBuilder for semver_string::Builder,fmt::Write for FmtAdapter,AsFd for &File, the css blanket impls forOption<T>,Size2D,Rect, slices and strings, andIntoHostConstructReturn for Box<T>(a comment inhost_fn.rsnamesBox<T>as a constructor return type).IntoText for String,IntoText for Box<[u8]>(Log::add_error) andAsFd for &Fd(the syscall wrappers). A new caller can need one at any time.host_fn_setterandhost_fn_this_valueinsrc/jsc/host_fn.rs. No generated class calls them today.generate-classes.tsemits the call for a class withoutsharedThisthat has a setter or apassThismethod.bun_core::strings::split_once: unused, butclippy.tomlnames it as the replacement forstr::split_once.Not counted in the 57:
Encoding for Latin1andEncoding for Utf16insrc/parsers/yaml.rs,Clone for JsPoster,Clone for CookieMapRef, and theunsupported_implmodule ofFutex.rs. Each removal leaves something half-used or is a design call.Method
build.ninjaplus-Wl,--gc-sections, with one--undefined=per#[no_mangle]Rust symbol (3,690). A function that lldb or C++ can call stays a root, and so does what it reaches.llvm-dwarfdump --debug-line). A fn or an impl block with no live address in its line range is a candidate. This also finds a generic fn that is never instantiated. 3,029 of 31,977 Rust fns had no live code on linux-x64. Most are gated bycfg, are tests, or run at compile time only.cargo check --workspace --keep-going, put back each item that an error names, repeat until clean. Targets: the 12 ofrust:check-all. Configurations: the four above.selfreceiver is not a candidate. A deletedWStr::lenfell throughDerefto the slicelenand still compiled. The six impls here cannot do that: a missing impl fails the bound.mysql_error_to_js,MaybeBytes,IntoIterObject, a&mut JSObjecttype,JsClasswithPostgresSQLConnection, andBox<or()insrc/css. Each hit was read. None passes aStringtomysql_error_to_js, and none adds a&mut JSObject.Other scans in this run, clean or already claimed
.rsfiles outside every mod tree, headers that nothing includes, C and C++ sources outside the build,#if 0andif (false)blocks, commented-out code in C++ and TS,tsc --noUnusedLocalsonsrc/js, and unused Cargo dependencies.src/jsc/bindingsandpackages/bun-usockets: 77 extern functions have no caller on linux. An open PR already deletes 67 of them. The other ten have a caller on another target, sit in a macro list, or belong to a generic arm.