From bd404ed8a54d5f230fc9cc08346decbe8ad5ffce Mon Sep 17 00:00:00 2001 From: DualFroz Date: Wed, 7 Oct 2026 20:11:30 +0200 Subject: [PATCH] Remove trailing semicolon from assert_binary_snapshot! macro body #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. --- CHANGELOG.md | 6 ++++++ insta/src/macros.rs | 2 +- insta/tests/test_binary.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3e0862..7abda0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to insta and cargo-insta are documented here. +## Unreleased + +- Remove the trailing semicolon from the `assert_binary_snapshot!` macro body, + which #940 missed, to avoid compiler warnings when used in expression + position. + ## 1.49.0 - Allow `Option<&OsStr>` snapshot names, such as `Path::file_name()`, diff --git a/insta/src/macros.rs b/insta/src/macros.rs index 4aebed6..f27a009 100644 --- a/insta/src/macros.rs +++ b/insta/src/macros.rs @@ -409,7 +409,7 @@ macro_rules! _assert_snapshot_base { #[macro_export] macro_rules! assert_binary_snapshot { ($name_and_extension:expr, $value:expr $(,)?) => { - $crate::assert_binary_snapshot!($name_and_extension, $value, stringify!($value)); + $crate::assert_binary_snapshot!($name_and_extension, $value, stringify!($value)) }; ($name_and_extension:expr, $value:expr, $debug_expr:expr $(,)?) => { diff --git a/insta/tests/test_binary.rs b/insta/tests/test_binary.rs index c160a30..4acd52f 100644 --- a/insta/tests/test_binary.rs +++ b/insta/tests/test_binary.rs @@ -1,6 +1,6 @@ #[test] fn test_binary_snapshot() { - insta::assert_binary_snapshot!(".txt", b"test".to_vec()); + insta::assert_binary_snapshot!(".txt", b"test".to_vec()) } #[test]