From 6750c11df33868ffac07af4c8d4b050331663f5e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 7 Mar 2021 00:20:13 +0100 Subject: Rename a few `crate_def_map`s to `def_map` These could all be block `DefMap`s instead of crate-level `DefMap`s --- crates/hir_def/src/body.rs | 4 ++-- crates/hir_def/src/child_by_source.rs | 4 ++-- crates/hir_def/src/resolver.rs | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index ff4b4a0cf..16e1bac40 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -87,11 +87,11 @@ impl Expander { module: ModuleId, ) -> Expander { let cfg_expander = CfgExpander::new(db, current_file_id, module.krate); - let crate_def_map = module.def_map(db); + let def_map = module.def_map(db); let ast_id_map = db.ast_id_map(current_file_id); Expander { cfg_expander, - def_map: crate_def_map, + def_map, current_file_id, ast_id_map, module: module.local_id, diff --git a/crates/hir_def/src/child_by_source.rs b/crates/hir_def/src/child_by_source.rs index 65d85c86a..75c2d756b 100644 --- a/crates/hir_def/src/child_by_source.rs +++ b/crates/hir_def/src/child_by_source.rs @@ -74,8 +74,8 @@ impl ChildBySource for ImplId { impl ChildBySource for ModuleId { fn child_by_source(&self, db: &dyn DefDatabase) -> DynMap { - let crate_def_map = self.def_map(db); - let module_data = &crate_def_map[self.local_id]; + let def_map = self.def_map(db); + let module_data = &def_map[self.local_id]; module_data.scope.child_by_source(db) } } diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index e85f85e49..77ff21739 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs @@ -34,7 +34,7 @@ pub struct Resolver { // FIXME how to store these best #[derive(Debug, Clone)] struct ModuleItemMap { - crate_def_map: Arc, + def_map: Arc, module_id: LocalModuleId, } @@ -337,11 +337,11 @@ impl Resolver { let mut traits = FxHashSet::default(); for scope in &self.scopes { if let Scope::ModuleScope(m) = scope { - if let Some(prelude) = m.crate_def_map.prelude() { + if let Some(prelude) = m.def_map.prelude() { let prelude_def_map = prelude.def_map(db); traits.extend(prelude_def_map[prelude.local_id].scope.traits()); } - traits.extend(m.crate_def_map[m.module_id].scope.traits()); + traits.extend(m.def_map[m.module_id].scope.traits()); } } traits @@ -349,7 +349,7 @@ impl Resolver { fn module_scope(&self) -> Option<(&DefMap, LocalModuleId)> { self.scopes.iter().rev().find_map(|scope| match scope { - Scope::ModuleScope(m) => Some((&*m.crate_def_map, m.module_id)), + Scope::ModuleScope(m) => Some((&*m.def_map, m.module_id)), _ => None, }) @@ -413,21 +413,21 @@ impl Scope { // def: m.module.into(), // }), // ); - m.crate_def_map[m.module_id].scope.entries().for_each(|(name, def)| { + m.def_map[m.module_id].scope.entries().for_each(|(name, def)| { f(name.clone(), ScopeDef::PerNs(def)); }); - m.crate_def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { + m.def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { let scope = PerNs::macros(macro_, Visibility::Public); seen.insert((name.clone(), scope)); f(name.clone(), ScopeDef::PerNs(scope)); }); - m.crate_def_map.extern_prelude().for_each(|(name, &def)| { + m.def_map.extern_prelude().for_each(|(name, &def)| { f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); }); BUILTIN_SCOPE.iter().for_each(|(name, &def)| { f(name.clone(), ScopeDef::PerNs(def)); }); - if let Some(prelude) = m.crate_def_map.prelude() { + if let Some(prelude) = m.def_map.prelude() { let prelude_def_map = prelude.def_map(db); prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| { let seen_tuple = (name.clone(), def); @@ -513,8 +513,8 @@ impl Resolver { self.push_scope(Scope::ImplDefScope(impl_def)) } - fn push_module_scope(self, crate_def_map: Arc, module_id: LocalModuleId) -> Resolver { - self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) + fn push_module_scope(self, def_map: Arc, module_id: LocalModuleId) -> Resolver { + self.push_scope(Scope::ModuleScope(ModuleItemMap { def_map, module_id })) } fn push_expr_scope( @@ -534,7 +534,7 @@ impl ModuleItemMap { path: &ModPath, ) -> Option { let (module_def, idx) = - self.crate_def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); + self.def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); match idx { None => { let value = to_value_ns(module_def)?; @@ -564,7 +564,7 @@ impl ModuleItemMap { path: &ModPath, ) -> Option<(TypeNs, Option)> { let (module_def, idx) = - self.crate_def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); + self.def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); let res = to_type_ns(module_def)?; Some((res, idx)) } -- cgit v1.2.3