Repository: mitsuhiko/insta
Pull request #749 (2025-04-01 22:09:51)

Run with `--force-update-snapshots`
As well as isolating future diffs to changes that matter, helps identify a couple of issues; e.g. how the turbofish is formatted in the `Selector` expressions



Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7b7bdb6..2cf3a5b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -7,7 +7,7 @@ repos:
       - id: check-yaml
       - id: mixed-line-ending
   - repo: https://github.com/crate-ci/typos
-    rev: v1
+    rev: v1.31.1
     hooks:
       - id: typos
         # https://github.com/crate-ci/typos/issues/347
diff --git a/.typos.toml b/.typos.toml
new file mode 100644
index 0000000..f7dddbc
--- /dev/null
+++ b/.typos.toml
@@ -0,0 +1,2 @@
+[default]
+extend-words = { "Foled" = "Foled" }
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0e105a..0d94072 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ All notable changes to insta and cargo-insta are documented here.
 - Add uppercase keyboard shortcuts for bulk operations in `cargo insta review`:
   `A` to accept all, `R` to reject all, and `S` to skip all remaining snapshots.
   #745
+- `cargo insta review` fails with a helpful error message when run in a non-TTY environment.
 
 ## 1.42.2
 
diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs
index 6c2f9f9..0fc7277 100644
--- a/cargo-insta/src/cli.rs
+++ b/cargo-insta/src/cli.rs
@@ -264,6 +264,14 @@ fn query_snapshot(
     show_info: &mut bool,
     show_diff: &mut bool,
 ) -> Result<Operation, Box<dyn Error>> {
+    // Check if we're running in a TTY environment
+    if !term.is_term() {
+        return Err(err_msg(
+            "Interactive review requires a terminal. Use `cargo insta accept` or `cargo insta reject` \
+            for non-interactive snapshot management, or run this command in a terminal environment."
+        ));
+    }
+
     loop {
         term.clear_screen()?;
 
diff --git a/insta/src/content/json.rs b/insta/src/content/json.rs
index e4dd5e6..49e3b8d 100644
--- a/insta/src/content/json.rs
+++ b/insta/src/content/json.rs
@@ -336,7 +336,7 @@ fn test_to_string() {
         (Content::from("cmdline"), Content::Seq(vec![])),
         (Content::from("extra"), Content::Map(vec![])),
     ]));
-    crate::assert_snapshot!(&json, @r###"{"environments":["development","production"],"cmdline":[],"extra":{}}"###);
+    crate::assert_snapshot!(&json, @r#"{"environments":["development","production"],"cmdline":[],"extra":{}}"#);
 }
 
 #[test]
@@ -352,7 +352,7 @@ fn test_to_string_pretty() {
         (Content::from("cmdline"), Content::Seq(vec![])),
         (Content::from("extra"), Content::Map(vec![])),
     ]));
-    crate::assert_snapshot!(&json, @r###"
+    crate::assert_snapshot!(&json, @r#"
     {
       "environments": [
         "development",
@@ -361,7 +361,7 @@ fn test_to_string_pretty() {
       "cmdline": [],
       "extra": {}
     }
-    "###);
+    "#);
 }
 
 #[test]
@@ -371,12 +371,12 @@ fn test_to_string_num_keys() {
         (Content::from(-23i32), Content::from(false)),
     ]);
     let json = to_string_pretty(&content);
-    crate::assert_snapshot!(&json, @r###"
+    crate::assert_snapshot!(&json, @r#"
     {
       "42": true,
       "-23": false
     }
-    "###);
+    "#);
 }
 
 #[test]
@@ -466,7 +466,7 @@ fn test_to_string_pretty_complex() {
     ]);
     let json = to_string_pretty(&content);
 
-    crate::assert_snapshot!(&json, @r###"
+    crate::assert_snapshot!(&json, @r##"
     {
       "is_alive": true,
       "newtype_variant": {
@@ -525,5 +525,5 @@ fn test_to_string_pretty_complex() {
       "unit": null,
       "crazy_string": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
     }
-    "###);
+    "##);
 }
diff --git a/insta/src/macros.rs b/insta/src/macros.rs
index 81d0cfc..f970cfe 100644
--- a/insta/src/macros.rs
+++ b/insta/src/macros.rs
@@ -253,6 +253,14 @@ macro_rules! _assert_serialized_snapshot {
         };
         $crate::_assert_snapshot_base!(transform=transform, $value $($arg)*);
     }};
+    // If there's a name, redaction expressions, and debug_expr, capture and pass all to `_assert_snapshot_base`
+    (format=$format:ident, $name:expr, $value:expr, $(match ..)? {$($k:expr => $v:expr),* $(,)?}, $debug_expr:expr $(,)?) => {{
+        let transform = |value| {
+            let (_, value) = $crate::_prepare_snapshot_for_redaction!(value, {$($k => $v),*}, $format);
+            value
+        };
+        $crate::_assert_snapshot_base!(transform=transform, $name, $value, $debug_expr);
+    }};
     // If there's a name and redaction expressions, capture and pass to `_assert_snapshot_base`
     (format=$format:ident, $name:expr, $value:expr, $(match ..)? {$($k:expr => $v:expr),* $(,)?} $(,)?) => {{
         let transform = |value| {
diff --git a/insta/src/serialization.rs b/insta/src/serialization.rs
index 749a2a8..48f64c9 100644
--- a/insta/src/serialization.rs
+++ b/insta/src/serialization.rs
@@ -126,14 +126,14 @@ fn test_yaml_serialization() {
         ]),
         SerializationFormat::Yaml,
     );
-    crate::assert_snapshot!(&yaml, @r###"
+    crate::assert_snapshot!(&yaml, @r"
     env:
       - ENVIRONMENT
       - production
     cmdline:
       - my-tool
       - run
-    "###);
+    ");
 
     let inline_yaml = serialize_content(
         Content::Map(vec![
@@ -151,12 +151,12 @@ fn test_yaml_serialization() {
         ]),
         SerializationFormat::Yaml,
     );
-    crate::assert_snapshot!(&inline_yaml, @r###"
+    crate::assert_snapshot!(&inline_yaml, @r"
     env:
       - ENVIRONMENT
       - production
     cmdline:
       - my-tool
       - run
-    "###);
+    ");
 }
diff --git a/insta/src/snapshot.rs b/insta/src/snapshot.rs
index 3d87212..c6142b4 100644
--- a/insta/src/snapshot.rs
+++ b/insta/src/snapshot.rs
@@ -860,28 +860,28 @@ fn names_of_path(path: &Path) -> (String, String) {
 #[test]
 fn test_names_of_path() {
     assert_debug_snapshot!(
-        names_of_path(Path::new("/src/snapshots/insta_tests__tests__name_foo.snap")), @r###"
+        names_of_path(Path::new("/src/snapshots/insta_tests__tests__name_foo.snap")), @r#"
     (
         "name_foo",
         "insta_tests__tests",
     )
-    "###
+    "#
     );
     assert_debug_snapshot!(
-        names_of_path(Path::new("/src/snapshots/name_foo.snap")), @r###"
+        names_of_path(Path::new("/src/snapshots/name_foo.snap")), @r#"
     (
         "name_foo",
         "",
     )
-    "###
+    "#
     );
     assert_debug_snapshot!(
-        names_of_path(Path::new("foo/src/snapshots/go1.20.5.snap")), @r###"
+        names_of_path(Path::new("foo/src/snapshots/go1.20.5.snap")), @r#"
     (
         "go1.20.5",
         "",
     )
-    "###
+    "#
     );
 }
 
@@ -1282,12 +1282,11 @@ fn test_empty_lines() {
     assert_snapshot!(r#"multiline content starting on first line
 
     final line
-    "#, @r###"
+    "#, @r"
     multiline content starting on first line
 
         final line
-
-    "###);
+    ");
 
     assert_snapshot!(r#"
     multiline content starting on second line
diff --git a/insta/src/utils.rs b/insta/src/utils.rs
index f800252..5325dd3 100644
--- a/insta/src/utils.rs
+++ b/insta/src/utils.rs
@@ -122,7 +122,7 @@ fn test_format_rust_expression() {
     use crate::assert_snapshot;
     assert_snapshot!(format_rust_expression("vec![1,2,3]"), @"vec![1, 2, 3]");
     assert_snapshot!(format_rust_expression("vec![1,2,3].iter()"), @"vec![1, 2, 3].iter()");
-    assert_snapshot!(format_rust_expression(r#"    "aoeu""#), @r###""aoeu""###);
-    assert_snapshot!(format_rust_expression(r#"  "aoe😄""#), @r###""aoe😄""###);
+    assert_snapshot!(format_rust_expression(r#"    "aoeu""#), @r#""aoeu""#);
+    assert_snapshot!(format_rust_expression(r#"  "aoe😄""#), @r#""aoe😄""#);
     assert_snapshot!(format_rust_expression("😄😄😄😄😄"), @"😄😄😄😄😄")
 }


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index fd2c71e..4434074 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -83,7 +83,7 @@ jobs:
   clippy:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: dtolnay/rust-toolchain@master
         with:
           toolchain: stable
@@ -98,7 +98,7 @@ jobs:
     continue-on-error: true
 
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: dtolnay/rust-toolchain@master
         with:
           toolchain: nightly
@@ -111,7 +111,7 @@ jobs:
   rustfmt:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: dtolnay/rust-toolchain@master
         with:
           toolchain: stable
diff --git a/cargo-insta/tests/functional/inline.rs b/cargo-insta/tests/functional/inline.rs
index edb9153..2b8a3f0 100644
--- a/cargo-insta/tests/functional/inline.rs
+++ b/cargo-insta/tests/functional/inline.rs
@@ -187,7 +187,7 @@ fn test_trailing_comma_in_inline_snapshot() {
 
     assert!(&output.status.success());
 
-    assert_snapshot!(test_project.diff("src/lib.rs"), @r##"
+    assert_snapshot!(test_project.diff("src/lib.rs"), @r#"
     --- Original: src/lib.rs
     +++ Updated: src/lib.rs
     @@ -1,21 +1,19 @@
@@ -223,7 +223,7 @@ fn test_trailing_comma_in_inline_snapshot() {
     +        @"new value",  // comma here
          );
      }
-    "##);
+    "#);
 }
 
 /// Test the old format of inline YAML snapshots with a leading `---` still passes
diff --git a/cargo-insta/tests/functional/workspace.rs b/cargo-insta/tests/functional/workspace.rs
index f2b40d3..7e29e1e 100644
--- a/cargo-insta/tests/functional/workspace.rs
+++ b/cargo-insta/tests/functional/workspace.rs
@@ -88,7 +88,7 @@ fn test_root_crate_workspace_accept() {
 
     assert!(&output.status.success());
 
-    assert_snapshot!(test_project.file_tree_diff(), @r###"
+    assert_snapshot!(test_project.file_tree_diff(), @r"
     --- Original file tree
     +++ Updated file tree
     @@ -1,8 +1,13 @@
@@ -105,7 +105,7 @@ fn test_root_crate_workspace_accept() {
          src/main.rs
     +    src/snapshots
     +      src/snapshots/root_crate_workspace_accept__root.snap
-    "###     );
+    "     );
 }
 
 /// Check that in a workspace with a default root crate, running `cargo insta
@@ -145,7 +145,7 @@ fn test_root_crate_no_all() {
 
     assert!(&output.status.success());
 
-    assert_snapshot!(test_project.file_tree_diff(), @r###"
+    assert_snapshot!(test_project.file_tree_diff(), @r"
     --- Original file tree
     +++ Updated file tree
     @@ -1,4 +1,5 @@
@@ -160,7 +160,7 @@ fn test_root_crate_no_all() {
          src/main.rs
     +    src/snapshots
     +      src/snapshots/root_crate_no_all__root.snap
-    "###     );
+    "     );
 }
 
 fn workspace_with_virtual_manifest(name: String) -> TestFiles {
@@ -247,7 +247,7 @@ fn test_virtual_manifest_all() {
 
     assert!(&output.status.success());
 
-    assert_snapshot!(test_project.file_tree_diff(), @r###"
+    assert_snapshot!(test_project.file_tree_diff(), @r"
     --- Original file tree
     +++ Updated file tree
     @@ -1,10 +1,15 @@
@@ -266,7 +266,7 @@ fn test_virtual_manifest_all() {
            member-2/src/lib.rs
     +      member-2/src/snapshots
     +        member-2/src/snapshots/virtual_manifest_all_member_2__member_2.snap
-    "###     );
+    "     );
 }
 
 /// Check that in a workspace with a virtual manifest, running `cargo insta test
@@ -284,7 +284,7 @@ fn test_virtual_manifest_default() {
 
     assert!(&output.status.success());
 
-    assert_snapshot!(test_project.file_tree_diff(), @r###"
+    assert_snapshot!(test_project.file_tree_diff(), @r"
     --- Original file tree
     +++ Updated file tree
     @@ -1,10 +1,15 @@
@@ -303,7 +303,7 @@ fn test_virtual_manifest_default() {
            member-2/src/lib.rs
     +      member-2/src/snapshots
     +        member-2/src/snapshots/virtual_manifest_default_member_2__member_2.snap
-    "###     );
+    "     );
 }
 
 /// Check that in a workspace with a virtual manifest, running `cargo insta test
@@ -321,7 +321,7 @@ fn test_virtual_manifest_single_crate() {
 
     assert!(&output.status.success());
 
-    assert_snapshot!(test_project.file_tree_diff(), @r###"
+    assert_snapshot!(test_project.file_tree_diff(), @r"
     --- Original file tree
     +++ Updated file tree
     @@ -1,9 +1,12 @@
@@ -337,7 +337,7 @@ fn test_virtual_manifest_single_crate() {
        member-2
          member-2/Cargo.toml
          member-2/src
-    "###     );
+    "     );
 }
 
 use std::path::{Path, PathBuf};
@@ -943,7 +943,7 @@ fn test_inline() {
     assert!(output.status.success());
 
     // Verify inline snapshot
-    assert_snapshot!(test_project.diff("src/lib.rs"), @r##"
+    assert_snapshot!(test_project.diff("src/lib.rs"), @r#"
     --- Original: src/lib.rs
     +++ Updated: src/lib.rs
     @@ -10,5 +10,5 @@
@@ -953,7 +953,7 @@ fn test_inline() {
     -    insta::assert_snapshot!("This is an inline snapshot for manifest path test", @"");
     +    insta::assert_snapshot!("This is an inline snapshot for manifest path test", @"This is an inline snapshot for manifest path test");
      }
-    "##);
+    "#);
     assert_snapshot!(test_project.file_tree_diff(), @r"
     --- Original file tree
     +++ Updated file tree
diff --git a/insta/tests/snapshots/test_redaction__foo_bar.snap b/insta/tests/snapshots/test_redaction__foo_bar.snap
index b06fb5c..f71ab16 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo.bar\").unwrap()"
+expression: "Selector :: parse(\".foo.bar\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__foo_bar_alt.snap b/insta/tests/snapshots/test_redaction__foo_bar_alt.snap
index 575b156..aeb12a7 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar_alt.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar_alt.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo[\\\"bar\\\"]\").unwrap()"
+expression: "Selector :: parse(\".foo[\\\"bar\\\"]\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__foo_bar_deep.snap b/insta/tests/snapshots/test_redaction__foo_bar_deep.snap
index 9cb30bd..1203254 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar_deep.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar_deep.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo.bar.**\").unwrap()"
+expression: "Selector :: parse(\".foo.bar.**\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__foo_bar_full_range.snap b/insta/tests/snapshots/test_redaction__foo_bar_full_range.snap
index d702353..9873e31 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar_full_range.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar_full_range.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo.bar[]\").unwrap()"
+expression: "Selector :: parse(\".foo.bar[]\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__foo_bar_range.snap b/insta/tests/snapshots/test_redaction__foo_bar_range.snap
index a25e6cf..84ba3e6 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar_range.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar_range.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo.bar[10:20]\").unwrap()"
+expression: "Selector :: parse(\".foo.bar[10:20]\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__foo_bar_range_from.snap b/insta/tests/snapshots/test_redaction__foo_bar_range_from.snap
index 6955568..5da40cf 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar_range_from.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar_range_from.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo.bar[10:]\").unwrap()"
+expression: "Selector :: parse(\".foo.bar[10:]\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__foo_bar_range_to.snap b/insta/tests/snapshots/test_redaction__foo_bar_range_to.snap
index c97f4a8..4a7405b 100644
--- a/insta/tests/snapshots/test_redaction__foo_bar_range_to.snap
+++ b/insta/tests/snapshots/test_redaction__foo_bar_range_to.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "Selector::parse(\".foo.bar[:10]\").unwrap()"
+expression: "Selector :: parse(\".foo.bar[:10]\").unwrap()"
 ---
 Selector {
     selectors: [
diff --git a/insta/tests/snapshots/test_redaction__named_redacted_debug_expr.snap b/insta/tests/snapshots/test_redaction__named_redacted_debug_expr.snap
new file mode 100644
index 0000000..0096613
--- /dev/null
+++ b/insta/tests/snapshots/test_redaction__named_redacted_debug_expr.snap
@@ -0,0 +1,12 @@
+---
+source: insta/tests/test_redaction.rs
+expression: This is a custom debug expression for the snapshot
+---
+id: "[id]"
+items:
+  - one
+  - two
+  - three
+metadata:
+  count: 42
+  version: 123
diff --git a/insta/tests/snapshots/test_redaction__named_redacted_supported.snap b/insta/tests/snapshots/test_redaction__named_redacted_supported.snap
new file mode 100644
index 0000000..fc0943a
--- /dev/null
+++ b/insta/tests/snapshots/test_redaction__named_redacted_supported.snap
@@ -0,0 +1,12 @@
+---
+source: insta/tests/test_redaction.rs
+expression: "&complex_obj"
+---
+id: "[id]"
+items:
+  - one
+  - two
+  - three
+metadata:
+  count: 42
+  version: 123
diff --git a/insta/tests/snapshots/test_redaction__rounded_redaction.snap b/insta/tests/snapshots/test_redaction__rounded_redaction.snap
index 24ae5e0..2ef2d55 100644
--- a/insta/tests/snapshots/test_redaction__rounded_redaction.snap
+++ b/insta/tests/snapshots/test_redaction__rounded_redaction.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&MyPoint { x: 1.0 / 3.0, y: 6.0 / 3.0 }"
+expression: "&MyPoint { x: 1.0 / 3.0, y: 6.0 / 3.0, }"
 ---
 {
   "x": 0.3333,
diff --git a/insta/tests/snapshots/test_redaction__user_json.snap b/insta/tests/snapshots/test_redaction__user_json.snap
index 5aefc8b..db9b172 100644
--- a/insta/tests/snapshots/test_redaction__user_json.snap
+++ b/insta/tests/snapshots/test_redaction__user_json.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 9999,\n        username: \"jason_doe\".to_string(),\n        email: Email(\"jason@example.com\".to_string()),\n        extra: \"ssn goes here\".to_string(),\n    }"
+expression: "&User\n{\n    id: 9999, username: \"jason_doe\".to_string(), email:\n    Email(\"jason@example.com\".to_string()), extra:\n    \"ssn goes here\".to_string(),\n}"
 ---
 {
   "id": "[id]",
diff --git a/insta/tests/snapshots/test_redaction__user_json_flags.snap b/insta/tests/snapshots/test_redaction__user_json_flags.snap
index d8bffbc..6c5c3fa 100644
--- a/insta/tests/snapshots/test_redaction__user_json_flags.snap
+++ b/insta/tests/snapshots/test_redaction__user_json_flags.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 122,\n        username: \"jason_doe\".to_string(),\n        flags: vec![\"zzz\".into(), \"foo\".into(), \"aha\".into(),\n                    \"is_admin\".into()].into_iter().collect(),\n    }"
+expression: "&User\n{\n    id: 122, username: \"jason_doe\".to_string(), flags:\n    vec![\"zzz\".into(), \"foo\".into(), \"aha\".into(),\n    \"is_admin\".into()].into_iter().collect(),\n}"
 ---
 {
   "id": "[id]",
diff --git a/insta/tests/snapshots/test_redaction__user_json_flags_alt.snap b/insta/tests/snapshots/test_redaction__user_json_flags_alt.snap
index 1b4cd2b..70f97aa 100644
--- a/insta/tests/snapshots/test_redaction__user_json_flags_alt.snap
+++ b/insta/tests/snapshots/test_redaction__user_json_flags_alt.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 122,\n        username: \"jason_doe\".to_string(),\n        flags: MySet(vec![\"zzz\".into(), \"foo\".into(), \"aha\".into(),\n                        \"is_admin\".into()].into_iter().collect()),\n    }"
+expression: "&User\n{\n    id: 122, username: \"jason_doe\".to_string(), flags:\n    MySet(vec![\"zzz\".into(), \"foo\".into(), \"aha\".into(),\n    \"is_admin\".into()].into_iter().collect()),\n}"
 ---
 {
   "flags": [
diff --git a/insta/tests/snapshots/test_redaction__user_json_settings.snap b/insta/tests/snapshots/test_redaction__user_json_settings.snap
index 1f52ea5..c8d1327 100644
--- a/insta/tests/snapshots/test_redaction__user_json_settings.snap
+++ b/insta/tests/snapshots/test_redaction__user_json_settings.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 122,\n        username: \"jason_doe\".to_string(),\n        email: Email(\"jason@example.com\".to_string()),\n        extra: \"ssn goes here\".to_string(),\n    }"
+expression: "&User\n{\n    id: 122, username: \"jason_doe\".to_string(), email:\n    Email(\"jason@example.com\".to_string()), extra:\n    \"ssn goes here\".to_string(),\n}"
 ---
 {
   "id": "[id]",
diff --git a/insta/tests/snapshots/test_redaction__user_json_settings_callback.snap b/insta/tests/snapshots/test_redaction__user_json_settings_callback.snap
index f8aa729..bf7f665 100644
--- a/insta/tests/snapshots/test_redaction__user_json_settings_callback.snap
+++ b/insta/tests/snapshots/test_redaction__user_json_settings_callback.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 1234,\n        username: \"jason_doe\".to_string(),\n        email: Email(\"jason@example.com\".to_string()),\n        extra: \"extra here\".to_string(),\n    }"
+expression: "&User\n{\n    id: 1234, username: \"jason_doe\".to_string(), email:\n    Email(\"jason@example.com\".to_string()), extra: \"extra here\".to_string(),\n}"
 ---
 {
   "id": "[id]",
diff --git a/insta/tests/snapshots/test_redaction__with_random_value.snap b/insta/tests/snapshots/test_redaction__with_random_value.snap
index 2989098..f97843d 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 42,\n        username: \"john_doe\".to_string(),\n        email: Email(\"john@example.com\".to_string()),\n        extra: \"\".to_string(),\n    }"
+expression: "&User\n{\n    id: 42, username: \"john_doe\".to_string(), email:\n    Email(\"john@example.com\".to_string()), extra: \"\".to_string(),\n}"
 ---
 id: "[id]"
 username: john_doe
diff --git a/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma-2.snap b/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma-2.snap
index 137543e..7fda776 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma-2.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma-2.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 11,\n        username: \"john_doe\".to_string(),\n        email: Email(\"john@example.com\".to_string()),\n        extra: \"\".to_string(),\n    }"
+expression: "&User\n{\n    id: 11, username: \"john_doe\".to_string(), email:\n    Email(\"john@example.com\".to_string()), extra: \"\".to_string(),\n}"
 ---
 id: "[id]"
 username: john_doe
diff --git a/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma.snap b/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma.snap
index 137543e..7fda776 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value_and_match_comma.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 11,\n        username: \"john_doe\".to_string(),\n        email: Email(\"john@example.com\".to_string()),\n        extra: \"\".to_string(),\n    }"
+expression: "&User\n{\n    id: 11, username: \"john_doe\".to_string(), email:\n    Email(\"john@example.com\".to_string()), extra: \"\".to_string(),\n}"
 ---
 id: "[id]"
 username: john_doe
diff --git a/insta/tests/snapshots/test_redaction__with_random_value_and_trailing_comma.snap b/insta/tests/snapshots/test_redaction__with_random_value_and_trailing_comma.snap
index 137543e..7fda776 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value_and_trailing_comma.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value_and_trailing_comma.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 11,\n        username: \"john_doe\".to_string(),\n        email: Email(\"john@example.com\".to_string()),\n        extra: \"\".to_string(),\n    }"
+expression: "&User\n{\n    id: 11, username: \"john_doe\".to_string(), email:\n    Email(\"john@example.com\".to_string()), extra: \"\".to_string(),\n}"
 ---
 id: "[id]"
 username: john_doe
diff --git a/insta/tests/snapshots/test_redaction__with_random_value_inline_callback.snap b/insta/tests/snapshots/test_redaction__with_random_value_inline_callback.snap
index 0aa80ea..582d0d7 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value_inline_callback.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value_inline_callback.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 23,\n        username: \"john_doe\".to_string(),\n        email: Email(\"john@example.com\".to_string()),\n        extra: \"\".to_string(),\n    }"
+expression: "&User\n{\n    id: 23, username: \"john_doe\".to_string(), email:\n    Email(\"john@example.com\".to_string()), extra: \"\".to_string(),\n}"
 ---
 id: "[id]"
 username: john_doe
diff --git a/insta/tests/snapshots/test_redaction__with_random_value_json_match.snap b/insta/tests/snapshots/test_redaction__with_random_value_json_match.snap
index 5aefc8b..db9b172 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value_json_match.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value_json_match.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 9999,\n        username: \"jason_doe\".to_string(),\n        email: Email(\"jason@example.com\".to_string()),\n        extra: \"ssn goes here\".to_string(),\n    }"
+expression: "&User\n{\n    id: 9999, username: \"jason_doe\".to_string(), email:\n    Email(\"jason@example.com\".to_string()), extra:\n    \"ssn goes here\".to_string(),\n}"
 ---
 {
   "id": "[id]",
diff --git a/insta/tests/snapshots/test_redaction__with_random_value_json_settings2.snap b/insta/tests/snapshots/test_redaction__with_random_value_json_settings2.snap
index 5b08ad7..cfef2a8 100644
--- a/insta/tests/snapshots/test_redaction__with_random_value_json_settings2.snap
+++ b/insta/tests/snapshots/test_redaction__with_random_value_json_settings2.snap
@@ -1,6 +1,6 @@
 ---
 source: insta/tests/test_redaction.rs
-expression: "&User {\n        id: 975,\n        username: \"jason_doe\".to_string(),\n        email: Email(\"jason@example.com\".to_string()),\n        extra: \"ssn goes here\".to_string(),\n    }"
+expression: "&User\n{\n    id: 975, username: \"jason_doe\".to_string(), email:\n    Email(\"jason@example.com\".to_string()), extra:\n    \"ssn goes here\".to_string(),\n}"
 ---
 {
   "id": "[id]",
diff --git a/insta/tests/test_basic.rs b/insta/tests/test_basic.rs
index 33b6761..da35a59 100644
--- a/insta/tests/test_basic.rs
+++ b/insta/tests/test_basic.rs
@@ -129,9 +129,9 @@ fn test_trailing_crlf() {
 
 #[test]
 fn test_trailing_crlf_inline() {
-    insta::assert_snapshot!("foo\r\nbar\r\nbaz\r\n", @r#"
+    insta::assert_snapshot!("foo\r\nbar\r\nbaz\r\n", @r"
     foo
     bar
     baz
-    "#);
+    ");
 }
diff --git a/insta/tests/test_inline.rs b/insta/tests/test_inline.rs
index fe93690..c8d1c18 100644
--- a/insta/tests/test_inline.rs
+++ b/insta/tests/test_inline.rs
@@ -14,14 +14,14 @@ use std::thread;
 
 #[test]
 fn test_simple() {
-    assert_debug_snapshot!(vec![1, 2, 3, 4], @r###"
+    assert_debug_snapshot!(vec![1, 2, 3, 4], @r"
     [
         1,
         2,
         3,
         4,
     ]
-    "###);
+    ");
 }
 
 #[test]
@@ -56,9 +56,7 @@ fn test_unnamed_thread_single_line() {
 #[test]
 fn test_newline() {
     // https://github.com/mitsuhiko/insta/issues/39
-    assert_snapshot!("\n", @r###"
-
-    "###);
+    assert_snapshot!("\n", @"");
 }
 
 #[test]
@@ -173,12 +171,12 @@ fn test_toml_inline() {
 #[cfg(feature = "json")]
 #[test]
 fn test_json_inline() {
-    assert_json_snapshot!(vec!["foo", "bar"], @r###"
+    assert_json_snapshot!(vec!["foo", "bar"], @r#"
     [
       "foo",
       "bar"
     ]
-    "###);
+    "#);
 }
 
 #[cfg(feature = "yaml")]
@@ -195,11 +193,11 @@ fn test_yaml_inline() {
         id: 42,
         username: "peter-pan".into(),
         email: "peterpan@wonderland.invalid".into()
-    }, @r###"
+    }, @r"
     id: 42
     username: peter-pan
     email: peterpan@wonderland.invalid
-    "###);
+    ");
 }
 
 #[cfg(all(feature = "redactions", feature = "yaml"))]
@@ -218,11 +216,11 @@ fn test_yaml_inline_redacted() {
         email: "peterpan@wonderland.invalid".into()
     }, {
         ".id" => "[user-id]"
-    }, @r###"
+    }, @r#"
     id: "[user-id]"
     username: peter-pan
     email: peterpan@wonderland.invalid
-    "###);
+    "#);
 }
 
 #[test]
@@ -232,20 +230,20 @@ fn test_non_basic_plane() {
 
 #[test]
 fn test_multiline_with_empty_lines() {
-    assert_snapshot!("# first\nsecond\n  third\n\n# alternative", @r###"
+    assert_snapshot!("# first\nsecond\n  third\n\n# alternative", @r"
     # first
     second
       third
 
     # alternative
-    "###);
+    ");
 }
 
 #[cfg(feature = "json")]
 #[test]
 fn test_compact_json() {
     assert_compact_json_snapshot!((1..30).collect::<Vec<_>>(), @"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]");
-    assert_compact_json_snapshot!((1..34).collect::<Vec<_>>(), @r###"
+    assert_compact_json_snapshot!((1..34).collect::<Vec<_>>(), @r"
     [
       1,
       2,
@@ -281,7 +279,7 @@ fn test_compact_json() {
       32,
       33
     ]
-    "###);
+    ");
 }
 
 #[test]
@@ -300,14 +298,11 @@ fn test_inline_test_in_loop() {
 
 #[test]
 fn test_inline_snapshot_whitespace() {
-    assert_snapshot!("\n\nfoo\n\n    bar\n\n", @r###"
-
-
+    assert_snapshot!("\n\nfoo\n\n    bar\n\n", @r"
     foo
 
         bar
-
-    "###);
+    ");
 }
 
 #[test]
diff --git a/insta/tests/test_redaction.rs b/insta/tests/test_redaction.rs
index ab46127..b184644 100644
--- a/insta/tests/test_redaction.rs
+++ b/insta/tests/test_redaction.rs
@@ -121,12 +121,12 @@ fn test_with_random_value_and_match_comma() {
         match .. {
             ".id" => "[id]",
         },
-        @r###"
+        @r#"
     id: "[id]"
     username: john_doe
     email: john@example.com
     extra: ""
-    "###, // comma here
+    "#, // comma here
     );
 }
 
@@ -322,14 +322,14 @@ fn test_redact_newtype_struct() {
 
     assert_json_snapshot!(wrapper, {
         r#".id"# => "[id]"
-    }, @r###"
+    }, @r#"
     {
       "id": "[id]",
       "username": "john_doe",
       "email": "john@example.com",
       "extra": ""
     }
-    "###);
+    "#);
 }
 
 #[cfg(feature = "yaml")]
@@ -347,11 +347,11 @@ fn test_redact_newtype_enum() {
     };
     assert_yaml_snapshot!(visitor, {
         r#".id"# => "[id]",
-    }, @r###"
+    }, @r#"
     Visitor:
       id: "[id]"
       name: my-name
-    "###);
+    "#);
 
     let admin = Role::Admin(User {
         id: 42,
@@ -361,13 +361,13 @@ fn test_redact_newtype_enum() {
     });
     assert_yaml_snapshot!(admin, {
         r#".id"# => "[id]",
-    }, @r###"
+    }, @r#"
     Admin:
       id: "[id]"
       username: john_doe
       email: john@example.com
       extra: ""
-    "###);
+    "#);
 }
 
 #[cfg(feature = "json")]
@@ -386,7 +386,7 @@ fn test_redact_recursive() {
 
     assert_json_snapshot!(root, {
         ".**.id" => "[id]",
-    }, @r###"
+    }, @r#"
     {
       "id": "[id]",
       "next": {
@@ -394,7 +394,7 @@ fn test_redact_recursive() {
         "next": null
       }
     }
-    "###);
+    "#);
 }
 
 #[cfg(feature = "yaml")]
@@ -543,3 +543,68 @@ fn test_rounded_redaction() {
         }
     );
 }
+
+#[cfg(feature = "yaml")]
+#[test]
+fn test_named_redacted_with_debug_expr() {
+    // This test demonstrates the form with a name, redactions, and debug expression
+    // | File, redacted, named, debug expr | `assert_yaml_snapshot!("name", expr, {"." => sorted_redaction()}, "debug_expr")` |
+
+    #[derive(Serialize, Debug)]
+    pub struct ComplexObject {
+        id: u32,
+        items: Vec<String>,
+        metadata: std::collections::HashMap<String, u32>,
+    }
+
+    let mut metadata = std::collections::HashMap::new();
+    metadata.insert("count".to_string(), 42);
+    metadata.insert("version".to_string(), 123);
+
+    let complex_obj = ComplexObject {
+        id: 12345,
+        items: vec!["one".to_string(), "two".to_string(), "three".to_string()],
+        metadata,
+    };
+
+    // Now that we've added support for this form, we can test it directly
+    assert_yaml_snapshot!(
+        "named_redacted_debug_expr",
+        &complex_obj,
+        {
+            ".id" => "[id]",
+            ".metadata" => insta::sorted_redaction()
+        },
+        "This is a custom debug expression for the snapshot"
+    );
+}
+
+#[cfg(feature = "yaml")]
+#[test]
+fn test_named_redacted_supported_form() {
+    #[derive(Serialize, Debug)]
+    pub struct ComplexObject {
+        id: u32,
+        items: Vec<String>,
+        metadata: std::collections::HashMap<String, u32>,
+    }
+
+    let mut metadata = std::collections::HashMap::new();
+    metadata.insert("count".to_string(), 42);
+    metadata.insert("version".to_string(), 123);
+
+    let obj = ComplexObject {
+        id: 12345,
+        items: vec!["one".to_string(), "two".to_string(), "three".to_string()],
+        metadata,
+    };
+
+    assert_yaml_snapshot!(
+        "named_redacted_supported",
+        &obj,
+        {
+            ".id" => "[id]",
+            ".metadata" => insta::sorted_redaction()
+        }
+    );
+}
diff --git a/insta/tests/test_settings.rs b/insta/tests/test_settings.rs
index da0c6ce..8a6513b 100644
--- a/insta/tests/test_settings.rs
+++ b/insta/tests/test_settings.rs
@@ -16,12 +16,12 @@ fn test_simple() {
     let mut settings = insta::Settings::new();
     settings.set_sort_maps(true);
     settings.bind(|| {
-        assert_yaml_snapshot!(&map, @r###"
+        assert_yaml_snapshot!(&map, @r"
         a: first value
         b: second value
         c: third value
         d: fourth value
-        "###);
+        ");
     });
 }
 
@@ -38,12 +38,12 @@ fn test_bound_to_scope() {
         let mut settings = Settings::new();
         settings.set_sort_maps(true);
         let _guard = settings.bind_to_scope();
-        assert_yaml_snapshot!(&map, @r###"
+        assert_yaml_snapshot!(&map, @r"
         a: first value
         b: second value
         c: third value
         d: fourth value
-        "###);
+        ");
     }
 
     assert!(!Settings::clone_current().sort_maps());
@@ -59,12 +59,12 @@ fn test_settings_macro() {
     map.insert("d", "fourth value");
 
     with_settings!({sort_maps => true}, {
-        insta::assert_yaml_snapshot!(&map, @r###"
+        insta::assert_yaml_snapshot!(&map, @r"
         a: first value
         b: second value
         c: third value
         d: fourth value
-        "###);
+        ");
     });
 }