Skip to content

Strip comment blocks longer than 3 lines from .rs files#31201

Closed
robobun wants to merge 1 commit into
mainfrom
farm/a9f7cf29/strip-long-rs-comments
Closed

Strip comment blocks longer than 3 lines from .rs files#31201
robobun wants to merge 1 commit into
mainfrom
farm/a9f7cf29/strip-long-rs-comments

Conversation

@robobun

@robobun robobun commented May 22, 2026

Copy link
Copy Markdown
Collaborator

What

Adds scripts/strip-long-rs-comments.ts and applies it across the tree.

The script removes every //-style comment block longer than 3 lines (i.e. 4+ consecutive comment-only lines) from git-tracked *.rs files, except:

  • a block that is the first non-blank content in the file (top-of-file header),
  • // HOST_EXPORT(...) marker lines, which src/codegen/generate-host-exports.ts scrapes to emit extern "C" thunks — those are kept even when the surrounding prose is removed, and
  • any block containing SAFETY, a line opening with a case-insensitive Safety:-style marker, or a /// # Safety heading — clippy::undocumented_unsafe_blocks is deny workspace-wide and matches the marker case-insensitively, so those justifications are kept in full.

A "comment block" is a maximal run of lines whose trimmed content starts with // (covers //, ///, //!). Inline /* ... */ and trailing // ... after code aren't touched. vendor/, packages/ (externally published crates) and scripts/verify-baseline-static/ are skipped.

When a block is removed, adjacent blank lines are collapsed so the result doesn't leave double blanks or a stray blank after {.

Result

1060 files changed, 650 insertions(+), 70792 deletions(-)   # vs current main (fourteenth refresh)
1061 files changed, 647 insertions(+), 70774 deletions(-)   # original pass

Script usage

bun scripts/strip-long-rs-comments.ts           # apply in-place
bun scripts/strip-long-rs-comments.ts --dry     # report only
bun scripts/strip-long-rs-comments.ts --min N   # threshold (default 4)
bun scripts/strip-long-rs-comments.ts a.rs b.rs # only these files

Rebase onto main

Main gained 9 commits touching 10 .rs files after the original pass (WebKit upgrade, yaml/parser/shell/patch fixes). Conflicts in src/js_parser/parser.rs, src/jsc/JSType.rs and src/runtime/shell/states/Expansion.rs were resolved by taking main's version of each file and re-running the script on it, so the upstream code changes (JSType renumbering, shell meta_offsets rework, parser changes) are preserved exactly and only their comments are stripped. The last commit re-runs the script over src/js_parser/parse/{mod,parse_stmt}.rs and src/parsers/yaml.rs, which gained 4+-line comment blocks from upstream commits that merged cleanly.

A second rebase onto current main (18 further commits, 17 touching .rs files) had a single conflict, src/js_parser/parse/parse_typescript.rs (from #31261). It was resolved the same way: take main's version of the file and re-run the script on it, so the upstream parser change is preserved exactly and only its comments are stripped. A follow-up commit strips the 12 comment blocks (58 lines) that the newly merged upstream commits introduced (src/md/links.rs, src/md/inlines.rs, src/js_parser/p.rs, src/js_parser/parse/parse_stmt.rs, src/js_parser/lower/lower_decorators.rs).

A third rebase picked up #31240, #31264 and #31272 (3 commits, 3 .rs files), which landed while the previous head was in CI. Conflicts in src/bun_core/lib.rs and src/runtime/shell/states/Expansion.rs were resolved the same way — take main's version of the file and re-run the script on it — so the upstream fixes (the b.len() < a.len() guard in eql_case_insensitive_ascii, the component-leading-! glob wrapping) are preserved exactly and only their comments are stripped. A follow-up commit strips the one 4-line block #31240 added to src/js_parser/scan/scan_imports.rs, which had merged cleanly.

A fourth rebase picked up the next 10 upstream commits (67 .rs files: the round-3 hardening pass #31221 plus CSS/parser/markdown/JSONC/CryptoHasher fixes). 15 files conflicted — 14 on the main strip commit and src/md/inlines.rs on a follow-up commit — and were resolved the same way: take main's version of the file and re-run the script, so the upstream code changes are preserved exactly and only their comments are stripped. A follow-up commit strips the 33 new 4+-line blocks (173 lines) those commits introduced across the 25 files that merged cleanly.

A fifth rebase picked up the next 6 upstream commits, dominated by #31254 (pub(crate) restriction + dead-code removal across 789 .rs files). 240 files conflicted on the main strip commit and were resolved the same way — take main's version of each file and re-run the script — plus 5 files that #31254 deleted upstream (src/meta/*, src/url_jsc/lib.rs, src/libarchive_sys/bindings.rs, src/codegen/process_windows_translate_c.rs) are deleted here too rather than resurrected. A follow-up commit strips the 2 new 4+-line blocks the remaining upstream commits introduced in cleanly-merged files. The diffstat shrank slightly because upstream's dead-code removal deleted some previously-stripped files and lines.

A sixth rebase picked up the next 11 upstream commits (11 .rs files: CSS nesting/@container minification fixes, js_parser decorator/auto-accessor/TS-depth fixes, node:http2 GOAWAY + HEADERS/CONTINUATION work, js_printer fixes). Only src/css/rules/mod.rs and src/css/rules/style.rs conflicted, on the main strip commit, and were resolved the same way — take main's version of the file and re-run the script — so the upstream changes are preserved exactly and only their comments are stripped. A follow-up commit strips the 6 new 4+-line blocks (25 lines) the remaining upstream commits introduced in cleanly-merged files (src/js_parser/parse/mod.rs, src/js_parser/visit/visit_stmt.rs, src/runtime/api/bun/h2_frame_parser.rs).

A seventh rebase picked up #31333, #31350 and #31366 (3 commits, 6 .rs files: transpiler nesting-depth errors, a JSX key-prop fix, and the ANSI markdown indentation cap). src/js_parser/p.rs and src/js_parser/parse/parse_stmt.rs conflicted on the main strip commit and were resolved the same way — take main's version of the file and re-run the script — so the upstream changes are preserved exactly and only their comments are stripped. A follow-up commit strips the 2 new 4+-line blocks (10 lines) #31366 added to src/md/ansi_renderer.rs, which had merged cleanly.

An eighth rebase picked up #31341 and #31367 (2 commits, 2 .rs files). Only src/ast/lib.rs conflicted, on the main strip commit, and was resolved the same way — take main's version of the file and re-run the script. src/runtime/shell/states/Expansion.rs merged cleanly and the new upstream code introduced no new 4+-line comment blocks, so no follow-up commit was needed. The empty retrigger commit from the previous head was dropped from history during the rebase.

A ninth rebase picked up the next 4 upstream commits, of which two touch .rs files: #31351 (Bun.stringWidth ported to C++, deleting the Rust grapheme/visible-width code) and #31358 (Blob owned content-type drop fix). Eight files conflicted on the main strip commit and were resolved the same way — take main's version of each file and re-run the script — so the upstream changes are preserved exactly and only their comments are stripped; src/bun_core/string/immutable/grapheme.rs and grapheme_tables.rs, which #31351 deleted upstream, are deleted here too rather than resurrected. The remaining upstream .rs changes merged cleanly and introduced no new 4+-line comment blocks, so no follow-up commit was needed. The diffstat shrank slightly because the deleted files carried previously-stripped lines.

A tenth rebase picked up #31339 (the round-4 hardening pass, ~60 .rs files) and #31379 (FormData multipart serialization, 2 .rs files). Eleven files conflicted on the main strip commit and were resolved the same way — take main's version of each file and re-run the script — so the upstream changes are preserved exactly and only their comments are stripped. The cleanly-merged upstream changes introduced no new 4+-line comment blocks, so no follow-up commit was needed.

An eleventh rebase picked up the next 6 upstream commits, three touching .rs files (#31325 fetch checkServerIdentity, #31376 install exit-callback gating, #31404 CSS pseudo-name escaping) plus #31382 (test/fixture only). Only src/runtime/webcore/fetch/FetchTasklet.rs conflicted, on the main strip commit, and was resolved the same way — take main's version and re-run the script. A follow-up commit strips the 4 new 4+-line blocks (25 lines) #31325 added to src/http/lib.rs and src/http/InternalState.rs, which had merged cleanly.

A twelfth rebase picked up the next 4 upstream commits, two touching .rs files this PR covers: #31385 (TextEncoder SIMD ASCII fast paths: src/runtime/webcore/TextEncoder.rs, src/highway/lib.rs, src/bun_core/lib.rs) and #31403 (js_parser digit-named default-export sanitization: src/js_parser/p.rs, src/bun_core/fmt.rs); #31412 only touches scripts/verify-baseline-static/, which the script skips, and #31407 touches no .rs files. src/bun_core/lib.rs and src/runtime/webcore/TextEncoder.rs conflicted on the main strip commit and were resolved the same way — take main's version of the file and re-run the script — so the upstream changes are preserved exactly and only their comments are stripped; the rewritten TextEncoder.rs has no strippable 4+-line blocks at all, so it no longer carries any diff here. The other files merged cleanly and the new upstream code introduced no new 4+-line comment blocks, so no follow-up strip commit was needed. A review-driven follow-up keeps sub-threshold pieces of the original comments in the two bodies the strip pass had left empty — the #[cfg(debug_assertions)] block in StandaloneModuleGraph.rs and the queue_slice_len == 1 arm in resolver.rs — so neither is left as a bare {}. A second review follow-up does the same for four more bodies that cargo fmt had collapsed onto a single line (LinkerContext::check_for_memory_corruption, BundleOptions's Drop impl, the Target::Bun arm in options.rs, and the prefill::hot_module_reloading placeholder mod); the remaining strip-emptied bodies are idiomatic empty match arms and no-op trait fns and stay as they are.

A thirteenth rebase picked up the next 9 upstream commits, six touching .rs files this PR covers (#31421/#31423/#31425 Buffer base64/hex SIMD, #31422 Bun.serve per-request GC accounting, #31433 js_parser SIMD block-comment skipping, #31435 JS-highlighter OOB fix). One conflict, src/js_parser/lexer.rs: #31433 both re-implemented skip_to_interesting_character_in_multiline_comment to delegate to bun_highway::index_of_interesting_character_in_multiline_comment (returning usize) and added a 6-line doc comment to it, while this branch's strip commit had stripped that file against its old base. Resolved the same way — take main's version of the function (the bun_highway body) and strip its 6-line doc block, exactly what this PR does to every 4+-line comment block. A follow-up commit strips the 10 new 4+-line blocks (56 lines) the cleanly-merged upstream commits introduced across five files (src/base64/lib.rs, src/bun_core/string/immutable.rs, src/highway/lib.rs, src/runtime/webcore/encoding.rs, src/simdutf_sys/simdutf.rs).

A fourteenth rebase picked up #31424 (node:fs watchFile → lazy internal module), #31437 (mysql binary YEAR decode), #31438 (TextDecoder codec-alive across chunks), and #31417 (round-6 hardening, ~46 .rs files). Seven files conflicted on the main strip commit (bun.lock.rs, jsc/lib.rs, bake/DevServer.rs, dns_jsc/dns.rs, node/node_fs.rs, webcore/Blob.rs, webcore/Body.rs) and were resolved the same way — take main's version of each file and re-run the script — so the upstream changes (incl. #31417's pub(crate) tightening and new doc comments) are preserved exactly and only their comments are stripped. A follow-up commit strips the 4+-line blocks those files plus TextDecoder.rs carried, and cargo fmt then reflowed three of them (a use re-sort in bun.lock.rs, a collapsed match arm in node_fs.rs, a blank-line collapse in Body.rs). This refresh also fixed a latent over-strip bug: a full byte-for-byte comparison against main with the script applied revealed that two earlier strip commits — built against older bases — had removed whole comment-only statements rather than just their comments: an if token == PercentTag::O {} in ConsoleObject.rs and an else {} in resolver.rs. Both files were re-derived from main with the script so the (empty) constructs are preserved and the diff stays strictly comments-only.

A fifteenth rebase picked up the next 5 upstream commits, four touching .rs files this PR covers: #31493 (StringJoiner borrowed segments bound to a lifetime — StringJoiner<'a> / Node<'a>), #31483 (Bun.escapeHTML rewritten on Highway SIMD, deleting the old scalar ScalarVec/ENABLE_SIMD path and slimming immutable/escapeHTML.rs to the byte→entity lookup), #31211 (postgres NUMERIC binary-decode leading-zero fix), and #31456 (node-fallback polyfills embedded zstd-compressed). Seven files conflicted on the main strip commit — StringJoiner.rs, immutable.rs, immutable/escapeHTML.rs, immutable/unicode.rs, resolver/node_fallbacks.rs, sourcemap/lib.rs — plus webcore/Blob.rs on a follow-up (its push_string_slice signature picked up the new StringJoiner<'_> lifetime from #31493). All were resolved the same way — take main's version of each file and re-run the strip script — so the upstream code changes (the StringJoiner lifetime, the SIMD escapeHTML, the NUMERIC counter split, the zstd embed) are preserved exactly and only their comments are stripped. A follow-up commit strips the one new 4+-line block #31211 introduced in sql_jsc/postgres/DataCell.rs (the get_str_from_var NUMERIC comment), which had merged cleanly, and re-derives ptr/lib.rs and sourcemap/lib.rs from main+script so a one-blank-line formatting drift those files carried from an older base is dropped. Proof it is comments-only (re-run for this head): a fresh checkout of main with the script applied and cargo fmt'd is byte-identical to this branch across every .rs file except the eight bodies that carry a deliberate ≤3-line note (LinkerContext::check_for_memory_corruption, options.rs's Target::Bun arm and BundleOptions's Drop, lifecycle_script_runner.rs's else arm, the two js_parser/p.rs substitution-failure arms, parser.rs's hot_module_reloading mod, ConsoleObject.rs's %o branch, resolver.rs's paths-merge else + queue_slice_len == 1 arm, and StandaloneModuleGraph.rs's #[cfg(debug_assertions)] block) — each differing only by the note text inside an otherwise-identical construct, with zero real-code lines added. bun bd built and linked cleanly (binary runs; -e 'console.log(1+1)'2), cargo fmt --all -- --check is clean, cargo clippy -p bun_resolver is clean on the pinned nightly (the needless_else fix holds; bun_jsc's needless_ifs fix is guarded by the %o note and the deny-warnings bun bd build passed), and test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (incl. the tree-is-clean idempotency scan).

Clippy follow-up (current head): re-deriving those two files left three control-flow bodies whose only content on main was a now-stripped comment block as bare {}, and two of them fail cargo clippy under -D warnings: the else {} in resolver.rs (the extends-chain tsconfig paths-merge) trips clippy::needless_else, and if token == PercentTag::O {} in ConsoleObject.rs trips clippy::needless_ifs (CI only reported the first because it stops at the first crate error). Each of the three now carries a single sub-threshold note — // No paths to move; parent_config still owns them (Drop frees)., // %o would apply node's extra formatter options (max depth, hidden, proxy); not yet implemented., and the existing // Is the directory we're searching for actually a file? moved back inside the queue_slice_len == 1 arm (out of the dead-code position above the else if). All three notes are one line, under the 4-line threshold, so the script stays idempotent on both files; cargo clippy -p bun_resolver -p bun_jsc is clean on the pinned nightly, and a scan of every changed .rs file finds no remaining empty if {} / else {}.

Verification

  • Relative to current main, the .rs diff removes only comment lines; the ~650 added lines are the cargo fmt reflow that follows block removal, use/pub use re-sorts, and the short sub-threshold notes kept in a handful of otherwise-empty bodies (lifecycle_script_runner.rs, the js_parser substitution-failure arms, LinkerContext::check_for_memory_corruption, BundleOptions's Drop impl, the Target::Bun arm in options.rs, prefill::hot_module_reloading, StandaloneModuleGraph.rs's #[cfg(debug_assertions)] block, resolver.rs's paths-merge else and queue_slice_len == 1 arm, and ConsoleObject.rs's %o branch — the last three required so clippy::needless_else / needless_ifs don't fire on a bare {}). Proof it is comments-only: applying the script to a fresh checkout of main and running cargo fmt on both trees yields byte-identical .rs files everywhere except those note-carrying bodies (which differ only by the note text inside an otherwise-identical construct) — this check is what caught and fixed the two over-stripped statements in the fourteenth refresh
  • All 90 // HOST_EXPORT(...) markers present on main are still present; zero SAFETY / # Safety lines removed, and the one mixed-case // Safety: block in the tree (src/jsc/AsyncModule.rs) is kept
  • No raw-string literal content touched (checked the multi-line literals in the upstream-changed files byte-for-byte)
  • cargo fmt --all -- --check is clean with the pinned nightly-2026-05-06
  • cargo clippy -p bun_resolver -p bun_jsc --no-deps is clean on the pinned nightly (the two crates whose strip-emptied bodies were tripping needless_else / needless_ifs); no changed .rs file contains an empty if {} / else {}
  • bun scripts/strip-long-rs-comments.ts --dry over the tree reports nothing left to strip (idempotent)
  • test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (unit cases + tree-is-clean scan)
  • bun bd built and linked cleanly on the pre-rebase revision of this diff; ./build/debug/bun-debug -e 'console.log(1+1)'2
    A sixteenth rebase picked up the next 11 upstream commits (45 .rs files: Hardening: input validation and protocol tightening across 24 subsystems (round 7) #31495 round-7 hardening across 24 subsystems, Add runtime-dispatched SIMD xxHash3 via Highway #31491 SIMD xxHash3 via Highway, Lowercase Headers names on iteration with Highway SIMD #31489 Highway header-name lowercasing, Route large ANSI escape scans through the dispatched Highway kernel #31490 Highway ANSI-escape scanning, plus node:buffer: default lastIndexOf(value, encoding) to search from the end #31507/js_parser: discard the fake if-block scope for a forward-declared function #31533/css: bound selector expansion through nesting-holding at-rules #31482/bun:sqlite: decode short non-UTF-8 TEXT leniently instead of dropping the field #31514/sourcemap: fail on a truncated base64 VLQ instead of decoding it as 0 #31506/yaml: extract parse_block_indented helper; fix anchor/tag on empty node (6KGN/FH7J/H7J7/PW8X) #31308/ci: build the Windows artifacts by cross-compiling from Linux #31431 buffer/parser/css/sqlite/sourcemap/yaml/CI fixes). Seven files conflicted — six on the main strip commit (src/hash/xxhash.rs, src/css/rules/style.rs, src/runtime/api/HashObject.rs, src/runtime/api/bun/h2_frame_parser.rs, src/uws/lib.rs, src/uws_sys/Response.rs) and src/parsers/yaml.rs on a follow-up strip commit — and were resolved the same way: take main's version of each file and re-run the strip script, so the upstream code changes (the bun_highway::XxHash64State streaming wrapper, the CSS nesting rework, the h2 frame-parser changes, yaml's parse_block_indented extraction) are preserved exactly and only their comments are stripped. A follow-up commit strips the 9 new 4+-line blocks (58 lines) the cleanly-merged upstream commits introduced across seven files (src/base64/lib.rs, src/css/rules/mod.rs, src/css/rules/supports.rs, src/highway/lib.rs, src/js_parser/parse/parse_fn.rs, src/runtime/cli/pack_command.rs, src/runtime/socket/Listener.rs). Proof it is comments-only (re-run for this head): a fresh git worktree at main with the script applied and cargo fmt'd is byte-identical to this branch across every .rs file except the same eight bodies that carry a deliberate ≤3-line note (check_for_memory_corruption, the Target::Bun arm + BundleOptions Drop in options.rs, lifecycle_script_runner.rs's else arm, the two js_parser/p.rs substitution-failure arms, parser.rs's hot_module_reloading mod, ConsoleObject.rs's %o branch, resolver.rs's paths-merge else + queue_slice_len == 1 arm, and StandaloneModuleGraph.rs's #[cfg(debug_assertions)] block) — each differing only by the note text inside an otherwise-identical construct, with zero real-code lines added. The 90 genuine // HOST_EXPORT(...) marker lines are all present (90 = 90 vs main; the one HOST_EXPORT( substring that differs is prose inside backticks in a stripped doc block, not a marker line); SAFETY/# Safety header lines 12876 = 12876 with none removed; zero TODO/FIXME/HACK/XXX added in the diff. bun bd built and linked cleanly (binary runs; -e 'console.log(1+1)'2), the deny-warnings build passing confirms bun_jsc's needless_ifs fix (guarded by the %o note) holds; cargo fmt --all -- --check clean, cargo clippy -p bun_resolver clean on the pinned nightly (the needless_else fix holds), the strip --dry reports 0 changes (idempotent), and test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (incl. the tree-is-clean scan).

A seventeenth rebase picked up the next 9 upstream commits (35 .rs files: #31542/#31551/#31548/#31544/#31541/#31536 dead-code deletions across bun_alloc/paths/resolver/threading/collections/bun_core, #31529 inlining ungate_support into bundle_v2/lib.rs and deleting the file, #31537 js_parser JSX stack-depth guard, #31527 yaml tab rejection). Fifteen files conflicted on the main strip commit (bun_alloc/memory.rs, bun_alloc/stack_fallback.rs, bun_core/util.rs, bundler/LinkerContext.rs, LinkerGraph.rs, bundle_v2.rs, linker_context/prepareCssAstsForChunk.rs, transpiler.rs, collections/comptime_string_map.rs, resolver/fs.rs, threading/{ThreadPool,guarded,unbounded_queue}.rs) plus parsers/yaml.rs on a follow-up strip commit, and were resolved the same way — take main's version of each file and re-run the strip script — so the upstream code changes (the dead-code removals, the JSX depth guard, yaml's tab handling) are preserved exactly and only their comments are stripped. src/bundler/ungate_support.rs, which #31529 deleted upstream, is deleted here too rather than resurrected. The empty ci: retrigger tip commit from the previous head was dropped during the rebase. Proof it is comments-only (re-run for this head): a fresh git worktree at main with the script applied and cargo fmt'd is byte-identical to this branch across every .rs file except the same eight bodies that carry a deliberate ≤3-line note — each differing only by the note text inside an otherwise-identical construct, with zero real-code lines added. 90 genuine // HOST_EXPORT(...) marker lines present (90 = 90; the one substring that differs is prose inside a stripped doc block in virtual_machine_exports.rs/generated_host_exports.rs, not a marker line); SAFETY/# Safety header lines 12073 = 12073 with none removed; zero TODO/FIXME/HACK/XXX added in the diff. bun bd built and linked cleanly (binary runs; -e 'console.log(1+1)'2), cargo fmt --all -- --check clean, cargo clippy -p bun_resolver -p bun_jsc --no-deps clean on the pinned nightly (the needless_else/needless_ifs fixes hold, also confirmed by the deny-warnings bun bd build), strip --dry = 0 (idempotent), and test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (incl. the tree-is-clean scan). The CONFLICTING badge GitHub may show is stale cache: the branch is rebased on the current main tip and git merge-tree --write-tree HEAD origin/main is clean (0 conflicts).

An eighteenth rebase picked up the next 10 upstream commits (20 .rs files: #31546/#31545/#31543/#31552/#31550 dead-code deletions across ast/semver/bun_core/http_types/sys, #31496 deleted-cwd compiled-executable crash fix, #31532 encodeInto astral-char fix, #31539 install lockfileVersion-2 gating, #31547 yaml ---/... column-0 recognition, plus #31553 CI-only). Nine files conflicted on the main strip commit (src/ast/runtime.rs, src/bun_core/deprecated.rs, src/bun_core/util.rs, src/bundler/options.rs, src/jsc/VirtualMachine.rs, src/runtime/jsc_hooks.rs, src/semver/SemverRange.rs, src/semver/lib.rs) and src/http_types/URLPath.rs on a follow-up — all resolved the same way: take main's version of each file and re-run the strip script, so the upstream code changes (the dead-code removals, the crash fix, encodeInto fix, lockfile-v2 gating, yaml column-0 rule) are preserved exactly and only their comments are stripped. src/bundler/options.rs's two sub-threshold notes (the Target::Bun arm and BundleOptions's Drop) were restored after re-deriving the file. A follow-up commit strips the 6 new 4+-line blocks (44 lines) #31539 and #31547 introduced across src/install/lockfile/bun.lock.rs and src/parsers/yaml.rs, which had merged cleanly. Proof it is comments-only (re-run for this head): a fresh git worktree at main with the script applied and cargo fmt'd is byte-identical to this branch across every .rs file except the same eight bodies that carry a deliberate ≤3-line note (check_for_memory_corruption, the Target::Bun arm + BundleOptions Drop in options.rs, lifecycle_script_runner.rs's else arm, the two js_parser/p.rs substitution-failure arms, parser.rs's hot_module_reloading mod, ConsoleObject.rs's %o branch, resolver.rs's paths-merge else + queue_slice_len == 1 arm, and StandaloneModuleGraph.rs's #[cfg(debug_assertions)] block) — each differing only by the note text inside an otherwise-identical construct, with zero real-code lines added. 90 genuine // HOST_EXPORT(...) marker lines present (90 = 90; the one substring delta is prose in a stripped doc block, not a marker); SAFETY/# Safety header lines 12072 = 12072 with none removed; zero TODO/FIXME/HACK/XXX added in the diff. bun bd built and linked cleanly (binary runs; -e 'console.log(1+1)'2), cargo fmt --all -- --check clean, cargo clippy -p bun_resolver -p bun_jsc --no-deps clean on the pinned nightly (the needless_else/needless_ifs fixes hold, also confirmed by the deny-warnings bun bd build), strip --dry = 0 (idempotent), and test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (incl. the tree-is-clean scan).

A nineteenth rebase picked up #31561 (yaml flow-context over/under-accept fixes, 1 .rs file). The single conflict, src/parsers/yaml.rs, was resolved the same way — take main's version of the file and re-run the strip script — so #31561's parser changes are preserved exactly and only the file's comments are stripped (43 blocks / 246 comment lines removed; cargo fmt made no further change). Proof it is comments-only (re-run for this head): a fresh git worktree at main with the script applied and cargo fmt'd is byte-identical to this branch across every .rs file except the same eight bodies that carry a deliberate ≤3-line note (check_for_memory_corruption, the Target::Bun arm + BundleOptions Drop in options.rs, lifecycle_script_runner.rs's else arm, the two js_parser/p.rs substitution-failure arms, parser.rs's hot_module_reloading mod, ConsoleObject.rs's %o branch, resolver.rs's paths-merge else + queue_slice_len == 1 arm, and StandaloneModuleGraph.rs's #[cfg(debug_assertions)] block) — each differing only by the note text inside an otherwise-identical construct (the difference is just {} vs { <note> } brace placement), with zero real-code lines added. yaml.rs gained no new empty {} match arms (28 = 28 vs main). cargo fmt --all -- --check clean; cargo clippy -p bun_resolver --no-deps clean on the pinned nightly (transitively checks bun_parsers/yaml.rs, bun_js_parser, and bun_resolver — the needless_else fix holds); bun_jsc's needless_ifs guard (the %o note) is unchanged by this rebase and confirmed by the deny-warnings bun bd build. strip --dry = 0 (idempotent); test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (incl. the tree-is-clean scan). Rebased on the current main tip (0 behind / 26 ahead); git merge-tree --write-tree HEAD origin/main is conflict-free.

@robobun

robobun commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 6:07 PM PT - May 29th, 2026

@robobun, your commit 1afc868b885df277724d0920c0d3f368b39a9405 passed in Build #59109! 🎉


🧪   To try this PR locally:

bunx bun-pr 31201

That installs a local version of the PR into your bun-31201 executable, so you can run:

bun-31201 --bun

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a script to strip long Rust comments, removes extensive comments across the codebase, and introduces targeted functional updates: richer AST Expr/Data APIs and equality, expanded fmt/util/strings and Unicode handling, allocator/BSS refactors, bundler/linker borrow-safety changes, and a Windows ANSI terminal capability check.

Changes

Automated comment stripping and synchronized code updates

Layer / File(s) Summary
Scripted comment removal CLI
scripts/strip-long-rs-comments.ts
Plans/applies deletions of long comment-only Rust line blocks with exemptions; supports dry-run and tracked file discovery.
AST core surface updates
src/ast/expr.rs, related AST files
Adds Expr accessors/mutators, Data tagged union with clone/deep_clone and deterministic hashing, equality kinds, and improved not-folding.
Core formatting/utilities/strings
src/bun_core/fmt.rs, src/bun_core/util.rs, src/bun_core/string/**
Extensive formatting/parsing utilities, JSON escaping, Raw/SliceCursor, itoa helpers; large util port (FFI strings, IO, sync, time, spawn, argv); Unicode/BOM conversion helpers.
Allocator/BSS refactors
src/bun_alloc/**
Platform MAX_ALIGN_T, vtable free_only, mimalloc/global helpers, BSS singleton infra and containers, Mutex/AllocError; MimallocArena refactors.
Bundler/linker pipeline tweaks
src/bundler/**
Borrow-safety refactors across linking/codegen, Windows path normalization fix, parse task pipeline and plugin before-parse FFI, wrapper generation macro, deinit/arena ownership, added field on ImportTrackerIterator.
Windows terminal capability
src/bun_core/Progress.rs
Detects ANSI support using GetConsoleMode/ENABLE_VIRTUAL_TERMINAL_PROCESSING on Windows; non-Windows via output_sink().

Possibly related PRs

  • oven-sh/bun#30877: Similar pass rewording/removing Zig-port comments across files like ast allocator and analytics schema.

Suggested reviewers

  • Jarred-Sumner
  • alii
  • RiskyMH

Comment thread scripts/strip-long-rs-comments.ts Outdated
Comment thread scripts/strip-long-rs-comments.ts Outdated
Comment thread scripts/verify-baseline-static/src/main.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/strip-long-rs-comments.ts`:
- Around line 52-54: isBlank currently treats lines with a trailing CR as
non-blank and the file splitter/joiner normalizes CRLF to LF; update the logic
so you preserve original EOLs and correctly detect blank lines: modify isBlank
to ignore a trailing '\r' when testing emptiness (or normalize line endings when
checking), change any split("\n") usage (see the file-splitting logic around the
blocks noted and the join/write logic) to split using a CRLF-aware pattern (or
detect file EOL once from the raw content), and when writing use the detected
original EOL sequence so rewritten files keep CRLF on Windows. Ensure you
reference and update the functions/methods that perform splitting/joining as
well as isBlank to keep behavior consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2555038e-d0eb-47f6-9cbd-d2b3db353e0e

📥 Commits

Reviewing files that changed from the base of the PR and between b3886f3 and 11d5016.

📒 Files selected for processing (1)
  • scripts/strip-long-rs-comments.ts

Comment thread scripts/strip-long-rs-comments.ts
Comment thread scripts/strip-long-rs-comments.ts Outdated
@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch from 11d5016 to 3f38be0 Compare May 22, 2026 05:28
Comment thread scripts/strip-long-rs-comments.ts
Comment thread scripts/strip-long-rs-comments.ts

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my earlier findings are addressed — thanks. I'm deferring to a human reviewer not because of any remaining bug, but because deleting ~85k lines of explanatory comments across 1,000+ files is a documentation-policy decision that a maintainer should explicitly sign off on.

Extended reasoning...

Overview

This PR adds scripts/strip-long-rs-comments.ts and applies it tree-wide, removing every //-style comment block of 4+ consecutive lines from tracked .rs files (1,082 files, ~85,408 deletions). Exemptions: top-of-file headers, HOST_EXPORT(...) codegen markers (line-preserved), SAFETY/# Safety blocks (block-preserved), and the vendor/, packages/, scripts/verify-baseline-static/ trees. The script itself, an autofix.ci cargo fmt pass, and two small hand-authored follow-up commits round out the change set.

Prior review history

I left six inline findings across four review passes; all were resolved:

  • SAFETY: blocks stripped → would break clippy::undocumented_unsafe_blocks = deny — fixed via PROTECTED_BLOCK (3f38be0).
  • packages/bun-native-plugin-rs docs.rs API docs stripped — fixed via SKIP_PREFIXES (3f38be0).
  • scripts/verify-baseline-static/CLAUDE.md line refs invalidated — fixed via SKIP_PREFIXES (3f38be0).
  • --min arg-parsing bug dropping first positional — fixed (3f38be0).
  • Output not rustfmt-clean — fixed via autofix.ci (8aa3dc3).
  • Orphaned #[allow(if_same_then_else)] in lifecycle_script_runner.rs — fixed (0e6c09a).

No new issues found at HEAD (0e6c09a). CI shows one unrelated-looking flake (napi.test.ts segfault on Windows aarch64).

Security risks

None. Pure comment deletion; no logic, control flow, FFI surface, or auth path changes. The script runs locally over git ls-files output.

Level of scrutiny

High — but for policy reasons, not correctness. The transform is mechanical and verified (builds, clippy-clean, rustfmt-clean, HOST_EXPORT preserved). What's being removed, however, is the bulk of the codebase's "why" documentation: PORT NOTE rationale, Zig-spec divergence explanations, soundness arguments, perf annotations, layering notes. Whether that trade-off is desirable is a maintainer call, not something a bot should rubber-stamp.

Other factors

  • The 300-file diff window means ~780 changed files are not visible inline; a human spot-checking a few subsystems they own is the only practical review.
  • The hand-authored commits (0356627, 0e6c09a) on top of the scripted output are small and have been reviewed.
  • This is well outside the "simple, mechanical, obvious" threshold for bot approval purely on scale (1,082 files).

@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 2 times, most recently from 5f27d37 to fe451c8 Compare May 23, 2026 00:42

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all four rounds of feedback — I have nothing further on the script or the applied diff. Given the scale (1073 files, ~71K lines of design rationale / PORT NOTEs / upstream-esbuild comments removed) this is a codebase-wide documentation policy call that warrants a human sign-off, and the robobun CI comment still shows platform-specific lint failures (unused label / unnecessary unsafe / unreachable pub) on the FreeBSD / aarch64-musl / Android builds for 5f27d37.

Extended reasoning...

Overview

This PR adds scripts/strip-long-rs-comments.ts and applies it across the entire Rust tree: every //-style comment block of 4+ consecutive lines is removed from ~1073 tracked .rs files (~71K deletions, ~600 insertions), with carve-outs for top-of-file headers, // HOST_EXPORT(...) codegen markers, SAFETY/# Safety blocks (clippy deny), and the vendor/ / packages/ / scripts/verify-baseline-static/ trees. The PR description verifies that relative to main only comment-only lines change apart from cargo fmt reflow and a 2-line note in lifecycle_script_runner.rs.

I previously left four rounds of inline comments on this PR (SAFETY-block stripping breaking clippy, packages/ docs.rs regression, verify-baseline-static CLAUDE.md staleness, the --min arg-parse off-by-one, rustfmt cleanliness, and the orphaned #[allow(if_same_then_else)]). All were fixed and the threads resolved.

Security risks

None identified. This is comment-only deletion plus a dev-tool script; no runtime code paths, auth, crypto, or input handling are affected. The script itself only operates on git ls-files '*.rs' output and is not exposed to untrusted input.

Level of scrutiny

High — requires human review. While the mechanical transform is well-verified (script-driven, idempotent, cargo fmt --check clean, HOST_EXPORT/SAFETY preserved, debug build + smoke test pass), the decision to delete ~71K lines of design rationale, PORT NOTEs, esbuild-upstream explanatory comments, and TODO(port) markers from every Rust file is a significant documentation-policy change that a maintainer should explicitly sign off on. This is not a change a bot should approve regardless of mechanical correctness.

Other factors

  • The robobun CI status (last updated 5:42 PM PT May 22, after the fix commits) still reports build-rust failures on FreeBSD x64/aarch64, aarch64-musl, and aarch64-android for commit 5f27d37: unnecessary unsafe block in bun_core/lib.rs, unused label in spawn/process.rs and install/npm.rs, and unreachable pub in threading/Futex.rs. These are platform-gated code paths and may need follow-up.
  • The diff is too large (300+ files shown, 1073 total) to spot-check every removed block for load-bearing content beyond the SAFETY/HOST_EXPORT classes already protected.

@robobun

robobun commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

Status — head 1afc868, freshly rebased onto current main (7069b30929): 0 behind, 1 ahead, mergeable, no conflicts (git merge-tree clean). Mechanics done and re-verified on this head; the only thing outstanding is a maintainer's call on landing (or closing) it.

This refresh picked up 2 upstream commits — #31569 (yaml test.todo cleanups) and #31519 (node:crypto X509 serialNumber/modulus hex uppercase) — conflicting on src/parsers/yaml.rs and src/runtime/api/YAMLObject.rs. Resolved the usual way — re-derive the whole strip from current main: reset to main, apply scripts/strip-long-rs-comments.ts, cargo fmt, then restore the four sub-threshold notes below — so the upstream code changes are preserved exactly and only comments are stripped.

Proof the diff is comments-only (re-run for this head): a fresh checkout of main with the script applied and cargo fmt'd is byte-identical to this branch across every .rs file except four bodies that keep a ≤3-line slice of their original comment — each required so a deny-level clippy lint doesn't fire on the body the strip would otherwise empty:

  • jsc/ConsoleObject.rsif token == PercentTag::O {}clippy::needless_ifs
  • js_parser/p.rs — the two Substitution::Failure else if arms, identical once their explaining comments are gone → clippy::if_same_then_else
  • install/lifecycle_script_runner.rs — the finished_installing else arm (same body as the if arm) → clippy::if_same_then_else
  • resolver/resolver.rs — the tsconfig paths-merge else arm → clippy::needless_else

Each note is a verbatim sub-threshold slice of the comment that was already on main, so the if/else structure is unchanged and the diff stays comments-only. The only non-.rs files added are scripts/strip-long-rs-comments.ts and test/internal/strip-long-rs-comments.test.ts. Verified locally: full-workspace cargo clippy --workspace --no-deps clean under -D warnings on the pinned nightly; cargo fmt --all -- --check clean; bun bd links and the binary runs (-e 'console.log(1+1)'2, %o formatter correct); // HOST_EXPORT(...) markers 90 = 90; SAFETY/# Safety header lines 12761 = 12761 (none removed); zero TODO/FIXME/HACK/XXX in added lines; strip --dry = 0 (idempotent); test/internal/strip-long-rs-comments.test.ts → 5 pass / 0 fail (incl. the tree-is-clean scan).

What I need from a maintainer: the diff is green and bot-reviewed; 0 unresolved review threads. This PR re-conflicts whenever a .rs file lands on main, so it wants merging shortly after a refresh — or closing if the team would rather keep the long inline comments. Comment here if another refresh is needed right before merging and I'll take care of it.

Comment thread scripts/strip-long-rs-comments.ts Outdated
@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 3 times, most recently from 347d615 to fb5e8fa Compare May 24, 2026 04:15

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All prior review feedback has been addressed and the script's application now verifies clean (SAFETY blocks preserved, packages/ and verify-baseline-static/ excluded, fmt/clippy pass, idempotent). I'm deferring rather than approving because mass-stripping ~70K lines of internal documentation across 1,074 files is a project-wide documentation-policy decision that a maintainer should explicitly sign off on — the mechanical correctness is established, but whether the tree should lose this commentary isn't a call for a bot to make.

Extended reasoning...

Overview

This PR adds scripts/strip-long-rs-comments.ts and applies it tree-wide: every //-style comment block of 4+ consecutive lines is removed from tracked *.rs files, with carve-outs for top-of-file headers, HOST_EXPORT codegen markers, and SAFETY/# Safety blocks. Net: 1,074 files changed, ~71K deletions, ~650 insertions (the script + test + cargo fmt reflow + a handful of hand-restored short notes). Three rebases onto main were resolved by re-running the script on the upstream files, so upstream code changes are preserved exactly.

Security risks

None. The diff is comment-only on the .rs side (verified by the PR's own checks: zero non-comment deletions, raw-string literals untouched, cargo fmt --check clean, clippy parity with main). The new script is a dev tool that reads/writes files passed on the CLI or from git ls-files — no network, no privilege, no untrusted input.

Level of scrutiny

High — not for correctness risk, but for policy weight. The mechanical transform is well-verified (idempotency test, HOST_EXPORT/SAFETY preservation counts, build+clippy green, all seven of my prior inline findings fixed and resolved). What remains is a judgment call: this strips a large body of PORT NOTE, PERF(port), design-rationale, and Zig-divergence commentary that was deliberately written during the Rust port. Whether that commentary is now noise (port complete, notes stale) or still load-bearing (explains non-obvious invariants, divergences from Zig) is a maintainer-level decision about how the codebase should be documented going forward.

Other factors

  • All inline review threads (mine and CodeRabbit's) are resolved.
  • The PR author's own status comment explicitly flags "explicit maintainer sign-off on the documentation-policy decision itself" as the remaining gate.
  • CI is green on every lane that ran (one macOS lane expired without executing).
  • The change is trivially revertable per-file but practically irreversible in aggregate (70K lines of context won't be rewritten).
  • No CODEOWNERS file consulted, but a 1,074-file change touching every src/ subtree effectively touches everyone's code.

@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 3 times, most recently from 737377c to 4bfc0db Compare May 25, 2026 00:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/bun_core/util.rs`:
- Around line 5018-5058: The get_boundary function treats semicolons inside
quoted boundary values as terminators because it uses index_of_char(begin, b';')
to find the end; update get_boundary to reuse index_of_unquoted_semicolon (or an
equivalent unquoted-semicolon scan) when computing end so quoted boundaries like
boundary="a;b" are handled correctly. Specifically, after determining begin (the
substring after "boundary="), call index_of_unquoted_semicolon(begin) (falling
back to begin.len() if None) instead of
crate::strings_impl::index_of_char(begin, b';'), and keep the existing
quote-handling logic that strips surrounding quotes and validates matching
quotes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5521e7a2-ce02-4a89-a694-eec97ed32a5f

📥 Commits

Reviewing files that changed from the base of the PR and between 11d5016 and 4bfc0db.

📒 Files selected for processing (259)
  • scripts/strip-long-rs-comments.ts
  • src/analytics/lib.rs
  • src/analytics/schema.rs
  • src/api/lib.rs
  • src/ast/ast_memory_allocator.rs
  • src/ast/ast_result.rs
  • src/ast/b.rs
  • src/ast/base.rs
  • src/ast/binding.rs
  • src/ast/char_freq.rs
  • src/ast/e.rs
  • src/ast/expr.rs
  • src/ast/fold_string_addition.rs
  • src/ast/g.rs
  • src/ast/import_record.rs
  • src/ast/known_global.rs
  • src/ast/lexer_tables.rs
  • src/ast/lib.rs
  • src/ast/loader.rs
  • src/ast/new_store.rs
  • src/ast/nodes.rs
  • src/ast/op.rs
  • src/ast/runtime.rs
  • src/ast/s.rs
  • src/ast/scope.rs
  • src/ast/server_component_boundary.rs
  • src/ast/stmt.rs
  • src/ast/symbol.rs
  • src/ast/transpiler_cache.rs
  • src/ast/ts.rs
  • src/base64/lib.rs
  • src/boringssl/lib.rs
  • src/boringssl_sys/boringssl.rs
  • src/boringssl_sys/lib.rs
  • src/brotli/lib.rs
  • src/brotli_sys/brotli_c.rs
  • src/bun_alloc/MaxHeapAllocator.rs
  • src/bun_alloc/MimallocArena.rs
  • src/bun_alloc/NullableAllocator.rs
  • src/bun_alloc/ast_alloc.rs
  • src/bun_alloc/c_thunks.rs
  • src/bun_alloc/fallback/z.rs
  • src/bun_alloc/hashbrown_bridge.rs
  • src/bun_alloc/heap_breakdown.rs
  • src/bun_alloc/lib.rs
  • src/bun_alloc/maybe_owned.rs
  • src/bun_alloc/memory.rs
  • src/bun_alloc/stack_fallback.rs
  • src/bun_bin/lib.rs
  • src/bun_bin/phase_c_exports.rs
  • src/bun_core/Global.rs
  • src/bun_core/Progress.rs
  • src/bun_core/atomic_cell.rs
  • src/bun_core/bounded_array.rs
  • src/bun_core/build.rs
  • src/bun_core/debug.rs
  • src/bun_core/deprecated.rs
  • src/bun_core/env.rs
  • src/bun_core/env_var.rs
  • src/bun_core/external_shared.rs
  • src/bun_core/feature_flags.rs
  • src/bun_core/fmt.rs
  • src/bun_core/heap.rs
  • src/bun_core/hint.rs
  • src/bun_core/lib.rs
  • src/bun_core/output.rs
  • src/bun_core/result.rs
  • src/bun_core/string/HashedString.rs
  • src/bun_core/string/MutableString.rs
  • src/bun_core/string/PathString.rs
  • src/bun_core/string/SmolStr.rs
  • src/bun_core/string/StringBuilder.rs
  • src/bun_core/string/StringJoiner.rs
  • src/bun_core/string/identifier.rs
  • src/bun_core/string/immutable.rs
  • src/bun_core/string/immutable/escapeHTML.rs
  • src/bun_core/string/immutable/exact_size_matcher.rs
  • src/bun_core/string/immutable/grapheme.rs
  • src/bun_core/string/immutable/unicode.rs
  • src/bun_core/string/immutable/visible.rs
  • src/bun_core/string/mod.rs
  • src/bun_core/string/wtf.rs
  • src/bun_core/thread_id.rs
  • src/bun_core/util.rs
  • src/bun_core/windows_sys.rs
  • src/bun_core_macros/lib.rs
  • src/bun_output_tags/lib.rs
  • src/bundler/AstBuilder.rs
  • src/bundler/BundleThread.rs
  • src/bundler/Chunk.rs
  • src/bundler/Graph.rs
  • src/bundler/HTMLImportManifest.rs
  • src/bundler/HTMLScanner.rs
  • src/bundler/LinkerContext.rs
  • src/bundler/LinkerGraph.rs
  • src/bundler/OutputFile.rs
  • src/bundler/ParseTask.rs
  • src/bundler/ServerComponentParseTask.rs
  • src/bundler/ThreadPool.rs
  • src/bundler/analyze_transpiled_module.rs
  • src/bundler/barrel_imports.rs
  • src/bundler/bundle_v2.rs
  • src/bundler/bundled_ast.rs
  • src/bundler/cache.rs
  • src/bundler/defines.rs
  • src/bundler/entry_points.rs
  • src/bundler/lib.rs
  • src/bundler/linker.rs
  • src/bundler/linker_context/MetafileBuilder.rs
  • src/bundler/linker_context/StaticRouteVisitor.rs
  • src/bundler/linker_context/computeChunks.rs
  • src/bundler/linker_context/computeCrossChunkDependencies.rs
  • src/bundler/linker_context/convertStmtsForChunk.rs
  • src/bundler/linker_context/convertStmtsForChunkForDevServer.rs
  • src/bundler/linker_context/doStep5.rs
  • src/bundler/linker_context/findAllImportedPartsInJSOrder.rs
  • src/bundler/linker_context/findImportedCSSFilesInJSOrder.rs
  • src/bundler/linker_context/findImportedFilesInCSSOrder.rs
  • src/bundler/linker_context/generateChunksInParallel.rs
  • src/bundler/linker_context/generateCodeForFileInChunkJS.rs
  • src/bundler/linker_context/generateCodeForLazyExport.rs
  • src/bundler/linker_context/generateCompileResultForCssChunk.rs
  • src/bundler/linker_context/generateCompileResultForHtmlChunk.rs
  • src/bundler/linker_context/generateCompileResultForJSChunk.rs
  • src/bundler/linker_context/postProcessCSSChunk.rs
  • src/bundler/linker_context/postProcessJSChunk.rs
  • src/bundler/linker_context/prepareCssAstsForChunk.rs
  • src/bundler/linker_context/renameSymbolsInChunk.rs
  • src/bundler/linker_context/scanImportsAndExports.rs
  • src/bundler/linker_context/writeOutputFilesToDisk.rs
  • src/bundler/options.rs
  • src/bundler/transpiler.rs
  • src/bundler/ungate_support.rs
  • src/bundler_jsc/PluginRunner.rs
  • src/bundler_jsc/analyze_jsc.rs
  • src/bundler_jsc/lib.rs
  • src/bunfig/arguments.rs
  • src/bunfig/bunfig.rs
  • src/cares_sys/c_ares.rs
  • src/cares_sys/lib.rs
  • src/clap/args.rs
  • src/clap/comptime.rs
  • src/clap/lib.rs
  • src/clap/streaming.rs
  • src/clap_macros/lib.rs
  • src/collections/StaticHashMap.rs
  • src/collections/array_hash_map.rs
  • src/collections/array_list.rs
  • src/collections/bit_set.rs
  • src/collections/comptime_string_map.rs
  • src/collections/hive_array.rs
  • src/collections/identity_context.rs
  • src/collections/lib.rs
  • src/collections/linear_fifo.rs
  • src/collections/multi_array_list.rs
  • src/collections/pool.rs
  • src/collections/string_map.rs
  • src/collections/vec_ext.rs
  • src/collections/zig_hash_map.rs
  • src/crash_handler/CPUFeatures.rs
  • src/crash_handler/handle_oom.rs
  • src/crash_handler/lib.rs
  • src/csrf/lib.rs
  • src/css/context.rs
  • src/css/css_modules.rs
  • src/css/css_parser.rs
  • src/css/declaration.rs
  • src/css/generics.rs
  • src/css/lib.rs
  • src/css/media_query.rs
  • src/css/printer.rs
  • src/css/properties/align.rs
  • src/css/properties/animation.rs
  • src/css/properties/background.rs
  • src/css/properties/border.rs
  • src/css/properties/border_image.rs
  • src/css/properties/border_radius.rs
  • src/css/properties/box_shadow.rs
  • src/css/properties/css_modules.rs
  • src/css/properties/custom.rs
  • src/css/properties/flex.rs
  • src/css/properties/font.rs
  • src/css/properties/grid.rs
  • src/css/properties/margin_padding.rs
  • src/css/properties/masking.rs
  • src/css/properties/mod.rs
  • src/css/properties/outline.rs
  • src/css/properties/overflow.rs
  • src/css/properties/prefix_handler.rs
  • src/css/properties/properties_generated.rs
  • src/css/properties/properties_impl.rs
  • src/css/properties/shape.rs
  • src/css/properties/size.rs
  • src/css/properties/transform.rs
  • src/css/properties/transition.rs
  • src/css/rules/container.rs
  • src/css/rules/document.rs
  • src/css/rules/font_face.rs
  • src/css/rules/import.rs
  • src/css/rules/keyframes.rs
  • src/css/rules/layer.rs
  • src/css/rules/media.rs
  • src/css/rules/mod.rs
  • src/css/rules/page.rs
  • src/css/rules/property.rs
  • src/css/rules/scope.rs
  • src/css/rules/style.rs
  • src/css/rules/supports.rs
  • src/css/rules/tailwind.rs
  • src/css/rules/viewport.rs
  • src/css/selectors/builder.rs
  • src/css/selectors/mod.rs
  • src/css/selectors/parser.rs
  • src/css/selectors/selector.rs
  • src/css/small_list.rs
  • src/css/targets.rs
  • src/css/values/alpha.rs
  • src/css/values/angle.rs
  • src/css/values/calc.rs
  • src/css/values/color.rs
  • src/css/values/css_string.rs
  • src/css/values/easing.rs
  • src/css/values/gradient.rs
  • src/css/values/ident.rs
  • src/css/values/image.rs
  • src/css/values/length.rs
  • src/css/values/mod.rs
  • src/css/values/percentage.rs
  • src/css/values/rect.rs
  • src/css/values/size.rs
  • src/css/values/syntax.rs
  • src/css/values/time.rs
  • src/css/values/url.rs
  • src/css_derive/lib.rs
  • src/css_jsc/color_js.rs
  • src/css_jsc/css_internals.rs
  • src/css_jsc/lib.rs
  • src/dispatch/lib.rs
  • src/dns/lib.rs
  • src/dotenv/env_loader.rs
  • src/errno/lib.rs
  • src/errno/linux_errno.rs
  • src/errno/windows_errno.rs
  • src/event_loop/AnyEventLoop.rs
  • src/event_loop/AnyTask.rs
  • src/event_loop/AnyTaskWithExtraContext.rs
  • src/event_loop/AutoFlusher.rs
  • src/event_loop/ConcurrentTask.rs
  • src/event_loop/DeferredTaskQueue.rs
  • src/event_loop/EventLoopTimer.rs
  • src/event_loop/ManagedTask.rs
  • src/event_loop/MiniEventLoop.rs
  • src/event_loop/SpawnSyncEventLoop.rs
  • src/event_loop/lib.rs
  • src/exe_format/elf.rs
  • src/exe_format/lib.rs
  • src/exe_format/macho.rs
  • src/exe_format/macho_types.rs
  • src/exe_format/pe.rs
💤 Files with no reviewable changes (76)
  • src/ast/ts.rs
  • src/bun_alloc/MaxHeapAllocator.rs
  • src/ast/ast_result.rs
  • src/bun_alloc/c_thunks.rs
  • src/boringssl_sys/lib.rs
  • src/ast/s.rs
  • src/bun_core/hint.rs
  • src/bun_alloc/memory.rs
  • src/bundler/linker_context/convertStmtsForChunkForDevServer.rs
  • src/bun_core/build.rs
  • src/bun_alloc/fallback/z.rs
  • src/bun_core/string/MutableString.rs
  • src/bundler/linker_context/findAllImportedPartsInJSOrder.rs
  • src/api/lib.rs
  • src/bundler/HTMLImportManifest.rs
  • src/bun_core/atomic_cell.rs
  • src/brotli_sys/brotli_c.rs
  • src/ast/b.rs
  • src/bundler/linker_context/StaticRouteVisitor.rs
  • src/ast/transpiler_cache.rs
  • src/ast/op.rs
  • src/ast/import_record.rs
  • src/bun_core/string/immutable/escapeHTML.rs
  • src/bun_core/external_shared.rs
  • src/bundler/linker_context/doStep5.rs
  • src/ast/fold_string_addition.rs
  • src/bun_core/string/StringBuilder.rs
  • src/ast/loader.rs
  • src/bundler/linker_context/MetafileBuilder.rs
  • src/ast/base.rs
  • src/bun_core/deprecated.rs
  • src/bun_alloc/stack_fallback.rs
  • src/ast/ast_memory_allocator.rs
  • src/boringssl/lib.rs
  • src/bundler/HTMLScanner.rs
  • src/bundler/linker_context/findImportedCSSFilesInJSOrder.rs
  • src/ast/stmt.rs
  • src/bundler/bundled_ast.rs
  • src/ast/g.rs
  • src/ast/lexer_tables.rs
  • src/bun_core/result.rs
  • src/bun_core/string/StringJoiner.rs
  • src/bun_alloc/NullableAllocator.rs
  • src/bundler/ServerComponentParseTask.rs
  • src/bundler/linker_context/computeCrossChunkDependencies.rs
  • src/bundler/Graph.rs
  • src/bundler/linker_context/convertStmtsForChunk.rs
  • src/bundler/AstBuilder.rs
  • src/bun_core_macros/lib.rs
  • src/bun_bin/lib.rs
  • src/bundler/lib.rs
  • src/bundler/linker_context/computeChunks.rs
  • src/bundler/LinkerGraph.rs
  • src/bun_core/bounded_array.rs
  • src/bun_alloc/hashbrown_bridge.rs
  • src/bun_core/Progress.rs
  • src/bundler/OutputFile.rs
  • src/bundler/ThreadPool.rs
  • src/bundler/linker.rs
  • src/bundler/analyze_transpiled_module.rs
  • src/bundler/defines.rs
  • src/ast/runtime.rs
  • src/bundler/cache.rs
  • src/bundler/barrel_imports.rs
  • src/bundler/entry_points.rs
  • src/bundler/Chunk.rs
  • src/bun_alloc/ast_alloc.rs
  • src/bun_core/heap.rs
  • src/ast/nodes.rs
  • src/bundler/ParseTask.rs
  • src/bun_core/fmt.rs
  • src/bun_core/string/immutable/unicode.rs
  • src/bundler/LinkerContext.rs
  • src/bun_core/string/immutable.rs
  • src/bundler/bundle_v2.rs
  • src/bun_core/string/wtf.rs

Comment thread src/bun_core/util.rs

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my earlier feedback is addressed and I found nothing new, but this is a 1062-file / -70k-line codebase-wide policy change (stripping port-note / rationale comments) that should get a human sign-off rather than a bot approval — also note transpiler.test.js is now failing on all three Windows lanes on the current head, which wasn't the case on the pre-rebase head.

Extended reasoning...

Overview

This PR adds scripts/strip-long-rs-comments.ts and applies it across the tree: 1062 files changed, +649 / -70,930. The script removes every //-style comment block of 4+ consecutive lines from tracked *.rs files, with carve-outs for top-of-file headers, // HOST_EXPORT(...) codegen markers, and SAFETY / # Safety blocks; vendor/, packages/, and scripts/verify-baseline-static/ are skipped. The .rs diff is verified comments-only (plus the cargo fmt reflow that follows block removal). The PR has been rebased onto main seven times, each conflict resolved by taking main's file and re-running the script.

Security risks

None. The diff removes only comment lines and adjacent blank lines; no executable code paths change. The script itself is a one-shot dev tool that shells out to git ls-files and reads/writes files in-tree — not shipped, not exposed to untrusted input.

Level of scrutiny

High — needs human review. While the transformation is mechanical and well-verified (idempotency test, cargo fmt --check clean, all HOST_EXPORT/SAFETY markers preserved), the decision to strip 70k lines of inline documentation — including extensive PORT NOTE: / TODO(port): comments explaining why the Rust port diverges from Zig, layout-guard rationales, and perf-tradeoff notes — is a codebase-wide policy call that a maintainer should explicitly sign off on. This is well outside the "simple, mechanical, obvious" threshold for bot approval.

Other factors

  • All seven of my prior inline findings are resolved (SAFETY-block stripping, packages/ docs.rs exposure, --min CLI bug, verify-baseline-static CLAUDE.md refs, rustfmt cleanliness, the orphaned #[allow] in lifecycle_script_runner.rs, and the case-insensitive Safety: regex). The script and PR description now reflect each fix.
  • CI is not green on the current head: test/bundler/transpiler/transpiler.test.js fails on all three Windows lanes (2019 x64, 2019 x64-baseline, 11 aarch64) on commit 4bfc0dbb. The previous head's only failures were expired macOS runners, so this is a new regression introduced by (or surfaced by) the seventh rebase and worth investigating before merge.
  • The author has noted this PR re-conflicts on every .rs change to main and needs to merge shortly after CI goes green — which argues for a maintainer looking at it promptly rather than for relaxing the review bar.

@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 5 times, most recently from 6082852 to 973f050 Compare May 26, 2026 05:18
Comment thread scripts/strip-long-rs-comments.ts
Comment thread src/bundler/LinkerContext.rs
@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 2 times, most recently from 79d5e4a to 1fbbce0 Compare May 27, 2026 19:18
Comment thread scripts/strip-long-rs-comments.ts
Comment thread scripts/strip-long-rs-comments.ts
@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 3 times, most recently from 05e2855 to 45fb3db Compare May 29, 2026 01:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/bundler/Chunk.rs (1)

863-869: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard pooled path-buffer slicing for long paths.

Lines 864-866 can panic when file_path.len() exceeds the pooled buffer capacity (file_path_buf[..n]). That turns long-path inputs into a hard runtime failure.

🛠️ Proposed safe fallback
-                            let file_path: &[u8] = {
-                                let n = file_path.len();
-                                let dst = &mut file_path_buf[..n];
-                                dst.copy_from_slice(file_path);
-                                bun_paths::resolve_path::platform_to_posix_in_place::<u8>(dst);
-                                dst
-                            };
+                            let mut file_path_heap: Vec<u8> = Vec::new();
+                            let file_path: &[u8] = {
+                                let n = file_path.len();
+                                if n <= file_path_buf.len() {
+                                    let dst = &mut file_path_buf[..n];
+                                    dst.copy_from_slice(file_path);
+                                    bun_paths::resolve_path::platform_to_posix_in_place::<u8>(dst);
+                                    dst
+                                } else {
+                                    file_path_heap.extend_from_slice(file_path);
+                                    bun_paths::resolve_path::platform_to_posix_in_place::<u8>(
+                                        &mut file_path_heap,
+                                    );
+                                    &file_path_heap
+                                }
+                            };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/bundler/Chunk.rs` around lines 863 - 869, The current slice-copy into the
pooled buffer can panic for long paths: guard the use of file_path_buf by
checking if file_path.len() <= file_path_buf.len() before slicing; if it fits,
copy into &mut file_path_buf[..n] and call
bun_paths::resolve_path::platform_to_posix_in_place::<u8>(dst) as before,
otherwise allocate a heap buffer (e.g., Vec<u8> with capacity n), copy file_path
into that heap buffer and call platform_to_posix_in_place on it and use its
slice; reference the variables/file names file_path, file_path_buf and the
function bun_paths::resolve_path::platform_to_posix_in_place::<u8> when making
the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/strip-long-rs-comments.ts`:
- Line 230: The write path recomputes the transform by calling
stripLongComments(src, min) again when writing the file; instead, reuse the
previously computed edits (the edits variable that was produced around line 215)
and apply those edits to src to produce the final text, then pass that resulting
string to writeFileSync(file, ...). Locate the earlier computation of edits and
the writeFileSync(file, stripLongComments(src, min)) call and replace the second
call with applying edits (or using the existing API that returns the edited
text) so the expensive transform is not run twice.

---

Outside diff comments:
In `@src/bundler/Chunk.rs`:
- Around line 863-869: The current slice-copy into the pooled buffer can panic
for long paths: guard the use of file_path_buf by checking if file_path.len() <=
file_path_buf.len() before slicing; if it fits, copy into &mut
file_path_buf[..n] and call
bun_paths::resolve_path::platform_to_posix_in_place::<u8>(dst) as before,
otherwise allocate a heap buffer (e.g., Vec<u8> with capacity n), copy file_path
into that heap buffer and call platform_to_posix_in_place on it and use its
slice; reference the variables/file names file_path, file_path_buf and the
function bun_paths::resolve_path::platform_to_posix_in_place::<u8> when making
the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9c266e56-a03e-485a-b90e-cdf8afdcc8bb

📥 Commits

Reviewing files that changed from the base of the PR and between 79d5e4a and 45fb3db.

📒 Files selected for processing (270)
  • scripts/strip-long-rs-comments.ts
  • src/analytics/lib.rs
  • src/analytics/schema.rs
  • src/api/lib.rs
  • src/ast/ast_memory_allocator.rs
  • src/ast/ast_result.rs
  • src/ast/b.rs
  • src/ast/base.rs
  • src/ast/binding.rs
  • src/ast/char_freq.rs
  • src/ast/e.rs
  • src/ast/expr.rs
  • src/ast/fold_string_addition.rs
  • src/ast/g.rs
  • src/ast/import_record.rs
  • src/ast/known_global.rs
  • src/ast/lexer_tables.rs
  • src/ast/lib.rs
  • src/ast/loader.rs
  • src/ast/new_store.rs
  • src/ast/nodes.rs
  • src/ast/op.rs
  • src/ast/runtime.rs
  • src/ast/s.rs
  • src/ast/scope.rs
  • src/ast/server_component_boundary.rs
  • src/ast/stmt.rs
  • src/ast/symbol.rs
  • src/ast/transpiler_cache.rs
  • src/ast/ts.rs
  • src/base64/lib.rs
  • src/boringssl/lib.rs
  • src/boringssl_sys/boringssl.rs
  • src/boringssl_sys/lib.rs
  • src/brotli/lib.rs
  • src/brotli_sys/brotli_c.rs
  • src/bun_alloc/MaxHeapAllocator.rs
  • src/bun_alloc/MimallocArena.rs
  • src/bun_alloc/NullableAllocator.rs
  • src/bun_alloc/ast_alloc.rs
  • src/bun_alloc/c_thunks.rs
  • src/bun_alloc/fallback/z.rs
  • src/bun_alloc/hashbrown_bridge.rs
  • src/bun_alloc/heap_breakdown.rs
  • src/bun_alloc/lib.rs
  • src/bun_alloc/maybe_owned.rs
  • src/bun_alloc/memory.rs
  • src/bun_alloc/stack_fallback.rs
  • src/bun_bin/lib.rs
  • src/bun_bin/phase_c_exports.rs
  • src/bun_core/Global.rs
  • src/bun_core/Progress.rs
  • src/bun_core/atomic_cell.rs
  • src/bun_core/bounded_array.rs
  • src/bun_core/build.rs
  • src/bun_core/debug.rs
  • src/bun_core/deprecated.rs
  • src/bun_core/env.rs
  • src/bun_core/env_var.rs
  • src/bun_core/external_shared.rs
  • src/bun_core/feature_flags.rs
  • src/bun_core/fmt.rs
  • src/bun_core/heap.rs
  • src/bun_core/hint.rs
  • src/bun_core/lib.rs
  • src/bun_core/output.rs
  • src/bun_core/result.rs
  • src/bun_core/string/HashedString.rs
  • src/bun_core/string/MutableString.rs
  • src/bun_core/string/PathString.rs
  • src/bun_core/string/SmolStr.rs
  • src/bun_core/string/StringBuilder.rs
  • src/bun_core/string/StringJoiner.rs
  • src/bun_core/string/identifier.rs
  • src/bun_core/string/immutable.rs
  • src/bun_core/string/immutable/exact_size_matcher.rs
  • src/bun_core/string/immutable/unicode.rs
  • src/bun_core/string/immutable/visible.rs
  • src/bun_core/string/mod.rs
  • src/bun_core/string/wtf.rs
  • src/bun_core/thread_id.rs
  • src/bun_core/util.rs
  • src/bun_core/windows_sys.rs
  • src/bun_core_macros/lib.rs
  • src/bun_output_tags/lib.rs
  • src/bundler/AstBuilder.rs
  • src/bundler/BundleThread.rs
  • src/bundler/Chunk.rs
  • src/bundler/Graph.rs
  • src/bundler/HTMLImportManifest.rs
  • src/bundler/HTMLScanner.rs
  • src/bundler/LinkerContext.rs
  • src/bundler/LinkerGraph.rs
  • src/bundler/OutputFile.rs
  • src/bundler/ParseTask.rs
  • src/bundler/ServerComponentParseTask.rs
  • src/bundler/ThreadPool.rs
  • src/bundler/analyze_transpiled_module.rs
  • src/bundler/barrel_imports.rs
  • src/bundler/bundle_v2.rs
  • src/bundler/bundled_ast.rs
  • src/bundler/cache.rs
  • src/bundler/defines.rs
  • src/bundler/entry_points.rs
  • src/bundler/lib.rs
  • src/bundler/linker.rs
  • src/bundler/linker_context/MetafileBuilder.rs
  • src/bundler/linker_context/StaticRouteVisitor.rs
  • src/bundler/linker_context/computeChunks.rs
  • src/bundler/linker_context/computeCrossChunkDependencies.rs
  • src/bundler/linker_context/convertStmtsForChunk.rs
  • src/bundler/linker_context/convertStmtsForChunkForDevServer.rs
  • src/bundler/linker_context/doStep5.rs
  • src/bundler/linker_context/findAllImportedPartsInJSOrder.rs
  • src/bundler/linker_context/findImportedCSSFilesInJSOrder.rs
  • src/bundler/linker_context/findImportedFilesInCSSOrder.rs
  • src/bundler/linker_context/generateChunksInParallel.rs
  • src/bundler/linker_context/generateCodeForFileInChunkJS.rs
  • src/bundler/linker_context/generateCodeForLazyExport.rs
  • src/bundler/linker_context/generateCompileResultForCssChunk.rs
  • src/bundler/linker_context/generateCompileResultForHtmlChunk.rs
  • src/bundler/linker_context/generateCompileResultForJSChunk.rs
  • src/bundler/linker_context/postProcessCSSChunk.rs
  • src/bundler/linker_context/postProcessJSChunk.rs
  • src/bundler/linker_context/prepareCssAstsForChunk.rs
  • src/bundler/linker_context/renameSymbolsInChunk.rs
  • src/bundler/linker_context/scanImportsAndExports.rs
  • src/bundler/linker_context/writeOutputFilesToDisk.rs
  • src/bundler/options.rs
  • src/bundler/transpiler.rs
  • src/bundler_jsc/PluginRunner.rs
  • src/bundler_jsc/analyze_jsc.rs
  • src/bundler_jsc/lib.rs
  • src/bunfig/arguments.rs
  • src/bunfig/bunfig.rs
  • src/cares_sys/c_ares.rs
  • src/cares_sys/lib.rs
  • src/clap/args.rs
  • src/clap/comptime.rs
  • src/clap/lib.rs
  • src/clap/streaming.rs
  • src/clap_macros/lib.rs
  • src/collections/StaticHashMap.rs
  • src/collections/array_hash_map.rs
  • src/collections/array_list.rs
  • src/collections/bit_set.rs
  • src/collections/comptime_string_map.rs
  • src/collections/hive_array.rs
  • src/collections/identity_context.rs
  • src/collections/lib.rs
  • src/collections/linear_fifo.rs
  • src/collections/multi_array_list.rs
  • src/collections/pool.rs
  • src/collections/string_map.rs
  • src/collections/vec_ext.rs
  • src/collections/zig_hash_map.rs
  • src/crash_handler/CPUFeatures.rs
  • src/crash_handler/handle_oom.rs
  • src/crash_handler/lib.rs
  • src/csrf/lib.rs
  • src/css/context.rs
  • src/css/css_modules.rs
  • src/css/css_parser.rs
  • src/css/declaration.rs
  • src/css/generics.rs
  • src/css/lib.rs
  • src/css/media_query.rs
  • src/css/printer.rs
  • src/css/properties/align.rs
  • src/css/properties/animation.rs
  • src/css/properties/background.rs
  • src/css/properties/border.rs
  • src/css/properties/border_image.rs
  • src/css/properties/border_radius.rs
  • src/css/properties/box_shadow.rs
  • src/css/properties/css_modules.rs
  • src/css/properties/custom.rs
  • src/css/properties/flex.rs
  • src/css/properties/font.rs
  • src/css/properties/grid.rs
  • src/css/properties/margin_padding.rs
  • src/css/properties/masking.rs
  • src/css/properties/mod.rs
  • src/css/properties/outline.rs
  • src/css/properties/overflow.rs
  • src/css/properties/prefix_handler.rs
  • src/css/properties/properties_generated.rs
  • src/css/properties/properties_impl.rs
  • src/css/properties/shape.rs
  • src/css/properties/size.rs
  • src/css/properties/transform.rs
  • src/css/properties/transition.rs
  • src/css/rules/container.rs
  • src/css/rules/document.rs
  • src/css/rules/font_face.rs
  • src/css/rules/import.rs
  • src/css/rules/keyframes.rs
  • src/css/rules/layer.rs
  • src/css/rules/media.rs
  • src/css/rules/mod.rs
  • src/css/rules/page.rs
  • src/css/rules/property.rs
  • src/css/rules/scope.rs
  • src/css/rules/style.rs
  • src/css/rules/supports.rs
  • src/css/rules/tailwind.rs
  • src/css/rules/viewport.rs
  • src/css/selectors/builder.rs
  • src/css/selectors/mod.rs
  • src/css/selectors/parser.rs
  • src/css/selectors/selector.rs
  • src/css/small_list.rs
  • src/css/targets.rs
  • src/css/values/alpha.rs
  • src/css/values/angle.rs
  • src/css/values/calc.rs
  • src/css/values/color.rs
  • src/css/values/css_string.rs
  • src/css/values/easing.rs
  • src/css/values/gradient.rs
  • src/css/values/ident.rs
  • src/css/values/image.rs
  • src/css/values/length.rs
  • src/css/values/mod.rs
  • src/css/values/percentage.rs
  • src/css/values/rect.rs
  • src/css/values/size.rs
  • src/css/values/syntax.rs
  • src/css/values/time.rs
  • src/css/values/url.rs
  • src/css_derive/lib.rs
  • src/css_jsc/color_js.rs
  • src/css_jsc/css_internals.rs
  • src/css_jsc/lib.rs
  • src/dispatch/lib.rs
  • src/dns/lib.rs
  • src/dotenv/env_loader.rs
  • src/errno/lib.rs
  • src/errno/linux_errno.rs
  • src/errno/windows_errno.rs
  • src/event_loop/AnyEventLoop.rs
  • src/event_loop/AnyTask.rs
  • src/event_loop/AnyTaskWithExtraContext.rs
  • src/event_loop/AutoFlusher.rs
  • src/event_loop/ConcurrentTask.rs
  • src/event_loop/DeferredTaskQueue.rs
  • src/event_loop/EventLoopTimer.rs
  • src/event_loop/ManagedTask.rs
  • src/event_loop/MiniEventLoop.rs
  • src/event_loop/SpawnSyncEventLoop.rs
  • src/event_loop/lib.rs
  • src/exe_format/elf.rs
  • src/exe_format/lib.rs
  • src/exe_format/macho.rs
  • src/exe_format/macho_types.rs
  • src/exe_format/pe.rs
  • src/glob/GlobWalker.rs
  • src/glob/lib.rs
  • src/glob/matcher.rs
  • src/hash/lib.rs
  • src/hash/xxhash.rs
  • src/highway/lib.rs
  • src/http/AsyncHTTP.rs
  • src/http/CertificateInfo.rs
  • src/http/Decompressor.rs
  • src/http/H2Client.rs
  • src/http/H3Client.rs
  • src/http/HTTPCertError.rs
  • src/http/HTTPContext.rs
  • src/http/HTTPRequestBody.rs
💤 Files with no reviewable changes (103)
  • src/bun_alloc/NullableAllocator.rs
  • src/bundler/linker_context/findImportedCSSFilesInJSOrder.rs
  • src/ast/server_component_boundary.rs
  • src/brotli/lib.rs
  • src/bun_alloc/MaxHeapAllocator.rs
  • src/bun_alloc/c_thunks.rs
  • src/ast/ast_result.rs
  • src/bun_core/string/HashedString.rs
  • src/bun_core/external_shared.rs
  • src/ast/transpiler_cache.rs
  • src/bundler/linker_context/convertStmtsForChunk.rs
  • src/bun_core/string/immutable/visible.rs
  • src/ast/g.rs
  • src/boringssl_sys/lib.rs
  • src/ast/op.rs
  • src/ast/b.rs
  • src/ast/ts.rs
  • src/bun_core/hint.rs
  • src/analytics/schema.rs
  • src/ast/base.rs
  • src/bun_core/debug.rs
  • src/bundler/bundled_ast.rs
  • src/bun_core/feature_flags.rs
  • src/bundler/linker_context/convertStmtsForChunkForDevServer.rs
  • src/ast/s.rs
  • src/bun_core_macros/lib.rs
  • src/bun_alloc/maybe_owned.rs
  • src/bundler/OutputFile.rs
  • src/boringssl/lib.rs
  • src/ast/new_store.rs
  • src/bun_core/string/PathString.rs
  • src/bundler/HTMLScanner.rs
  • src/bun_core/windows_sys.rs
  • src/bun_bin/lib.rs
  • src/boringssl_sys/boringssl.rs
  • src/bun_core/atomic_cell.rs
  • src/ast/import_record.rs
  • src/bundler/analyze_transpiled_module.rs
  • src/bun_core/bounded_array.rs
  • src/bun_core/build.rs
  • src/bun_bin/phase_c_exports.rs
  • src/bundler/AstBuilder.rs
  • src/ast/char_freq.rs
  • src/bun_core/string/immutable/exact_size_matcher.rs
  • src/bundler/linker_context/StaticRouteVisitor.rs
  • src/bun_core/deprecated.rs
  • src/analytics/lib.rs
  • src/ast/binding.rs
  • src/brotli_sys/brotli_c.rs
  • src/bun_core/string/identifier.rs
  • src/ast/ast_memory_allocator.rs
  • src/bun_output_tags/lib.rs
  • src/bun_core/string/MutableString.rs
  • src/bundler/BundleThread.rs
  • src/bun_alloc/fallback/z.rs
  • src/bun_alloc/heap_breakdown.rs
  • src/bundler/linker_context/findAllImportedPartsInJSOrder.rs
  • src/ast/stmt.rs
  • src/ast/loader.rs
  • src/bundler/linker_context/computeCrossChunkDependencies.rs
  • src/bun_core/thread_id.rs
  • src/bun_alloc/memory.rs
  • src/bun_core/string/wtf.rs
  • src/ast/fold_string_addition.rs
  • src/bundler/linker_context/generateChunksInParallel.rs
  • src/bun_alloc/stack_fallback.rs
  • src/ast/scope.rs
  • src/bundler/linker_context/doStep5.rs
  • src/bundler/barrel_imports.rs
  • src/bundler/cache.rs
  • src/bun_core/env.rs
  • src/api/lib.rs
  • src/bundler/defines.rs
  • src/bun_core/heap.rs
  • src/bun_core/env_var.rs
  • src/bundler/ThreadPool.rs
  • src/bundler/linker_context/computeChunks.rs
  • src/bundler/linker_context/MetafileBuilder.rs
  • src/bundler/lib.rs
  • src/bun_core/string/SmolStr.rs
  • src/ast/lexer_tables.rs
  • src/bun_core/string/StringBuilder.rs
  • src/bun_alloc/hashbrown_bridge.rs
  • src/ast/e.rs
  • src/ast/runtime.rs
  • src/bundler/linker.rs
  • src/bun_alloc/MimallocArena.rs
  • src/bun_core/result.rs
  • src/bundler/entry_points.rs
  • src/bun_core/Global.rs
  • src/bundler/Graph.rs
  • src/bun_alloc/ast_alloc.rs
  • src/bundler/linker_context/findImportedFilesInCSSOrder.rs
  • src/ast/nodes.rs
  • src/bun_core/Progress.rs
  • src/bun_core/string/immutable/unicode.rs
  • src/bun_core/output.rs
  • src/bun_core/string/mod.rs
  • src/ast/symbol.rs
  • src/ast/lib.rs
  • src/ast/expr.rs
  • src/bun_core/fmt.rs
  • src/bundler/bundle_v2.rs

Comment thread scripts/strip-long-rs-comments.ts Outdated
@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch 3 times, most recently from 661f2be to 395f877 Compare May 29, 2026 19:23
Adds scripts/strip-long-rs-comments.ts and applies it across the tree.

The script removes every `//`-style comment block of 4 or more consecutive
comment-only lines from git-tracked *.rs files, except:

- a block that is the first non-blank content in the file (top-of-file header),
- `// HOST_EXPORT(...)` marker lines, which src/codegen/generate-host-exports.ts
  scrapes to emit `extern "C"` thunks, kept even when surrounding prose is removed,
- any block containing SAFETY / a `Safety:`-style marker / a `/// # Safety`
  heading, since clippy::undocumented_unsafe_blocks is deny workspace-wide.

A comment block is a maximal run of lines whose trimmed content starts with
`//` (covers `//`, `///`, `//!`). Inline `/* ... */` and trailing `// ...`
after code are not touched. vendor/, packages/ and scripts/verify-baseline-static/
are skipped. When a block is removed, adjacent blank lines are collapsed.

Four bodies keep a sub-threshold (<=3 line) slice of their original comment
because removing it outright would trip a deny-level clippy lint on the
resulting construct:

- jsc/ConsoleObject.rs: `if token == PercentTag::O {}` (clippy::needless_ifs)
- js_parser/p.rs: the two `Substitution::Failure` else-if arms, whose bodies
  are identical once the explaining comments are gone (clippy::if_same_then_else)
- install/lifecycle_script_runner.rs: the `finished_installing` else arm, same
  body as the if arm (clippy::if_same_then_else)
- resolver/resolver.rs: the tsconfig paths-merge else arm (clippy::needless_else)
@robobun robobun force-pushed the farm/a9f7cf29/strip-long-rs-comments branch from 395f877 to 1afc868 Compare May 29, 2026 23:18
@alii alii closed this May 30, 2026
@alii

alii commented May 30, 2026

Copy link
Copy Markdown
Member

Closing for now, just keeps rebasing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants