From 496b146df526a6ec32ee4f75143a965e67a4484c Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Sun, 23 Mar 2025 19:55:50 -0400 Subject: [PATCH] Change one `FxHashMap` to `FxIndexMap` in librustdoc --- src/librustdoc/formats/cache.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 2648641e53e75..2b76d349e49f3 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -28,6 +28,12 @@ use crate::visit_lib::RustdocEffectiveVisibilities; /// to be a fairly large and expensive structure to clone. Instead this adheres /// to `Send` so it may be stored in an `Arc` instance and shared among the various /// rendering threads. +/// +/// To promote reproducibility across operating systems, this structure +/// intentionally does not use [`rustc_data_structures::fx::FxHashMap`]. +/// Elements can be stored in different orders in an `FxHashMap`, even if the +/// elements are inserted in the same order. Wherever an `FxHashMap` would be +/// needed, an [`rustc_data_structures::fx::FxIndexMap`] is used instead. #[derive(Default)] pub(crate) struct Cache { /// Maps a type ID to all known implementations for that type. This is only @@ -47,7 +53,7 @@ pub(crate) struct Cache { /// Similar to `paths`, but only holds external paths. This is only used for /// generating explicit hyperlinks to other crates. - pub(crate) external_paths: FxHashMap, ItemType)>, + pub(crate) external_paths: FxIndexMap, ItemType)>, /// Maps local `DefId`s of exported types to fully qualified paths. /// Unlike 'paths', this mapping ignores any renames that occur