Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6eada04

Browse files
michaelwoeristerOneirical
authored andcommittedApr 3, 2024
Use FxIndexMap instead FxHashMap to stabilize iteration order in EffectiveVisibilities.
Part of rust-lang/compiler-team#533
1 parent a8cfc83 commit 6eada04

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎compiler/rustc_middle/src/middle/privacy.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! outside their scopes. This pass will also generate a set of exported items
33
//! which are available for use externally when compiled as a library.
44
use crate::ty::{TyCtxt, Visibility};
5-
use rustc_data_structures::fx::FxHashMap;
5+
use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
66
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
77
use rustc_hir::def::DefKind;
88
use rustc_macros::HashStable;
@@ -90,7 +90,7 @@ impl EffectiveVisibility {
9090
/// Holds a map of effective visibilities for reachable HIR nodes.
9191
#[derive(Clone, Debug)]
9292
pub struct EffectiveVisibilities<Id = LocalDefId> {
93-
map: FxHashMap<Id, EffectiveVisibility>,
93+
map: FxIndexMap<Id, EffectiveVisibility>,
9494
}
9595

9696
impl EffectiveVisibilities {
@@ -130,9 +130,8 @@ impl EffectiveVisibilities {
130130
eff_vis: &EffectiveVisibility,
131131
tcx: TyCtxt<'_>,
132132
) {
133-
use std::collections::hash_map::Entry;
134133
match self.map.entry(def_id) {
135-
Entry::Occupied(mut occupied) => {
134+
IndexEntry::Occupied(mut occupied) => {
136135
let old_eff_vis = occupied.get_mut();
137136
for l in Level::all_levels() {
138137
let vis_at_level = eff_vis.at_level(l);
@@ -145,7 +144,7 @@ impl EffectiveVisibilities {
145144
}
146145
old_eff_vis
147146
}
148-
Entry::Vacant(vacant) => vacant.insert(*eff_vis),
147+
IndexEntry::Vacant(vacant) => vacant.insert(*eff_vis),
149148
};
150149
}
151150

0 commit comments

Comments
 (0)
Please sign in to comment.