Replace some instances of FxHashMap/FxHashSet with stable alternatives (mostly in rustc_hir and rustc_ast_lowering)
Part of https://github.com/rust-lang/compiler-team/issues/533
This commit is contained in:
parent
2a7634047a
commit
115885ba7e
12 changed files with 36 additions and 41 deletions
|
@ -3,8 +3,8 @@ use crate::hir;
|
|||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::NodeId;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::ToStableHashKey;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::def_id::{DefId, LocalDefId};
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
|
@ -806,4 +806,4 @@ pub enum LifetimeRes {
|
|||
ElidedAnchor { start: NodeId, end: NodeId },
|
||||
}
|
||||
|
||||
pub type DocLinkResMap = FxHashMap<(Symbol, Namespace), Option<Res<NodeId>>>;
|
||||
pub type DocLinkResMap = UnordMap<(Symbol, Namespace), Option<Res<NodeId>>>;
|
||||
|
|
|
@ -8,8 +8,8 @@ pub use crate::def_id::DefPathHash;
|
|||
use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use crate::def_path_hash_map::DefPathHashMap;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{Hash64, StableHasher};
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl DefPathTable {
|
|||
#[derive(Debug)]
|
||||
pub struct Definitions {
|
||||
table: DefPathTable,
|
||||
next_disambiguator: FxHashMap<(LocalDefId, DefPathData), u32>,
|
||||
next_disambiguator: UnordMap<(LocalDefId, DefPathData), u32>,
|
||||
|
||||
/// The [StableCrateId] of the local crate.
|
||||
stable_crate_id: StableCrateId,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use crate::def_id::DefId;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_span::def_id::DefIdMap;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DiagnosticItems {
|
||||
pub id_to_name: FxHashMap<DefId, Symbol>,
|
||||
pub name_to_id: FxHashMap<Symbol, DefId>,
|
||||
pub id_to_name: DefIdMap<Symbol>,
|
||||
pub name_to_id: FxIndexMap<Symbol, DefId>,
|
||||
}
|
||||
|
||||
impl<CTX: crate::HashStableContext> HashStable<CTX> for DiagnosticItems {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::def::{CtorKind, DefKind, Res};
|
||||
use crate::def_id::DefId;
|
||||
pub(crate) use crate::hir_id::{HirId, ItemLocalId, OwnerId};
|
||||
use crate::def_id::{DefId, LocalDefIdMap};
|
||||
pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
|
||||
use crate::intravisit::FnKind;
|
||||
use crate::LangItem;
|
||||
|
||||
|
@ -11,7 +11,6 @@ pub use rustc_ast::{BinOp, BinOpKind, BindingAnnotation, BorrowKind, ByRef, Capt
|
|||
pub use rustc_ast::{ImplPolarity, IsAuto, Movability, Mutability, UnOp};
|
||||
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
@ -874,12 +873,12 @@ pub struct OwnerInfo<'hir> {
|
|||
/// Contents of the HIR.
|
||||
pub nodes: OwnerNodes<'hir>,
|
||||
/// Map from each nested owner to its parent's local id.
|
||||
pub parenting: FxHashMap<LocalDefId, ItemLocalId>,
|
||||
pub parenting: LocalDefIdMap<ItemLocalId>,
|
||||
/// Collected attributes of the HIR nodes.
|
||||
pub attrs: AttributeMap<'hir>,
|
||||
/// Map indicating what traits are in scope for places where this
|
||||
/// is relevant; generated by resolve.
|
||||
pub trait_map: FxHashMap<ItemLocalId, Box<[TraitCandidate]>>,
|
||||
pub trait_map: ItemLocalMap<Box<[TraitCandidate]>>,
|
||||
}
|
||||
|
||||
impl<'tcx> OwnerInfo<'tcx> {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::def::{CtorOf, DefKind, Res};
|
||||
use crate::def_id::DefId;
|
||||
use crate::def_id::{DefId, DefIdSet};
|
||||
use crate::hir::{self, BindingAnnotation, ByRef, HirId, PatKind};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -114,9 +113,9 @@ impl hir::Pat<'_> {
|
|||
}
|
||||
_ => true,
|
||||
});
|
||||
// We remove duplicates by inserting into a `FxHashSet` to avoid re-ordering
|
||||
// We remove duplicates by inserting into a hash set to avoid re-ordering
|
||||
// the bounds
|
||||
let mut duplicates = FxHashSet::default();
|
||||
let mut duplicates = DefIdSet::default();
|
||||
variants.retain(|def_id| duplicates.insert(*def_id));
|
||||
variants
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue