Delete the unused draft FFI host function implementation - #37362
Delete the unused draft FFI host function implementation#37362robobun wants to merge 11 commits into
Conversation
…urcemap, threading, url
Resolved src/bun_core/string/mod.rs: #33909 switched return types to crate::CrateResult<()> in write_pre_quoted_string and quote_for_json, which this branch restructures into the const-generic write_pre_quoted_string_inner; carried CrateResult<()> into both the adapter and _inner signatures. Resolved src/router/lib.rs and src/sourcemap/Chunk.rs: #33909 touched return types inside blocks this branch deletes (orphaned router test scaffolding, uncalled print_source_map_contents); kept the deletions after re-verifying zero callers on current main. Restored Node::find_last in src/collections/pool.rs: gained a test caller via #33311.
…update --interactive
|
Updated 5:05 AM PT - Aug 11th, 2026
❌ @alii, your commit 5b3e978 has some failures in 🧪 To try this PR locally: bunx bun-pr 37362That installs a local version of the PR into your bun-37362 --bun |
There was a problem hiding this comment.
LGTM — pure dead-code deletion of a duplicate draft implementation.
Checked that every deleted item (Function/Step/Compiled, generate_symbols, generate_symbol_for_function, print_source_code, print_callback_source_code, Drop for Function, FFICallbackFunctionWrapper_destroy extern) has a live equivalent in ffi_body.rs, and that no code outside ffi/ referenced the removed mod.rs re-exports or types.
The deleted LIB_DIR_Z static has zero references anywhere in the tree.
The non-ffi host_fns grep hits (Response.rs, server/) are unrelated identifiers.
Extended reasoning...
Overview
This PR deletes src/runtime/ffi/host_fns.rs (469 lines) and removes ~120 lines of draft struct definitions from src/runtime/ffi/mod.rs. The deleted code was an earlier draft of the FFI Function/Step/Compiled types and the generate_symbols / print_source_code helpers. The live implementations of all of these are in ffi_body.rs, which is what mod.rs actually wires up (pub use ffi_body::FFI) and what all callers use. This is split 5/8 of #32023, broken up at maintainer request.
Security risks
None. This is a pure deletion with no new code paths, no changes to input handling, and no changes to the live FFI implementation in ffi_body.rs.
Level of scrutiny
Low-to-medium. Dead code deletion is mechanical, but FFI is a sensitive subsystem, so I verified the "dead" claim rather than trusting it:
- Grepped for every deleted public item. All
generate_symbols/generate_symbol_for_functioncall sites are insideffi_body.rsand resolve to the definitions atffi_body.rs:1707/:1846, not the deleted re-export. - Grepped for
ffi::(Function|Step|Compiled|generate_symbol|LIB_DIR_Z)acrosssrc/— no hits. Nothing outside the module referenced the draft types. - Confirmed
ffi_body.rshas its ownFunction(line 1890),Step(2524),Compiled(2533),Drop for Function(1920, byte-identical cleanup logic),needs_handle_scope/needs_napi_env/ffi_header/print_source_code/print_callback_source_code, and its ownFFICallbackFunctionWrapper_destroyextern declaration. LIB_DIR_Zhas zero references repo-wide.- The removed
uselines inmod.rs(c_char,c_void,NonNull,ZBox,JSGlobalObject,bun_tcc_sys as TCC) were only used by the deleted structs. - The apparent
host_fnshits inResponse.rsandserver/are unrelated (_jsc_host_fns,exported_host_fns).
The two Function types coexisted without conflict because host_fns.rs imported super::Function (the draft in mod.rs), while ffi_body.rs defines and uses its own — they were genuinely parallel, and only the ffi_body one is reachable from the FFI class that JS actually sees.
Other factors
The PR is part of a maintainer-requested split of an already-reviewed larger PR, with the union verified byte-identical to the CI-green parent. The remaining mod.rs is a straightforward re-export hub with an updated doc comment. No test changes are expected for a pure deletion; ffi.test.js covers the surviving path.
2f5dd36 to
9ae3ff5
Compare
What this does
ffi/host_fns.rswas an earlier draft ofgenerate_symbols/generate_symbol_for_function/Function::print_source_codethatffi/mod.rsstill declared and re-exported, but the live implementations are the ones inffi_body.rs, which is what every caller uses. This deletes the draft and theFunction/Step/Compiledstruct copies inmod.rsthat only it referenced.Split 5 of 8 from #32023, which alii asked to be broken up. Pure code motion and deletion; no intended behavior change. Stacked on
claude/split/install-cli(merge order: foundations → install-cli → these, in any order among themselves).Verification
cargo check), and the union of all eight splits is byte-identical to Deduplicate jsc bindings, runtime api, test matchers, and shell builtins #32023's headf29ce8fe4, which CI ran at 285/286 green (the one red was the fleet-widenapi.test.tsGC-timing flake on windows x64-baseline).grepfor its exports resolves only to theffi_bodydefinitions).