Strip comment blocks longer than 3 lines from .rs files#31201
Conversation
|
Updated 6:07 PM PT - May 29th, 2026
✅ @robobun, your commit 1afc868b885df277724d0920c0d3f368b39a9405 passed in 🧪 To try this PR locally: bunx bun-pr 31201That installs a local version of the PR into your bun-31201 --bun |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds 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. ChangesAutomated comment stripping and synchronized code updates
Possibly related PRs
Suggested reviewers
|
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
scripts/strip-long-rs-comments.ts
11d5016 to
3f38be0
Compare
There was a problem hiding this comment.
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 breakclippy::undocumented_unsafe_blocks = deny— fixed viaPROTECTED_BLOCK(3f38be0).packages/bun-native-plugin-rsdocs.rs API docs stripped — fixed viaSKIP_PREFIXES(3f38be0).scripts/verify-baseline-static/CLAUDE.mdline refs invalidated — fixed viaSKIP_PREFIXES(3f38be0).--minarg-parsing bug dropping first positional — fixed (3f38be0).- Output not rustfmt-clean — fixed via autofix.ci (8aa3dc3).
- Orphaned
#[allow(if_same_then_else)]inlifecycle_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).
5f27d37 to
fe451c8
Compare
There was a problem hiding this comment.
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 blockinbun_core/lib.rs,unused labelinspawn/process.rsandinstall/npm.rs, andunreachable pubinthreading/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.
|
Status — head This refresh picked up 2 upstream commits — #31569 (yaml Proof the diff is comments-only (re-run for this head): a fresh checkout of
Each note is a verbatim sub-threshold slice of the comment that was already on What I need from a maintainer: the diff is green and bot-reviewed; 0 unresolved review threads. This PR re-conflicts whenever a |
347d615 to
fb5e8fa
Compare
There was a problem hiding this comment.
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.
737377c to
4bfc0db
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (259)
scripts/strip-long-rs-comments.tssrc/analytics/lib.rssrc/analytics/schema.rssrc/api/lib.rssrc/ast/ast_memory_allocator.rssrc/ast/ast_result.rssrc/ast/b.rssrc/ast/base.rssrc/ast/binding.rssrc/ast/char_freq.rssrc/ast/e.rssrc/ast/expr.rssrc/ast/fold_string_addition.rssrc/ast/g.rssrc/ast/import_record.rssrc/ast/known_global.rssrc/ast/lexer_tables.rssrc/ast/lib.rssrc/ast/loader.rssrc/ast/new_store.rssrc/ast/nodes.rssrc/ast/op.rssrc/ast/runtime.rssrc/ast/s.rssrc/ast/scope.rssrc/ast/server_component_boundary.rssrc/ast/stmt.rssrc/ast/symbol.rssrc/ast/transpiler_cache.rssrc/ast/ts.rssrc/base64/lib.rssrc/boringssl/lib.rssrc/boringssl_sys/boringssl.rssrc/boringssl_sys/lib.rssrc/brotli/lib.rssrc/brotli_sys/brotli_c.rssrc/bun_alloc/MaxHeapAllocator.rssrc/bun_alloc/MimallocArena.rssrc/bun_alloc/NullableAllocator.rssrc/bun_alloc/ast_alloc.rssrc/bun_alloc/c_thunks.rssrc/bun_alloc/fallback/z.rssrc/bun_alloc/hashbrown_bridge.rssrc/bun_alloc/heap_breakdown.rssrc/bun_alloc/lib.rssrc/bun_alloc/maybe_owned.rssrc/bun_alloc/memory.rssrc/bun_alloc/stack_fallback.rssrc/bun_bin/lib.rssrc/bun_bin/phase_c_exports.rssrc/bun_core/Global.rssrc/bun_core/Progress.rssrc/bun_core/atomic_cell.rssrc/bun_core/bounded_array.rssrc/bun_core/build.rssrc/bun_core/debug.rssrc/bun_core/deprecated.rssrc/bun_core/env.rssrc/bun_core/env_var.rssrc/bun_core/external_shared.rssrc/bun_core/feature_flags.rssrc/bun_core/fmt.rssrc/bun_core/heap.rssrc/bun_core/hint.rssrc/bun_core/lib.rssrc/bun_core/output.rssrc/bun_core/result.rssrc/bun_core/string/HashedString.rssrc/bun_core/string/MutableString.rssrc/bun_core/string/PathString.rssrc/bun_core/string/SmolStr.rssrc/bun_core/string/StringBuilder.rssrc/bun_core/string/StringJoiner.rssrc/bun_core/string/identifier.rssrc/bun_core/string/immutable.rssrc/bun_core/string/immutable/escapeHTML.rssrc/bun_core/string/immutable/exact_size_matcher.rssrc/bun_core/string/immutable/grapheme.rssrc/bun_core/string/immutable/unicode.rssrc/bun_core/string/immutable/visible.rssrc/bun_core/string/mod.rssrc/bun_core/string/wtf.rssrc/bun_core/thread_id.rssrc/bun_core/util.rssrc/bun_core/windows_sys.rssrc/bun_core_macros/lib.rssrc/bun_output_tags/lib.rssrc/bundler/AstBuilder.rssrc/bundler/BundleThread.rssrc/bundler/Chunk.rssrc/bundler/Graph.rssrc/bundler/HTMLImportManifest.rssrc/bundler/HTMLScanner.rssrc/bundler/LinkerContext.rssrc/bundler/LinkerGraph.rssrc/bundler/OutputFile.rssrc/bundler/ParseTask.rssrc/bundler/ServerComponentParseTask.rssrc/bundler/ThreadPool.rssrc/bundler/analyze_transpiled_module.rssrc/bundler/barrel_imports.rssrc/bundler/bundle_v2.rssrc/bundler/bundled_ast.rssrc/bundler/cache.rssrc/bundler/defines.rssrc/bundler/entry_points.rssrc/bundler/lib.rssrc/bundler/linker.rssrc/bundler/linker_context/MetafileBuilder.rssrc/bundler/linker_context/StaticRouteVisitor.rssrc/bundler/linker_context/computeChunks.rssrc/bundler/linker_context/computeCrossChunkDependencies.rssrc/bundler/linker_context/convertStmtsForChunk.rssrc/bundler/linker_context/convertStmtsForChunkForDevServer.rssrc/bundler/linker_context/doStep5.rssrc/bundler/linker_context/findAllImportedPartsInJSOrder.rssrc/bundler/linker_context/findImportedCSSFilesInJSOrder.rssrc/bundler/linker_context/findImportedFilesInCSSOrder.rssrc/bundler/linker_context/generateChunksInParallel.rssrc/bundler/linker_context/generateCodeForFileInChunkJS.rssrc/bundler/linker_context/generateCodeForLazyExport.rssrc/bundler/linker_context/generateCompileResultForCssChunk.rssrc/bundler/linker_context/generateCompileResultForHtmlChunk.rssrc/bundler/linker_context/generateCompileResultForJSChunk.rssrc/bundler/linker_context/postProcessCSSChunk.rssrc/bundler/linker_context/postProcessJSChunk.rssrc/bundler/linker_context/prepareCssAstsForChunk.rssrc/bundler/linker_context/renameSymbolsInChunk.rssrc/bundler/linker_context/scanImportsAndExports.rssrc/bundler/linker_context/writeOutputFilesToDisk.rssrc/bundler/options.rssrc/bundler/transpiler.rssrc/bundler/ungate_support.rssrc/bundler_jsc/PluginRunner.rssrc/bundler_jsc/analyze_jsc.rssrc/bundler_jsc/lib.rssrc/bunfig/arguments.rssrc/bunfig/bunfig.rssrc/cares_sys/c_ares.rssrc/cares_sys/lib.rssrc/clap/args.rssrc/clap/comptime.rssrc/clap/lib.rssrc/clap/streaming.rssrc/clap_macros/lib.rssrc/collections/StaticHashMap.rssrc/collections/array_hash_map.rssrc/collections/array_list.rssrc/collections/bit_set.rssrc/collections/comptime_string_map.rssrc/collections/hive_array.rssrc/collections/identity_context.rssrc/collections/lib.rssrc/collections/linear_fifo.rssrc/collections/multi_array_list.rssrc/collections/pool.rssrc/collections/string_map.rssrc/collections/vec_ext.rssrc/collections/zig_hash_map.rssrc/crash_handler/CPUFeatures.rssrc/crash_handler/handle_oom.rssrc/crash_handler/lib.rssrc/csrf/lib.rssrc/css/context.rssrc/css/css_modules.rssrc/css/css_parser.rssrc/css/declaration.rssrc/css/generics.rssrc/css/lib.rssrc/css/media_query.rssrc/css/printer.rssrc/css/properties/align.rssrc/css/properties/animation.rssrc/css/properties/background.rssrc/css/properties/border.rssrc/css/properties/border_image.rssrc/css/properties/border_radius.rssrc/css/properties/box_shadow.rssrc/css/properties/css_modules.rssrc/css/properties/custom.rssrc/css/properties/flex.rssrc/css/properties/font.rssrc/css/properties/grid.rssrc/css/properties/margin_padding.rssrc/css/properties/masking.rssrc/css/properties/mod.rssrc/css/properties/outline.rssrc/css/properties/overflow.rssrc/css/properties/prefix_handler.rssrc/css/properties/properties_generated.rssrc/css/properties/properties_impl.rssrc/css/properties/shape.rssrc/css/properties/size.rssrc/css/properties/transform.rssrc/css/properties/transition.rssrc/css/rules/container.rssrc/css/rules/document.rssrc/css/rules/font_face.rssrc/css/rules/import.rssrc/css/rules/keyframes.rssrc/css/rules/layer.rssrc/css/rules/media.rssrc/css/rules/mod.rssrc/css/rules/page.rssrc/css/rules/property.rssrc/css/rules/scope.rssrc/css/rules/style.rssrc/css/rules/supports.rssrc/css/rules/tailwind.rssrc/css/rules/viewport.rssrc/css/selectors/builder.rssrc/css/selectors/mod.rssrc/css/selectors/parser.rssrc/css/selectors/selector.rssrc/css/small_list.rssrc/css/targets.rssrc/css/values/alpha.rssrc/css/values/angle.rssrc/css/values/calc.rssrc/css/values/color.rssrc/css/values/css_string.rssrc/css/values/easing.rssrc/css/values/gradient.rssrc/css/values/ident.rssrc/css/values/image.rssrc/css/values/length.rssrc/css/values/mod.rssrc/css/values/percentage.rssrc/css/values/rect.rssrc/css/values/size.rssrc/css/values/syntax.rssrc/css/values/time.rssrc/css/values/url.rssrc/css_derive/lib.rssrc/css_jsc/color_js.rssrc/css_jsc/css_internals.rssrc/css_jsc/lib.rssrc/dispatch/lib.rssrc/dns/lib.rssrc/dotenv/env_loader.rssrc/errno/lib.rssrc/errno/linux_errno.rssrc/errno/windows_errno.rssrc/event_loop/AnyEventLoop.rssrc/event_loop/AnyTask.rssrc/event_loop/AnyTaskWithExtraContext.rssrc/event_loop/AutoFlusher.rssrc/event_loop/ConcurrentTask.rssrc/event_loop/DeferredTaskQueue.rssrc/event_loop/EventLoopTimer.rssrc/event_loop/ManagedTask.rssrc/event_loop/MiniEventLoop.rssrc/event_loop/SpawnSyncEventLoop.rssrc/event_loop/lib.rssrc/exe_format/elf.rssrc/exe_format/lib.rssrc/exe_format/macho.rssrc/exe_format/macho_types.rssrc/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
There was a problem hiding this comment.
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,--minCLI bug,verify-baseline-staticCLAUDE.md refs, rustfmt cleanliness, the orphaned#[allow]inlifecycle_script_runner.rs, and the case-insensitiveSafety:regex). The script and PR description now reflect each fix. - CI is not green on the current head:
test/bundler/transpiler/transpiler.test.jsfails on all three Windows lanes (2019 x64, 2019 x64-baseline, 11 aarch64) on commit4bfc0dbb. 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
.rschange 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.
6082852 to
973f050
Compare
79d5e4a to
1fbbce0
Compare
05e2855 to
45fb3db
Compare
There was a problem hiding this comment.
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 winGuard 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
📒 Files selected for processing (270)
scripts/strip-long-rs-comments.tssrc/analytics/lib.rssrc/analytics/schema.rssrc/api/lib.rssrc/ast/ast_memory_allocator.rssrc/ast/ast_result.rssrc/ast/b.rssrc/ast/base.rssrc/ast/binding.rssrc/ast/char_freq.rssrc/ast/e.rssrc/ast/expr.rssrc/ast/fold_string_addition.rssrc/ast/g.rssrc/ast/import_record.rssrc/ast/known_global.rssrc/ast/lexer_tables.rssrc/ast/lib.rssrc/ast/loader.rssrc/ast/new_store.rssrc/ast/nodes.rssrc/ast/op.rssrc/ast/runtime.rssrc/ast/s.rssrc/ast/scope.rssrc/ast/server_component_boundary.rssrc/ast/stmt.rssrc/ast/symbol.rssrc/ast/transpiler_cache.rssrc/ast/ts.rssrc/base64/lib.rssrc/boringssl/lib.rssrc/boringssl_sys/boringssl.rssrc/boringssl_sys/lib.rssrc/brotli/lib.rssrc/brotli_sys/brotli_c.rssrc/bun_alloc/MaxHeapAllocator.rssrc/bun_alloc/MimallocArena.rssrc/bun_alloc/NullableAllocator.rssrc/bun_alloc/ast_alloc.rssrc/bun_alloc/c_thunks.rssrc/bun_alloc/fallback/z.rssrc/bun_alloc/hashbrown_bridge.rssrc/bun_alloc/heap_breakdown.rssrc/bun_alloc/lib.rssrc/bun_alloc/maybe_owned.rssrc/bun_alloc/memory.rssrc/bun_alloc/stack_fallback.rssrc/bun_bin/lib.rssrc/bun_bin/phase_c_exports.rssrc/bun_core/Global.rssrc/bun_core/Progress.rssrc/bun_core/atomic_cell.rssrc/bun_core/bounded_array.rssrc/bun_core/build.rssrc/bun_core/debug.rssrc/bun_core/deprecated.rssrc/bun_core/env.rssrc/bun_core/env_var.rssrc/bun_core/external_shared.rssrc/bun_core/feature_flags.rssrc/bun_core/fmt.rssrc/bun_core/heap.rssrc/bun_core/hint.rssrc/bun_core/lib.rssrc/bun_core/output.rssrc/bun_core/result.rssrc/bun_core/string/HashedString.rssrc/bun_core/string/MutableString.rssrc/bun_core/string/PathString.rssrc/bun_core/string/SmolStr.rssrc/bun_core/string/StringBuilder.rssrc/bun_core/string/StringJoiner.rssrc/bun_core/string/identifier.rssrc/bun_core/string/immutable.rssrc/bun_core/string/immutable/exact_size_matcher.rssrc/bun_core/string/immutable/unicode.rssrc/bun_core/string/immutable/visible.rssrc/bun_core/string/mod.rssrc/bun_core/string/wtf.rssrc/bun_core/thread_id.rssrc/bun_core/util.rssrc/bun_core/windows_sys.rssrc/bun_core_macros/lib.rssrc/bun_output_tags/lib.rssrc/bundler/AstBuilder.rssrc/bundler/BundleThread.rssrc/bundler/Chunk.rssrc/bundler/Graph.rssrc/bundler/HTMLImportManifest.rssrc/bundler/HTMLScanner.rssrc/bundler/LinkerContext.rssrc/bundler/LinkerGraph.rssrc/bundler/OutputFile.rssrc/bundler/ParseTask.rssrc/bundler/ServerComponentParseTask.rssrc/bundler/ThreadPool.rssrc/bundler/analyze_transpiled_module.rssrc/bundler/barrel_imports.rssrc/bundler/bundle_v2.rssrc/bundler/bundled_ast.rssrc/bundler/cache.rssrc/bundler/defines.rssrc/bundler/entry_points.rssrc/bundler/lib.rssrc/bundler/linker.rssrc/bundler/linker_context/MetafileBuilder.rssrc/bundler/linker_context/StaticRouteVisitor.rssrc/bundler/linker_context/computeChunks.rssrc/bundler/linker_context/computeCrossChunkDependencies.rssrc/bundler/linker_context/convertStmtsForChunk.rssrc/bundler/linker_context/convertStmtsForChunkForDevServer.rssrc/bundler/linker_context/doStep5.rssrc/bundler/linker_context/findAllImportedPartsInJSOrder.rssrc/bundler/linker_context/findImportedCSSFilesInJSOrder.rssrc/bundler/linker_context/findImportedFilesInCSSOrder.rssrc/bundler/linker_context/generateChunksInParallel.rssrc/bundler/linker_context/generateCodeForFileInChunkJS.rssrc/bundler/linker_context/generateCodeForLazyExport.rssrc/bundler/linker_context/generateCompileResultForCssChunk.rssrc/bundler/linker_context/generateCompileResultForHtmlChunk.rssrc/bundler/linker_context/generateCompileResultForJSChunk.rssrc/bundler/linker_context/postProcessCSSChunk.rssrc/bundler/linker_context/postProcessJSChunk.rssrc/bundler/linker_context/prepareCssAstsForChunk.rssrc/bundler/linker_context/renameSymbolsInChunk.rssrc/bundler/linker_context/scanImportsAndExports.rssrc/bundler/linker_context/writeOutputFilesToDisk.rssrc/bundler/options.rssrc/bundler/transpiler.rssrc/bundler_jsc/PluginRunner.rssrc/bundler_jsc/analyze_jsc.rssrc/bundler_jsc/lib.rssrc/bunfig/arguments.rssrc/bunfig/bunfig.rssrc/cares_sys/c_ares.rssrc/cares_sys/lib.rssrc/clap/args.rssrc/clap/comptime.rssrc/clap/lib.rssrc/clap/streaming.rssrc/clap_macros/lib.rssrc/collections/StaticHashMap.rssrc/collections/array_hash_map.rssrc/collections/array_list.rssrc/collections/bit_set.rssrc/collections/comptime_string_map.rssrc/collections/hive_array.rssrc/collections/identity_context.rssrc/collections/lib.rssrc/collections/linear_fifo.rssrc/collections/multi_array_list.rssrc/collections/pool.rssrc/collections/string_map.rssrc/collections/vec_ext.rssrc/collections/zig_hash_map.rssrc/crash_handler/CPUFeatures.rssrc/crash_handler/handle_oom.rssrc/crash_handler/lib.rssrc/csrf/lib.rssrc/css/context.rssrc/css/css_modules.rssrc/css/css_parser.rssrc/css/declaration.rssrc/css/generics.rssrc/css/lib.rssrc/css/media_query.rssrc/css/printer.rssrc/css/properties/align.rssrc/css/properties/animation.rssrc/css/properties/background.rssrc/css/properties/border.rssrc/css/properties/border_image.rssrc/css/properties/border_radius.rssrc/css/properties/box_shadow.rssrc/css/properties/css_modules.rssrc/css/properties/custom.rssrc/css/properties/flex.rssrc/css/properties/font.rssrc/css/properties/grid.rssrc/css/properties/margin_padding.rssrc/css/properties/masking.rssrc/css/properties/mod.rssrc/css/properties/outline.rssrc/css/properties/overflow.rssrc/css/properties/prefix_handler.rssrc/css/properties/properties_generated.rssrc/css/properties/properties_impl.rssrc/css/properties/shape.rssrc/css/properties/size.rssrc/css/properties/transform.rssrc/css/properties/transition.rssrc/css/rules/container.rssrc/css/rules/document.rssrc/css/rules/font_face.rssrc/css/rules/import.rssrc/css/rules/keyframes.rssrc/css/rules/layer.rssrc/css/rules/media.rssrc/css/rules/mod.rssrc/css/rules/page.rssrc/css/rules/property.rssrc/css/rules/scope.rssrc/css/rules/style.rssrc/css/rules/supports.rssrc/css/rules/tailwind.rssrc/css/rules/viewport.rssrc/css/selectors/builder.rssrc/css/selectors/mod.rssrc/css/selectors/parser.rssrc/css/selectors/selector.rssrc/css/small_list.rssrc/css/targets.rssrc/css/values/alpha.rssrc/css/values/angle.rssrc/css/values/calc.rssrc/css/values/color.rssrc/css/values/css_string.rssrc/css/values/easing.rssrc/css/values/gradient.rssrc/css/values/ident.rssrc/css/values/image.rssrc/css/values/length.rssrc/css/values/mod.rssrc/css/values/percentage.rssrc/css/values/rect.rssrc/css/values/size.rssrc/css/values/syntax.rssrc/css/values/time.rssrc/css/values/url.rssrc/css_derive/lib.rssrc/css_jsc/color_js.rssrc/css_jsc/css_internals.rssrc/css_jsc/lib.rssrc/dispatch/lib.rssrc/dns/lib.rssrc/dotenv/env_loader.rssrc/errno/lib.rssrc/errno/linux_errno.rssrc/errno/windows_errno.rssrc/event_loop/AnyEventLoop.rssrc/event_loop/AnyTask.rssrc/event_loop/AnyTaskWithExtraContext.rssrc/event_loop/AutoFlusher.rssrc/event_loop/ConcurrentTask.rssrc/event_loop/DeferredTaskQueue.rssrc/event_loop/EventLoopTimer.rssrc/event_loop/ManagedTask.rssrc/event_loop/MiniEventLoop.rssrc/event_loop/SpawnSyncEventLoop.rssrc/event_loop/lib.rssrc/exe_format/elf.rssrc/exe_format/lib.rssrc/exe_format/macho.rssrc/exe_format/macho_types.rssrc/exe_format/pe.rssrc/glob/GlobWalker.rssrc/glob/lib.rssrc/glob/matcher.rssrc/hash/lib.rssrc/hash/xxhash.rssrc/highway/lib.rssrc/http/AsyncHTTP.rssrc/http/CertificateInfo.rssrc/http/Decompressor.rssrc/http/H2Client.rssrc/http/H3Client.rssrc/http/HTTPCertError.rssrc/http/HTTPContext.rssrc/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
661f2be to
395f877
Compare
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)
395f877 to
1afc868
Compare
|
Closing for now, just keeps rebasing |
What
Adds
scripts/strip-long-rs-comments.tsand 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*.rsfiles, except:// HOST_EXPORT(...)marker lines, whichsrc/codegen/generate-host-exports.tsscrapes to emitextern "C"thunks — those are kept even when the surrounding prose is removed, andSAFETY, a line opening with a case-insensitiveSafety:-style marker, or a/// # Safetyheading —clippy::undocumented_unsafe_blocksisdenyworkspace-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) andscripts/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
Script usage
Rebase onto main
Main gained 9 commits touching 10
.rsfiles after the original pass (WebKit upgrade, yaml/parser/shell/patch fixes). Conflicts insrc/js_parser/parser.rs,src/jsc/JSType.rsandsrc/runtime/shell/states/Expansion.rswere resolved by taking main's version of each file and re-running the script on it, so the upstream code changes (JSType renumbering, shellmeta_offsetsrework, parser changes) are preserved exactly and only their comments are stripped. The last commit re-runs the script oversrc/js_parser/parse/{mod,parse_stmt}.rsandsrc/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.rsfiles) 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
.rsfiles), which landed while the previous head was in CI. Conflicts insrc/bun_core/lib.rsandsrc/runtime/shell/states/Expansion.rswere resolved the same way — take main's version of the file and re-run the script on it — so the upstream fixes (theb.len() < a.len()guard ineql_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 tosrc/js_parser/scan/scan_imports.rs, which had merged cleanly.A fourth rebase picked up the next 10 upstream commits (67
.rsfiles: the round-3 hardening pass #31221 plus CSS/parser/markdown/JSONC/CryptoHasher fixes). 15 files conflicted — 14 on the main strip commit andsrc/md/inlines.rson 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.rsfiles). 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
.rsfiles: CSS nesting/@containerminification fixes, js_parser decorator/auto-accessor/TS-depth fixes, node:http2 GOAWAY + HEADERS/CONTINUATION work, js_printer fixes). Onlysrc/css/rules/mod.rsandsrc/css/rules/style.rsconflicted, 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
.rsfiles: transpiler nesting-depth errors, a JSXkey-prop fix, and the ANSI markdown indentation cap).src/js_parser/p.rsandsrc/js_parser/parse/parse_stmt.rsconflicted 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 tosrc/md/ansi_renderer.rs, which had merged cleanly.An eighth rebase picked up #31341 and #31367 (2 commits, 2
.rsfiles). Onlysrc/ast/lib.rsconflicted, 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.rsmerged 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
.rsfiles: #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.rsandgrapheme_tables.rs, which #31351 deleted upstream, are deleted here too rather than resurrected. The remaining upstream.rschanges 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
.rsfiles) and #31379 (FormData multipart serialization, 2.rsfiles). 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
.rsfiles (#31325 fetch checkServerIdentity, #31376 install exit-callback gating, #31404 CSS pseudo-name escaping) plus #31382 (test/fixture only). Onlysrc/runtime/webcore/fetch/FetchTasklet.rsconflicted, 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 tosrc/http/lib.rsandsrc/http/InternalState.rs, which had merged cleanly.A twelfth rebase picked up the next 4 upstream commits, two touching
.rsfiles 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 touchesscripts/verify-baseline-static/, which the script skips, and #31407 touches no.rsfiles.src/bun_core/lib.rsandsrc/runtime/webcore/TextEncoder.rsconflicted 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 rewrittenTextEncoder.rshas 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 inStandaloneModuleGraph.rsand thequeue_slice_len == 1arm inresolver.rs— so neither is left as a bare{}. A second review follow-up does the same for four more bodies thatcargo fmthad collapsed onto a single line (LinkerContext::check_for_memory_corruption,BundleOptions'sDropimpl, theTarget::Bunarm inoptions.rs, and theprefill::hot_module_reloadingplaceholdermod); 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
.rsfiles 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-implementedskip_to_interesting_character_in_multiline_commentto delegate tobun_highway::index_of_interesting_character_in_multiline_comment(returningusize) 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 (thebun_highwaybody) 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
.rsfiles). 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'spub(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 plusTextDecoder.rscarried, andcargo fmtthen reflowed three of them (ausere-sort inbun.lock.rs, a collapsed match arm innode_fs.rs, a blank-line collapse inBody.rs). This refresh also fixed a latent over-strip bug: a full byte-for-byte comparison againstmainwith the script applied revealed that two earlier strip commits — built against older bases — had removed whole comment-only statements rather than just their comments: anif token == PercentTag::O {}inConsoleObject.rsand anelse {}inresolver.rs. Both files were re-derived frommainwith 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
.rsfiles this PR covers: #31493 (StringJoinerborrowed segments bound to a lifetime —StringJoiner<'a>/Node<'a>), #31483 (Bun.escapeHTMLrewritten on Highway SIMD, deleting the old scalarScalarVec/ENABLE_SIMDpath and slimmingimmutable/escapeHTML.rsto 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— pluswebcore/Blob.rson a follow-up (itspush_string_slicesignature picked up the newStringJoiner<'_>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 (theStringJoinerlifetime, 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 insql_jsc/postgres/DataCell.rs(theget_str_from_varNUMERIC comment), which had merged cleanly, and re-derivesptr/lib.rsandsourcemap/lib.rsfrommain+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 ofmainwith the script applied andcargo fmt'd is byte-identical to this branch across every.rsfile except the eight bodies that carry a deliberate ≤3-line note (LinkerContext::check_for_memory_corruption,options.rs'sTarget::Bunarm andBundleOptions'sDrop,lifecycle_script_runner.rs's else arm, the twojs_parser/p.rssubstitution-failure arms,parser.rs'shot_module_reloadingmod,ConsoleObject.rs's%obranch,resolver.rs's paths-merge else +queue_slice_len == 1arm, andStandaloneModuleGraph.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 bdbuilt and linked cleanly (binary runs;-e 'console.log(1+1)'→2),cargo fmt --all -- --checkis clean,cargo clippy -p bun_resolveris clean on the pinned nightly (theneedless_elsefix holds;bun_jsc'sneedless_ifsfix is guarded by the%onote and the deny-warningsbun bdbuild passed), andtest/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
mainwas a now-stripped comment block as bare{}, and two of them failcargo clippyunder-D warnings: theelse {}inresolver.rs(the extends-chain tsconfig paths-merge) tripsclippy::needless_else, andif token == PercentTag::O {}inConsoleObject.rstripsclippy::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 thequeue_slice_len == 1arm (out of the dead-code position above theelse 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_jscis clean on the pinned nightly, and a scan of every changed.rsfile finds no remaining emptyif {}/else {}.Verification
main, the.rsdiff removes only comment lines; the ~650 added lines are thecargo fmtreflow that follows block removal,use/pub usere-sorts, and the short sub-threshold notes kept in a handful of otherwise-empty bodies (lifecycle_script_runner.rs, thejs_parsersubstitution-failure arms,LinkerContext::check_for_memory_corruption,BundleOptions'sDropimpl, theTarget::Bunarm inoptions.rs,prefill::hot_module_reloading,StandaloneModuleGraph.rs's#[cfg(debug_assertions)]block,resolver.rs's paths-mergeelseandqueue_slice_len == 1arm, andConsoleObject.rs's%obranch — the last three required soclippy::needless_else/needless_ifsdon't fire on a bare{}). Proof it is comments-only: applying the script to a fresh checkout ofmainand runningcargo fmton both trees yields byte-identical.rsfiles 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// HOST_EXPORT(...)markers present onmainare still present; zeroSAFETY/# Safetylines removed, and the one mixed-case// Safety:block in the tree (src/jsc/AsyncModule.rs) is keptcargo fmt --all -- --checkis clean with the pinned nightly-2026-05-06cargo clippy -p bun_resolver -p bun_jsc --no-depsis clean on the pinned nightly (the two crates whose strip-emptied bodies were trippingneedless_else/needless_ifs); no changed.rsfile contains an emptyif {}/else {}bun scripts/strip-long-rs-comments.ts --dryover 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 bdbuilt and linked cleanly on the pre-rebase revision of this diff;./build/debug/bun-debug -e 'console.log(1+1)'→2A sixteenth rebase picked up the next 11 upstream commits (45
.rsfiles: 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: extractparse_block_indentedhelper; 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) andsrc/parsers/yaml.rson a follow-up strip commit — and were resolved the same way: takemain's version of each file and re-run the strip script, so the upstream code changes (thebun_highway::XxHash64Statestreaming wrapper, the CSS nesting rework, the h2 frame-parser changes, yaml'sparse_block_indentedextraction) 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 freshgit worktreeatmainwith the script applied andcargo fmt'd is byte-identical to this branch across every.rsfile except the same eight bodies that carry a deliberate ≤3-line note (check_for_memory_corruption, theTarget::Bunarm +BundleOptionsDropinoptions.rs,lifecycle_script_runner.rs's else arm, the twojs_parser/p.rssubstitution-failure arms,parser.rs'shot_module_reloadingmod,ConsoleObject.rs's%obranch,resolver.rs's paths-merge else +queue_slice_len == 1arm, andStandaloneModuleGraph.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 vsmain; the oneHOST_EXPORT(substring that differs is prose inside backticks in a stripped doc block, not a marker line); SAFETY/# Safetyheader lines 12876 = 12876 with none removed; zeroTODO/FIXME/HACK/XXXadded in the diff.bun bdbuilt and linked cleanly (binary runs;-e 'console.log(1+1)'→2), the deny-warnings build passing confirmsbun_jsc'sneedless_ifsfix (guarded by the%onote) holds;cargo fmt --all -- --checkclean,cargo clippy -p bun_resolverclean on the pinned nightly (theneedless_elsefix holds), the strip--dryreports 0 changes (idempotent), andtest/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
.rsfiles: #31542/#31551/#31548/#31544/#31541/#31536 dead-code deletions across bun_alloc/paths/resolver/threading/collections/bun_core, #31529 inliningungate_supportintobundle_v2/lib.rsand 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) plusparsers/yaml.rson a follow-up strip commit, and were resolved the same way — takemain'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 emptyci: retriggertip commit from the previous head was dropped during the rebase. Proof it is comments-only (re-run for this head): a freshgit worktreeatmainwith the script applied andcargo fmt'd is byte-identical to this branch across every.rsfile 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 invirtual_machine_exports.rs/generated_host_exports.rs, not a marker line); SAFETY/# Safetyheader lines 12073 = 12073 with none removed; zeroTODO/FIXME/HACK/XXXadded in the diff.bun bdbuilt and linked cleanly (binary runs;-e 'console.log(1+1)'→2),cargo fmt --all -- --checkclean,cargo clippy -p bun_resolver -p bun_jsc --no-depsclean on the pinned nightly (theneedless_else/needless_ifsfixes hold, also confirmed by the deny-warningsbun bdbuild), strip--dry= 0 (idempotent), andtest/internal/strip-long-rs-comments.test.ts→ 5 pass / 0 fail (incl. the tree-is-clean scan). TheCONFLICTINGbadge GitHub may show is stale cache: the branch is rebased on the currentmaintip andgit merge-tree --write-tree HEAD origin/mainis clean (0 conflicts).An eighteenth rebase picked up the next 10 upstream commits (20
.rsfiles: #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) andsrc/http_types/URLPath.rson a follow-up — all resolved the same way: takemain'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 (theTarget::Bunarm andBundleOptions'sDrop) were restored after re-deriving the file. A follow-up commit strips the 6 new 4+-line blocks (44 lines) #31539 and #31547 introduced acrosssrc/install/lockfile/bun.lock.rsandsrc/parsers/yaml.rs, which had merged cleanly. Proof it is comments-only (re-run for this head): a freshgit worktreeatmainwith the script applied andcargo fmt'd is byte-identical to this branch across every.rsfile except the same eight bodies that carry a deliberate ≤3-line note (check_for_memory_corruption, theTarget::Bunarm +BundleOptionsDropinoptions.rs,lifecycle_script_runner.rs's else arm, the twojs_parser/p.rssubstitution-failure arms,parser.rs'shot_module_reloadingmod,ConsoleObject.rs's%obranch,resolver.rs's paths-merge else +queue_slice_len == 1arm, andStandaloneModuleGraph.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/# Safetyheader lines 12072 = 12072 with none removed; zeroTODO/FIXME/HACK/XXXadded in the diff.bun bdbuilt and linked cleanly (binary runs;-e 'console.log(1+1)'→2),cargo fmt --all -- --checkclean,cargo clippy -p bun_resolver -p bun_jsc --no-depsclean on the pinned nightly (theneedless_else/needless_ifsfixes hold, also confirmed by the deny-warningsbun bdbuild), strip--dry= 0 (idempotent), andtest/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
.rsfile). The single conflict,src/parsers/yaml.rs, was resolved the same way — takemain'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 fmtmade no further change). Proof it is comments-only (re-run for this head): a freshgit worktreeatmainwith the script applied andcargo fmt'd is byte-identical to this branch across every.rsfile except the same eight bodies that carry a deliberate ≤3-line note (check_for_memory_corruption, theTarget::Bunarm +BundleOptionsDropinoptions.rs,lifecycle_script_runner.rs's else arm, the twojs_parser/p.rssubstitution-failure arms,parser.rs'shot_module_reloadingmod,ConsoleObject.rs's%obranch,resolver.rs's paths-merge else +queue_slice_len == 1arm, andStandaloneModuleGraph.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.rsgained no new empty{}match arms (28 = 28 vsmain).cargo fmt --all -- --checkclean;cargo clippy -p bun_resolver --no-depsclean on the pinned nightly (transitively checksbun_parsers/yaml.rs,bun_js_parser, andbun_resolver— theneedless_elsefix holds);bun_jsc'sneedless_ifsguard (the%onote) is unchanged by this rebase and confirmed by the deny-warningsbun bdbuild. 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 currentmaintip (0 behind / 26 ahead);git merge-tree --write-tree HEAD origin/mainis conflict-free.