From 196bc02e651919e8bf890b3d3d1bb43c4a599df7 Mon Sep 17 00:00:00 2001 From: Cormac Relf Date: Thu, 5 Dec 2024 11:24:09 +1100 Subject: [PATCH] Make the macros deterministic, using BTreeMap instead of HashMap 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 ce230db9..64905dee 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