From 37306b0254836fc637267baf9363188b15ece331 Mon Sep 17 00:00:00 2001 From: Alexandre Kirszenberg Date: Tue, 6 Oct 2026 15:53:58 +0200 Subject: [PATCH] Fix non-determinism in the order of `with` remappings --- crates/guest-rust/macro/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/guest-rust/macro/src/lib.rs b/crates/guest-rust/macro/src/lib.rs index 68b9b6871..d43ba41a0 100644 --- a/crates/guest-rust/macro/src/lib.rs +++ b/crates/guest-rust/macro/src/lib.rs @@ -153,7 +153,14 @@ impl Parse for Config { Opt::AdditionalMemberAttributes(list) => { opts.additional_member_attributes = list } - Opt::With(with) => opts.with.extend(with), + Opt::With(with) => { + // `HashMap` iteration order is non-deterministic, which can cause + // non-determinism in crates that invoke the macro. Sort by key so the + // output is stable. + let mut with: Vec<_> = with.into_iter().collect(); + with.sort_by(|a, b| a.0.cmp(&b.0)); + opts.with.extend(with) + } Opt::GenerateAll => { opts.generate_all = true; }