From 9d87dcb410a2de4f6a7c646468c15430e5dfc8d2 Mon Sep 17 00:00:00 2001 From: Cormac Relf Date: Sat, 7 Dec 2024 02:52:57 +1100 Subject: [PATCH] Make the macros deterministic, using BTreeMap instead of HashMap (#662) This fixes compile errors in non-cargo build systems, which rely on the rustc crate hash being the same between two compiles. HashMap order is nondeterministic due to SipHasher initialization, so macro-generated code would change between compiles. --- macros/src/actionlike.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macros/src/actionlike.rs b/macros/src/actionlike.rs index 8d903e73..e0460be2 100644 --- a/macros/src/actionlike.rs +++ b/macros/src/actionlike.rs @@ -1,7 +1,7 @@ use crate::utils; use proc_macro2::{Span, TokenStream}; use quote::quote; -use std::collections::HashMap; +use std::collections::BTreeMap; use syn::{Attribute, Data, DataEnum, DeriveInput, Error, Ident}; /// This approach and implementation is inspired by the `strum` crate, @@ -81,8 +81,8 @@ fn generate_input_control_kind_body( fn parse_variant_controls( data: &DataEnum, default_control: &Ident, -) -> syn::Result> { - let mut map = HashMap::::new(); +) -> syn::Result> { + let mut map = BTreeMap::::new(); for variant in data.variants.iter() { for attr in variant .attrs