Fix a flaky test in id::debug_format_tests (#8573)

`with_salt_matches_with` and `with_one_child` built the same `Id` by
different routes.
The debug source map keeps the first spelling it sees for an `Id` and
ignores later ones, so whichever test ran first decided what the other
one's `{:?}` printed — and the test order is not fixed.

Giving `with_salt_matches_with` sources of its own removes the shared
entry.

Surfaced by the red `Run tests` on #8571, which does not touch `id.rs`.
It reproduces on `main`: running just the two tests together, 10 of 15
runs failed before this change, and 12 runs of the whole module after it
failed none.

🤖 This PR was opened by a coding agent (Claude Opus 5).

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Emil ErnerfeldtandClaude Opus 5 authored and GitHub committed 2026-09-16 09:59:00 +00:00
1 parent 60d7caaea3
commit 7ba3dbc4b0
1 file changed
+8 -2
+8 -2
View File
@@ -254,10 +254,16 @@ mod debug_format_tests {
assert_eq!(format!("{id:?}"), r#"Id::unique(IdSalt::new("foo"))"#);
}
// The debug source map memoizes the first spelling it sees for an `Id`, so two tests that
// build the same `Id` by different routes race: whichever runs first decides what the other
// one's `{:?}` prints. Every test here therefore uses sources no other test uses.
#[test]
fn with_salt_matches_with() {
let parent = Id::unique("parent");
assert_eq!(parent.with_salt(IdSalt::new("child")), parent.with("child"));
let parent = Id::unique("salted_parent");
assert_eq!(
parent.with_salt(IdSalt::new("salted_child")),
parent.with("salted_child")
);
}
#[test]