Skip to content

Fix clippy, rustfmt, Miri, and stale tsconfig references on main - #37078

Merged
dylan-conway merged 5 commits into
mainfrom
farm/4a071ba6/fix-main-clippy-fmt
Aug 7, 2026
Merged

Fix clippy, rustfmt, Miri, and stale tsconfig references on main#37078
dylan-conway merged 5 commits into
mainfrom
farm/4a071ba6/fix-main-clippy-fmt

Conversation

@robobun

@robobun robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

cargo clippy and cargo fmt --check are red on main, so every PR touching Rust inherits failing Clippy and Format checks. Both workflows only run on pull_request, which is how the drift landed unnoticed.

Clippy (2 errors)

cargo clippy --workspace --no-deps now exits 0.

rustfmt (4 files)

src/bun_core/tty.rs, src/md/ansi_renderer.rs, src/runtime/bake/bake_body.rs, src/runtime/server/server_body.rs had unformatted hunks. Ran cargo fmt --all; cargo fmt --all --check now exits 0.

tsconfig

  • Root tsconfig.json still referenced ./src/bake, which moved to ./src/runtime/bake in the Rust rewrite, so tsc --noEmit failed immediately with TS6053. Updated the project reference.
  • test/tsconfig.json now excludes the three test/regression/issue/14477/*-mismatch.tsx fixtures: they contain deliberately mismatched JSX closing tags (the test asserts the parse error), which are unsuppressable TS17002 syntax errors.

Note: cd test && tsc --noEmit still reports several thousand pre-existing semantic errors across the test suite; that is long-standing drift (not CI-enforced) and out of scope here.

Also verified green on this branch: oxlint, clang-format check, prettier.

Miri

cargo miri test is also red on every PR: #37052 routed all byte search through the highway C++ kernels, and Miri cannot call foreign functions. The first caller to hit it is bun_ptr::ref_count::type_base_name (strings::last_index_of -> highway_memrmem). Under cfg(miri) the search wrappers in src/highway/lib.rs now take their scalar paths: the char and char-set scans reuse their existing short-input scalar prologue at every length, and the mem*mem wrappers get a scalar substring search. Kernels with no scalar form (hashing, hex, sourcemaps, lexer scans) stay FFI-only so a Miri-tested crate reaching one still fails loudly. Verified locally: bun run rust:miri green on bun_ptr (previously failing), bun_ast, bun_base64, bun_clap, bun_collections, bun_dispatch, bun_errno, and bun_hash; this PR's Miri workflow runs the full set.

Verification

The changes have no runtime-observable behavior: the proof is this PR's own Clippy and Format CI checks, which run cargo clippy --workspace and cargo fmt --all --check (both red on main, both green here), plus tsc --noEmit resolving again at the repo root. An earlier revision added a source-lint test walking the tsconfig reference graph; it was removed per maintainer feedback.

clippy -D warnings was failing on the workspace:
- yaml.rs bind_anchor takes PendingAnchor by value so binding consumes
  the must_use token; allow needless_pass_by_value there (from #37055)
- uws_handlers.rs wrapped NewSocket::on_close/on_handshake in swallow()
  after #37067 changed them to return unit; call them directly

cargo fmt --check was failing on 4 files (tty.rs, ansi_renderer.rs,
bake_body.rs, server_body.rs); ran cargo fmt.

tsc --noEmit failed because the root tsconfig still referenced
./src/bake, which moved to ./src/runtime/bake. The test project also
fails to parse the deliberately-mismatched JSX fixtures for issue
14477, so exclude those from test/tsconfig.json.
@robobun

robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 6:02 PM PT - Aug 6th, 2026

@robobun, your commit d0fec75 is building: #89782

Walks references[] from the root tsconfig.json and fails on any path
that is not a tsconfig file or a directory containing one, so a moved
project directory (like src/bake -> src/runtime/bake) cannot silently
break tsc and editor language services again. Trigger source-lints on
tsconfig changes so the lint runs when only a tsconfig moves.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

The pull request adds Miri-safe scalar paths for Highway searches, updates TypeScript project references and exclusions, changes socket callbacks to direct calls, and applies Rust formatting and documentation cleanup.

Highway Miri support

Layer / File(s) Summary
Miri scalar search paths
src/highway/lib.rs
Highway search wrappers use scalar implementations under Miri and retain foreign-function paths otherwise.

TypeScript project-reference validation

Layer / File(s) Summary
Reference configuration and fixture exclusions
tsconfig.json, test/tsconfig.json
The bake project reference points to src/runtime/bake, and the intentional JSX mismatch fixture is excluded from test configuration.

Rust runtime updates

Layer / File(s) Summary
Direct socket callback invocation
src/runtime/socket/uws_handlers.rs
BunListener calls api::NewSocket::on_close and on_handshake without swallow.
Formatting, imports, and parser documentation
src/bun_core/tty.rs, src/md/ansi_renderer.rs, src/parsers/yaml.rs, src/runtime/bake/bake_body.rs, src/runtime/server/server_body.rs
The Rust sources reformat calls and expressions, reorder imports, and document the by-value anchor binding.

Possibly related PRs

  • oven-sh/bun#35437: Both changes touch src/runtime/server/server_body.rs, but they modify different functions.
  • oven-sh/bun#36123: Both changes include RAII or lifetime-management cleanup in different code paths.

Suggested reviewers: jarred-sumner

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the PR's main fixes for Clippy, rustfmt, Miri, and stale TypeScript configuration references.
Description check ✅ Passed The description explains the changes, verification steps, scope, and remaining pre-existing errors in sufficient detail.

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2

🤖 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 `@test/internal/source-lints/tsconfig-references.test.ts`:
- Around line 65-76: Update the path resolution logic around the statSync calls
so catches return null only for expected not-found filesystem errors; rethrow
permission, I/O, and other syscall failures with the affected path context.
Apply this to both the initial stat check and the tsconfig.json lookup while
preserving the existing file and directory resolution behavior.
- Line 55: Replace the manual JSON cleanup and JSON.parse call in the
configuration parsing helper with TypeScript’s ts.parseConfigFileTextToJson or
another established JSONC parser. Preserve the helper’s current
parsed-configuration behavior while ensuring comments and trailing commas are
handled without modifying string contents or accepting otherwise invalid JSON.
🪄 Autofix

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: a4d680a3-2a3a-4b6d-a5a0-f228fa90e35d

📥 Commits

Reviewing files that changed from the base of the PR and between 3171136 and 1cdbe8b.

📒 Files selected for processing (10)
  • .github/workflows/source-lints.yml
  • src/bun_core/tty.rs
  • src/md/ansi_renderer.rs
  • src/parsers/yaml.rs
  • src/runtime/bake/bake_body.rs
  • src/runtime/server/server_body.rs
  • src/runtime/socket/uws_handlers.rs
  • test/internal/source-lints/tsconfig-references.test.ts
  • test/tsconfig.json
  • tsconfig.json

Comment thread test/internal/source-lints/tsconfig-references.test.ts Outdated
Comment thread test/internal/source-lints/tsconfig-references.test.ts Outdated
Trailing-comma removal now happens in the scanner only when emitting a
bracket outside a string, so a string value containing ",]" is left
alone; a block comment becomes a single space so it cannot fuse two
tokens into accidentally valid JSON. statSync uses throwIfNoEntry so
only ENOENT reads as a missing reference and real I/O errors propagate.
@robobun

robobun commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

A note on verification, since these are lint and formatting fixes with no runtime-observable behavior.

On main, cargo clippy --workspace --no-deps exits with 2 errors (needless_pass_by_value in src/parsers/yaml.rs, two unit_arg in src/runtime/socket/uws_handlers.rs) and cargo fmt --all --check fails on 4 files. Both workflows only run on pull requests, so every Rust-touching PR currently inherits the red checks. On this branch both workflows pass; they run the exact commands that fail on main, so they are the direct proof of the fix.

The tsconfig repairs are exercised by the new lint in test/internal/source-lints/tsconfig-references.test.ts: on the pre-PR tree it fails because the root reference to ./src/bake does not resolve, and it passes here. The Source lints workflow runs it and is green.

The Rust changes compile to identical behavior (an allow attribute, formatting, and dropping a wrapper that was a no-op around calls that now return unit), so no runtime test can fail without them; the CI checks above are the verification.

@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.

LGTM — mechanical lint/format cleanup with no runtime behavior change.

What was reviewed:

  • rustfmt hunks in tty.rs/ansi_renderer.rs/bake_body.rs/server_body.rs are whitespace/import-order only.
  • uws_handlers.rs: confirmed NewSocket::on_close/on_handshake now return () (socket_body.rs:2035/1666), so dropping swallow(()) is a no-op and matches the sibling on_data/on_writable/on_end/on_timeout handlers in the same impl.
  • tsconfig: verified src/runtime/bake/tsconfig.json exists and src/bake does not; the 14477 *-mismatch.tsx fixtures exist and are deliberately-invalid JSX.
  • New source-lint test: string-aware JSONC scanner (not regex-based), throwIfNoEntry: false correctly lets non-ENOENT stat errors throw; both CodeRabbit threads are addressed and resolved.
Extended reasoning...

Overview

This PR fixes CI lint drift on main: two clippy errors, four rustfmt-unformatted files, a stale tsconfig project reference (./src/bake./src/runtime/bake), and adds a source-lint test that walks the tsconfig references[] graph so a moved project directory can't silently break tsc --noEmit again. It also excludes three intentionally-malformed JSX fixtures from test/tsconfig.json and adds tsconfig paths to the source-lints workflow triggers.

Security risks

None. No user-facing runtime code paths are touched. The Rust changes are: whitespace reformatting (rustfmt), import reordering, a targeted #[allow(clippy::needless_pass_by_value)] with a stated reason (matching four existing uses in the tree), and removing a no-op swallow(()) wrapper around two calls whose return type changed to () in #37067.

Level of scrutiny

Low. The rustfmt hunks are mechanically verifiable as whitespace-only. The swallow() removal is behavior-preserving because Swallow for () is already a no-op, and I verified the inherent on_close/on_handshake on NewSocket in socket_body.rs return (). The tsconfig path fix is verified against the filesystem (src/runtime/bake/tsconfig.json exists, src/bake does not). The new test is a source-tree lint that runs against a released bun on a bare checkout — it can't affect the built binary.

Other factors

Both CodeRabbit inline comments were addressed in commit 53f6080 and are marked resolved: the JSONC parser is now a string-aware character scanner (handles escapes, inserts a space for stripped block comments so 1/* */2 stays invalid, only strips trailing commas outside strings), and the file comment explains why ts.parseConfigFileTextToJson isn't used (no bun install in the source-lints workflow). resolveReference uses statSync(..., { throwIfNoEntry: false }) so only ENOENT maps to null; permission/I/O errors still throw with the path. The PR description accurately scopes what is and isn't fixed (pre-existing test/ tsc semantic errors are out of scope). No prior human review comments are outstanding.

Keep the tsconfig repairs; drop the lint test and its workflow
triggers.

@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.

LGTM — mechanical lint/format cleanup with no runtime behavior change.

What was reviewed:

  • rustfmt hunks in 4 files are pure whitespace/import-order; uws_handlers.rs drops swallow(()) around NewSocket::on_close/on_handshake, which now return () — verified in src/runtime/socket/mod.rs:143,173, and matches the sibling on_data_no_ext/on_end_no_ext calls in the same impl.
  • #[allow(needless_pass_by_value)] on bind_anchor is justified — PendingAnchor is #[must_use] (yaml.rs:3243), so consuming it by value is the intent.
  • tsconfig: src/runtime/bake/tsconfig.json exists and src/bake does not; the three 14477/*-mismatch.tsx fixtures exist and are deliberate parse-error inputs.
  • CodeRabbit threads target the source-lint test that was removed in d70c236 per maintainer feedback; both are resolved and moot.
Extended reasoning...

Overview

This PR fixes lint/format drift on main across 8 files: four pure cargo fmt reflows (tty.rs, ansi_renderer.rs, bake_body.rs, server_body.rs — line wrapping and import ordering only), one targeted #[allow(clippy::needless_pass_by_value)] on Parser::bind_anchor in the YAML parser, removal of two swallow(...) wrappers around unit-returning calls in uws_handlers.rs, a stale project-reference path in the root tsconfig.json (./src/bake./src/runtime/bake), and an exclude glob in test/tsconfig.json for intentionally-invalid JSX fixtures. An earlier revision also added a tsconfig-reference source-lint test, but the final commit removed it per maintainer feedback — the two CodeRabbit inline threads are on that removed file and are resolved.

Security risks

None. No user-facing surface, no parsing of untrusted input, no auth/crypto/permissions. The only non-formatting Rust changes are an #[allow] attribute and unwrapping a no-op swallow(()) — both compile to identical machine code.

Level of scrutiny

Low. This is the canonical "unbreak main's lint CI" PR: every hunk is either tool-generated (cargo fmt), a lint suppression with a stated reason, or a config path correction. I verified the substantive claims against the tree: PendingAnchor carries #[must_use = "an anchor must be bound to the node it annotates"] at yaml.rs:3243, so pass-by-value is deliberate and the allow is correct. api::NewSocket::on_close / on_handshake in src/runtime/socket/mod.rs return unit, so swallow(unit) was dead — and the four neighboring *_no_ext handlers in the same BunListener impl already call directly without swallow, so this change makes the block internally consistent rather than diverging from it. src/runtime/bake/tsconfig.json exists on disk and src/bake does not. The three test/regression/issue/14477/*-mismatch.tsx fixtures exist and the sibling 14477.test.ts asserts their parse errors, so excluding them from tsc is correct.

Other factors

Verification is the PR's own Clippy/Format CI checks (both red on main, green here) plus tsc --noEmit at the repo root — appropriate for changes with no runtime-observable behavior. There are no outstanding human reviewer comments; the only inline threads (CodeRabbit) target a file no longer in the diff and are marked resolved. No prior claude[bot] review on this PR.

…ernels

cargo miri test cannot call foreign functions, and #37052 routed all
byte search through the highway FFI, which broke the Miri workflow:
bun_ptr's type_base_name hits highway_memrmem via strings::last_index_of.

Under cfg(miri) the char and char-set scans take their existing scalar
prologue at every length, and the four mem*mem wrappers use a scalar
substring search. Kernels with no scalar form here (hashing, hex,
sourcemaps, lexer scans) stay FFI-only, so a Miri-tested crate reaching
one still fails loudly.
@robobun robobun changed the title Fix clippy, rustfmt, and stale tsconfig references on main Fix clippy, rustfmt, Miri, and stale tsconfig references on main Aug 7, 2026
Comment thread src/highway/lib.rs
Comment thread src/highway/lib.rs
@dylan-conway
dylan-conway enabled auto-merge (squash) August 7, 2026 01:04

@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.

LGTM — mechanical lint/format/config repairs with no production behavior change.

What was reviewed:

  • rustfmt reflows in tty.rs, ansi_renderer.rs, bake_body.rs, server_body.rs — whitespace only.
  • swallow(...) removal in uws_handlers.rs: verified NewSocket::on_close/on_handshake return () (socket_body.rs:1666, :2035), and impl Swallow for () is a no-op — behavior-identical, now matches sibling on_data_no_ext etc.
  • highway/lib.rs: under non-Miri, scalar_only(len) folds to exactly len < SCALAR_CUTOFF (cfg!(miri) is a compile-time false), so the FFI paths are byte-identical; the cfg(miri) scalar memmem/memrmem fallbacks are only reachable under Miri and their callers already guard empty-needle and haystack.len() < needle.len() so the 0..=len-nlen range can't underflow.
  • tsconfig: confirmed src/runtime/bake/tsconfig.json exists and src/bake does not; the 14477 *-mismatch.tsx fixtures exist and are intentionally-invalid JSX.

The two comment-cop flags on highway/lib.rs are length-heuristic hits on doc comments; the scalar_memmem one documents the no-underflow precondition and the scalar_only one explains why hashing/hex kernels stay FFI-only under Miri — both read as design docs rather than workaround justifications, but trim if preferred.

Extended reasoning...

Overview

Nine files: four are pure cargo fmt reflows (line-wrapping and import ordering only), one adds a targeted #[allow(clippy::needless_pass_by_value)] with a one-line rationale, one drops two swallow(...) wrappers around calls that now return (), two are tsconfig path/exclude fixes, and one (src/highway/lib.rs) adds cfg(miri)-gated scalar fallbacks so byte-search wrappers work under Miri where FFI is unavailable. An earlier revision's source-lint test was removed per maintainer feedback, so the CodeRabbit threads on that file are moot (and marked resolved).

Security risks

None. No user-input parsing, no auth/crypto/permissions, no FFI signature or ownership changes. The highway change adds Rust-only code paths that are dead under normal compilation.

Level of scrutiny

Low. The rustfmt hunks are mechanical. The #[allow] is a lint suppression with a stated reason. The swallow removal: impl Swallow for () is fn swallow(self) {}, and both api::NewSocket::on_close and on_handshake return () (verified at socket_body.rs:1666/2035) — dropping the wrapper is a no-op and now matches the four neighboring on_*_no_ext bodies in the same impl. The highway change is the only non-trivial hunk, but its non-Miri path is provably identical: scalar_only(len) is #[inline(always)] returning cfg!(miri) || len < SCALAR_CUTOFF, and cfg!(miri) is a compile-time false in every real build, so the branch condition is unchanged. The cfg(miri)-only scalar_memmem/scalar_memrmem are naïve (0..=hlen-nlen).find(...) scans reached only after the caller has handled empty-needle and hlen < nlen, so no underflow. match_at and the four highway_mem*mem* externs are correctly #[cfg(not(miri))]-gated to avoid dead-code warnings.

Other factors

Verification is the CI lints themselves (Clippy/Format/Miri red on main, green here), which is appropriate for changes with no runtime-observable behavior. The tsconfig reference target and 14477 fixture directory both exist on disk. The two open comment-cop bot flags on highway/lib.rs are automated comment-length heuristics on doc comments that document a Miri-specific design decision and a precondition contract; I don't read them as blocking — they're not justifying a workaround, they're stating why the split exists — but the author can shorten them if the maintainers want the bot green.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants