From a11ab1d9d138be555e018efe8e5da787c15711ee Mon Sep 17 00:00:00 2001 From: pchikku Date: Sat, 6 Jun 2026 16:09:28 -0700 Subject: [PATCH] Use BTreeMap for deterministic Into impl order The Into derive iterated TypeAttribute.types (a HashMap) to emit one impl block per target. HashMap iteration order is randomized per process, so the generated impls came out in a different order each compile, changing the consuming crate's metadata hash (SVH) build-to-build (rust-lang/rust#89904 class). HashType already implements Ord, so switching types to BTreeMap makes the order deterministic with no other change. --- src/trait_handlers/into/models/type_attribute.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/trait_handlers/into/models/type_attribute.rs b/src/trait_handlers/into/models/type_attribute.rs index 526e31e..39ff73b 100644 --- a/src/trait_handlers/into/models/type_attribute.rs +++ b/src/trait_handlers/into/models/type_attribute.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; use syn::{punctuated::Punctuated, Attribute, Meta, Token}; @@ -8,7 +8,7 @@ use crate::{ }; pub(crate) struct TypeAttribute { - pub(crate) types: HashMap, + pub(crate) types: BTreeMap, } #[derive(Debug)] @@ -20,7 +20,7 @@ impl TypeAttributeBuilder { pub(crate) fn build_from_into_meta(&self, meta: &[Meta]) -> syn::Result { debug_assert!(!meta.is_empty()); - let mut types = HashMap::new(); + let mut types = BTreeMap::new(); for meta in meta { debug_assert!(meta.path().is_ident("Into")); @@ -147,7 +147,7 @@ impl TypeAttributeBuilder { } Ok(output.unwrap_or(TypeAttribute { - types: HashMap::new() + types: BTreeMap::new() })) } }