ITADN

Messed up inline snapshots b/c of filtering and/or `with_settings!` (?)

#857Openilyagr 创建于 2026-01-08
bug
I
ilyagrcommented
### What happened? 1. Start with this test: ```rust use insta::assert_snapshot; #[test] fn test_dummy() { insta::with_settings!({filters => vec![ (r":[[:xdigit:]]{3,}", ":PORT"), ]}, { assert_snapshot!(":12345\n\nabc", @" "); assert_snapshot!(":12345\n\nabc", @" "); assert_snapshot!("", @""); assert_snapshot!("", @""); }); } ``` 2. Run `cargo insta test --accept -- test_dummy` I get this incorrect result: ```rust use insta::assert_snapshot; #[test] fn test_dummy() { insta::with_settings!({filters => vec![ (r":[[:xdigit:]]{3,}", ":PORT"), ]}, { assert_snapshot!(":12345\n\nabc", @" "); assert_snapshot!(":12345\n\nabc", @" "); assert_snapshot!("", @""); assert_snapshot!("", @" :PORT abc "); }); } ``` ### Reproduction steps See above ### rustc Version ``` rustc 1.90.0 (1159e78c4 2025-09-14) binary: rustc commit-hash: 1159e78c4747b02ef996e55082b704c09b970588 commit-date: 2025-09-14 host: aarch64-apple-darwin release: 1.90.0 LLVM version: 20.1.8 ``` ### insta Version `insta = { version = "1.46.0", features = ["filters", "redactions", "ron"] }`, also present in 1.43.1 ### cargo insta --version output cargo-insta 1.46.0 ### What did you expect? ```rust #[test] fn test_push_dummy() { insta::with_settings!({filters => vec![ (r":[[:xdigit:]]{3,}", ":PORT"), ]}, { assert_snapshot!(":12345\n\nabc", @" :PORT abc "); assert_snapshot!(":12345\n\nabc", @" :PORT abc "); assert_snapshot!("", @""); assert_snapshot!("", @""); }); } ```
2 条评论