Skip to content

Remove trailing semicolons from macro bodies - #940

Merged
max-sixty merged 1 commit into
mitsuhiko:masterfrom
Tiwalun:fix/trailing-semicolon-lint
Sep 18, 2026
Merged

max-sixty merged 1 commit into
mitsuhiko:masterfrom
Tiwalun:fix/trailing-semicolon-lint

Conversation

@Tiwalun

@Tiwalun Tiwalun commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

clippy from cargo 1.99.0-beta.6 includes a new lint, which triggers on trailing semicolon in expression macro bodies.

Code like this:

#[test]
fn it_works() {
  insta::assert_json_snapshot!("a")
}

leads to this clippy warning:

warning: trailing semicolon in macro used in expression position
  --> src/lib.rs:10:9
   |
10 |         insta::assert_json_snapshot!("a")
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: macro invocations at the end of a block are treated as expressions
   = note: to ignore the value produced by the macro, add a semicolon after the invocation of `assert_json_snapshot`
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
   = note: `#[warn(semicolon_in_expressions_from_non_local_macros)]` (part of `#[warn(future_incompatible)]`) on by default
   = note: this warning originates in the macro `insta::assert_json_snapshot` (in Nightly builds, run with -Z macro-backtrace for more info)

This change removes these semicolons.

Looking at the output of cargo-expand, the final code doesn't seem to change, so this shouldn't have

See rust-lang/rust#79813.

clippy from cargo 1.99.0-beta.6 includes a new lint,
which triggers on trailing semicolon in expression macro bodies.

This change removes these semicolons.

See <rust-lang/rust#79813>.
@max-sixty
max-sixty merged commit 08b67d9 into mitsuhiko:master Sep 18, 2026
15 checks passed
@nyurik

nyurik commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@max-sixty thx for merging - would it be possible to release it? Thx!

max-sixty pushed a commit that referenced this pull request Oct 10, 2026
#940 removed the trailing semicolons from the serialization macro bodies
but missed the two-argument arm of `assert_binary_snapshot!`, so calling
it at the end of a block still warns with
`semicolon_in_expressions_from_non_local_macros` on newer toolchains.
this drops that semicolon and the one in `test_binary.rs`, so the test
covers it (fails on nightly without the fix, the pinned 1.95 doesn't
fire the lint here).
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.

3 participants