Skip to content

fix(core): move newer bail! sites out of expression position (partial #2835, complements #2843) - #3086

Closed
phil-opp wants to merge 1 commit into
mainfrom
claude/clever-wright-npgouu-2835-semicolon-in-macros
Closed

fix(core): move newer bail! sites out of expression position (partial #2835, complements #2843)#3086
phil-opp wants to merge 1 commit into
mainfrom
claude/clever-wright-npgouu-2835-semicolon-in-macros

Conversation

@phil-opp

@phil-opp phil-opp commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Part of #2835. Complements the pre-existing #2843 — please land both.

eyre::bail! / bail! expand to a block ending in a semicolon ({ return Err(..); }). Used as the tail expression of a block or as a bare match arm, that trailing semicolon is in expression position, which trips semicolon_in_expressions_from_macros / semicolon_in_expressions_from_non_local_macros — denied under future_incompatible on recent nightlies, failing dora-core compilation.

Relationship to #2843

#2843 (opened 2026-07-26, Closes #2835) fixes this lint class across the whole workspace (48 files: node API, CLI, etc.). Since then, newer code has merged into main that introduced additional expression-position bail! sites in dora-core which #2843 does not cover. This PR fixes those.

The two PRs are disjoint — no overlapping files — so both can land independently, and dora-core is only fully clean once both do:

dora-core file fixed by
build/git.rs, descriptor/mod.rs, descriptor/validate.rs, descriptor/expand.rs this PR
topics.rs, build/mod.rs #2843

What changed here

Moved every affected call in the files above to statement position:

  • Block-tail calls ({ …; bail!(..) }): added a trailing ;.
  • Bare match arms (_ => bail!(..)): wrapped in a { bail!(..); } block.

18 sites total. Every one diverges (bail! returns early), so it still coerces to the surrounding arm/expression type via the never type — no runtime behavior change.

Verification

Toolchain: rustc 1.99.0-nightly (771916f90 2026-08-08).

  • cargo +nightly check -p dora-core — the 13 diagnostics that were reported at these sites are gone. (Note: which sites a given nightly flags for the non-local eyre::bail! variant varies by toolchain build; the topics.rs / build/mod.rs sites owned by fix: avoid bail macros in expression position #2843 are the remaining ones needed for full cross-toolchain coverage.)
  • cargo +1.97.1 check -p dora-core — clean on the pinned toolchain.
  • cargo +1.97.1 clippy -p dora-core -- -D warnings — clean.
  • cargo +1.97.1 fmt -p dora-core -- --check — clean.
  • cargo +1.97.1 test -p dora-core — 272 passing.

… builds (#2835)

Several `eyre::bail!` / `bail!` invocations in `dora-core` sat as the tail
expression of a block or as a bare `match` arm. Because the macro expands to a
block ending in a semicolon (`{ return Err(..); }`), using it in expression
position triggers `semicolon_in_expressions_from_macros`, which is denied under
`future_incompatible` on newer toolchains and fails `dora-core` compilation on
nightly.

Move each affected call to statement position — add a trailing `;` for
block-tail calls and wrap bare `match` arms in a `{ ...; }` block. All these
blocks diverge (`bail!` returns early), so they still coerce to the surrounding
arm/expression type and runtime behavior is unchanged.

Verified with `cargo +nightly check -p dora-core` (no more trailing-semicolon
warnings) and `cargo +1.97.1 test -p dora-core` (272 passing).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LGoZSqmyXqMk28Bjndo1J
@trunk-io

trunk-io Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

phil-opp commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 Automated review by Claude — this is a fully automated review with no human in the loop.

I reviewed this diff and found no issues. The changes are mechanical: adding a trailing ; to block-tail bail! / eyre::bail! calls and wrapping bare match-arm bail! calls in { …; } blocks across libraries/core/src/build/git.rs, descriptor/expand.rs, descriptor/mod.rs, and descriptor/validate.rs. Every touched call diverges (early return), so it still coerces to the surrounding arm/expression type and runtime behavior is unchanged — the change only silences the semicolon_in_expressions_from_macros nightly lint.

One thing worth flagging for the maintainer: this overlaps with the still-open #2843 ("avoid bail macros in expression position"), which applies the same fix more broadly. You may want to reconcile the two so the lint fix lands once.


Generated by Claude Code

@phil-opp
phil-opp marked this pull request as ready for review August 9, 2026 11:34
Lioyae added a commit to Lioyae/dora that referenced this pull request Aug 9, 2026
@phil-opp

Copy link
Copy Markdown
Collaborator Author

Update: eyre-rs/eyre#294 was merged and a PR to do a new release is up: eyre-rs/eyre#296

@phil-opp

Copy link
Copy Markdown
Collaborator Author

The 18 edited sites are all correct — every one diverges, so !-coercion keeps them type-checking and there is no runtime change.

One correction to the body: it states that cargo +nightly check -p dora-core has no remaining trailing semicolon in macro diagnostics. That is not the case. Two expression-position sites survive in dora-core: libraries/core/src/topics.rs:486 (Err(VarError::NotUnicode(_)) => eyre::bail!(...), a bare match arm) and libraries/core/src/build/mod.rs:277 (block-tail eyre::bail! in the else of validate_subdir). Both are covered by #2843.

So this PR alone does not unblock the nightly build of dora-core — it does so only once #2843 lands too. Worth either correcting the body or merging the two as a pair. (They are otherwise disjoint: no file overlap, so both should land.)

@phil-opp phil-opp changed the title fix(core): move bail! out of expression position to unblock nightly builds (#2835) fix(core): move newer bail! sites out of expression position (partial #2835, complements #2843) Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks — you're right, and I've corrected the body.

Confirmed against the current tree: within dora-core, #2843 touches only topics.rs and build/mod.rs, and this PR touches only build/git.rs + the descriptor/{mod,validate,expand}.rs sites — no file overlap, so the two are complementary. My PR covers the expression-position bail! sites in code that merged into main after #2843 was opened; dora-core is fully nightly-clean only once both land. The title/body now scope the claim to a partial fix rather than a standalone unblock.

(On rustc 1.99.0-nightly (771916f90 2026-08-08) I don't reproduce the diagnostic at the two #2843 sites, whereas #2843 was validated on da86f4d07 2026-07-24 — the non-local eyre::bail! variant seems to be flagged inconsistently across nightly builds. Landing both makes the crate robust regardless of which nightly a contributor runs.)


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Heads up — this may no longer be needed. eyre 0.6.14 has been released, and it removes the trailing semicolon from every arm of the bail! macro:

 macro_rules! bail {
     ($msg:literal $(,)?) => {
-        return $crate::private::Err($crate::eyre!($msg));
+        return $crate::private::Err($crate::eyre!($msg))
     };
     …
 }

That semicolon was the entire cause of the lint, so both shapes this PR rewrites — block-tail calls and bare match arms — are fine as-is under 0.6.14.

I opened #3126, a one-package Cargo.lock bump with no source changes. On rustc 1.99.0-nightly (12c36e253 2026-08-10), cargo +nightly check --all (excluding the PyO3 crates) drops from 154 trailing semicolon in macro used in expression position diagnostics across 17 crates to 0, which subsumes both this PR's 4 dora-core files and #2843's 48.

Worth noting your observation here — that which sites a given nightly flags for the non-local eyre::bail! variant varies by toolchain build — held up in testing: on the nightly above the diagnostics surface as future-incompat warnings rather than the hard errors reported in #2835. That variability is a good argument for fixing it at the dependency rather than chasing call sites per toolchain.

Deferring to the maintainers on whether to close this in favour of #3126.


Generated by Claude Code

@phil-opp phil-opp closed this Aug 11, 2026
trunk-io Bot pushed a commit that referenced this pull request Aug 11, 2026
…supersedes #2843, #3086) (#3126)

chore(deps): bump eyre to 0.6.14 to fix expression-position `bail!`

eyre 0.6.14 removes the trailing semicolon from every arm of the `bail!`
macro. That semicolon was the sole cause of the
`semicolon_in_expressions_from_macros` /
`semicolon_in_expressions_from_non_local_macros` diagnostics reported in
 #2835, which fire whenever `bail!` is used as a block-tail expression or
as a bare `match` arm.

Bumping the lockfile clears all 154 affected call sites across 17 crates
without touching a single line of dora source, superseding the manual
semicolon insertion in #2843 and #3086.

Verified with rustc 1.99.0-nightly (12c36e253 2026-08-10):

  cargo +nightly check --all (excluding the PyO3 crates)
    eyre 0.6.12: 154 "trailing semicolon in macro used in expression
                 position" diagnostics
    eyre 0.6.14: 0

The only remaining future-incompat report comes from the third-party
`static_init_macro v1.0.4` and is unrelated.


Claude-Session: https://claude.ai/code/session_01BRDAyUb1r1nLd3i4Sc2UXy

Co-authored-by: Claude <noreply@anthropic.com>
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