Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/resolver.rs')
-rw-r--r--crates/hir_def/src/resolver.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs
index 72856a1bfe..b8c88282d6 100644
--- a/crates/hir_def/src/resolver.rs
+++ b/crates/hir_def/src/resolver.rs
@@ -1,5 +1,5 @@
//! Name resolution façade.
-use std::sync::Arc;
+use std::{hash::BuildHasherDefault, sync::Arc};
use base_db::CrateId;
use hir_expand::name::{name, Name};
@@ -343,7 +343,7 @@ impl Resolver {
/// Returns a set of names available in the current scope.
///
/// Note that this is a somewhat fuzzy concept -- internally, the compiler
- /// doesn't necessary follow a strict scoping discipline. Rathe, it just
+ /// doesn't necessary follow a strict scoping discipline. Rather, it just
/// tells for each ident what it resolves to.
///
/// A good example is something like `str::from_utf8`. From scopes point of
@@ -378,10 +378,13 @@ impl Resolver {
/// The result is ordered *roughly* from the innermost scope to the
/// outermost: when the name is introduced in two namespaces in two scopes,
/// we use the position of the first scope.
- pub fn names_in_scope(&self, db: &dyn DefDatabase) -> IndexMap<Name, SmallVec<[ScopeDef; 1]>> {
+ pub fn names_in_scope(
+ &self,
+ db: &dyn DefDatabase,
+ ) -> FxIndexMap<Name, SmallVec<[ScopeDef; 1]>> {
let mut res = ScopeNames::default();
for scope in self.scopes() {
- scope.process_names(db, &mut res);
+ scope.process_names(&mut res, db);
}
res.map
}
@@ -466,7 +469,7 @@ impl Resolver {
}
}
-#[derive(Debug, PartialEq, Eq)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ScopeDef {
ModuleDef(ModuleDefId),
Unknown,
@@ -478,7 +481,7 @@ pub enum ScopeDef {
}
impl Scope {
- fn process_names(&self, db: &dyn DefDatabase, acc: &mut ScopeNames) {
+ fn process_names(&self, acc: &mut ScopeNames, db: &dyn DefDatabase) {
match self {
Scope::ModuleScope(m) => {
// FIXME: should we provide `self` here?
@@ -691,9 +694,10 @@ fn to_type_ns(per_ns: PerNs) -> Option<TypeNs> {
Some(res)
}
+type FxIndexMap<K, V> = IndexMap<K, V, BuildHasherDefault<rustc_hash::FxHasher>>;
#[derive(Default)]
struct ScopeNames {
- map: IndexMap<Name, SmallVec<[ScopeDef; 1]>>,
+ map: FxIndexMap<Name, SmallVec<[ScopeDef; 1]>>,
}
impl ScopeNames {