Skip to content

Commit

Permalink
Auto merge of rust-lang#121851 - michaelwoerister:mcp-533-effective-v…
Browse files Browse the repository at this point in the history
…is, r=<try>

Use FxIndexMap instead FxHashMap to stabilize iteration order in EffectiveVisibilities

Part of [MCP 533](rust-lang/compiler-team#533).
  • Loading branch information
bors committed Mar 1, 2024
2 parents b0696a5 + a50490c commit 20a1b6d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions compiler/rustc_middle/src/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! outside their scopes. This pass will also generate a set of exported items
//! which are available for use externally when compiled as a library.
use crate::ty::{TyCtxt, Visibility};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::def::DefKind;
use rustc_macros::HashStable;
Expand Down Expand Up @@ -90,7 +90,7 @@ impl EffectiveVisibility {
/// Holds a map of effective visibilities for reachable HIR nodes.
#[derive(Clone, Debug)]
pub struct EffectiveVisibilities<Id = LocalDefId> {
map: FxHashMap<Id, EffectiveVisibility>,
map: FxIndexMap<Id, EffectiveVisibility>,
}

impl EffectiveVisibilities {
Expand Down Expand Up @@ -130,9 +130,8 @@ impl EffectiveVisibilities {
eff_vis: &EffectiveVisibility,
tcx: TyCtxt<'_>,
) {
use std::collections::hash_map::Entry;
match self.map.entry(def_id) {
Entry::Occupied(mut occupied) => {
IndexEntry::Occupied(mut occupied) => {
let old_eff_vis = occupied.get_mut();
for l in Level::all_levels() {
let vis_at_level = eff_vis.at_level(l);
Expand All @@ -145,7 +144,7 @@ impl EffectiveVisibilities {
}
old_eff_vis
}
Entry::Vacant(vacant) => vacant.insert(*eff_vis),
IndexEntry::Vacant(vacant) => vacant.insert(*eff_vis),
};
}

Expand Down

0 comments on commit 20a1b6d

Please sign in to comment.