mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 01:38:13 +00:00
Merge #7899
7899: Rename a few `crate_def_map`s to `def_map` r=jonas-schievink a=jonas-schievink These could all be block `DefMap`s instead of crate-level `DefMap`s bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
07a54f7ae4
4 changed files with 19 additions and 19 deletions
|
@ -365,14 +365,14 @@ impl Module {
|
||||||
let _p = profile::span("Module::diagnostics").detail(|| {
|
let _p = profile::span("Module::diagnostics").detail(|| {
|
||||||
format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string()))
|
format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string()))
|
||||||
});
|
});
|
||||||
let crate_def_map = self.id.def_map(db.upcast());
|
let def_map = self.id.def_map(db.upcast());
|
||||||
crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
|
def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
|
||||||
for decl in self.declarations(db) {
|
for decl in self.declarations(db) {
|
||||||
match decl {
|
match decl {
|
||||||
crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
|
crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
|
||||||
crate::ModuleDef::Module(m) => {
|
crate::ModuleDef::Module(m) => {
|
||||||
// Only add diagnostics from inline modules
|
// Only add diagnostics from inline modules
|
||||||
if crate_def_map[m.id.local_id].origin.is_inline() {
|
if def_map[m.id.local_id].origin.is_inline() {
|
||||||
m.diagnostics(db, sink)
|
m.diagnostics(db, sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,11 +87,11 @@ impl Expander {
|
||||||
module: ModuleId,
|
module: ModuleId,
|
||||||
) -> Expander {
|
) -> Expander {
|
||||||
let cfg_expander = CfgExpander::new(db, current_file_id, module.krate);
|
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);
|
let ast_id_map = db.ast_id_map(current_file_id);
|
||||||
Expander {
|
Expander {
|
||||||
cfg_expander,
|
cfg_expander,
|
||||||
def_map: crate_def_map,
|
def_map,
|
||||||
current_file_id,
|
current_file_id,
|
||||||
ast_id_map,
|
ast_id_map,
|
||||||
module: module.local_id,
|
module: module.local_id,
|
||||||
|
|
|
@ -74,8 +74,8 @@ impl ChildBySource for ImplId {
|
||||||
|
|
||||||
impl ChildBySource for ModuleId {
|
impl ChildBySource for ModuleId {
|
||||||
fn child_by_source(&self, db: &dyn DefDatabase) -> DynMap {
|
fn child_by_source(&self, db: &dyn DefDatabase) -> DynMap {
|
||||||
let crate_def_map = self.def_map(db);
|
let def_map = self.def_map(db);
|
||||||
let module_data = &crate_def_map[self.local_id];
|
let module_data = &def_map[self.local_id];
|
||||||
module_data.scope.child_by_source(db)
|
module_data.scope.child_by_source(db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub struct Resolver {
|
||||||
// FIXME how to store these best
|
// FIXME how to store these best
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct ModuleItemMap {
|
struct ModuleItemMap {
|
||||||
crate_def_map: Arc<DefMap>,
|
def_map: Arc<DefMap>,
|
||||||
module_id: LocalModuleId,
|
module_id: LocalModuleId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,11 +337,11 @@ impl Resolver {
|
||||||
let mut traits = FxHashSet::default();
|
let mut traits = FxHashSet::default();
|
||||||
for scope in &self.scopes {
|
for scope in &self.scopes {
|
||||||
if let Scope::ModuleScope(m) = scope {
|
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);
|
let prelude_def_map = prelude.def_map(db);
|
||||||
traits.extend(prelude_def_map[prelude.local_id].scope.traits());
|
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
|
traits
|
||||||
|
@ -349,7 +349,7 @@ impl Resolver {
|
||||||
|
|
||||||
fn module_scope(&self) -> Option<(&DefMap, LocalModuleId)> {
|
fn module_scope(&self) -> Option<(&DefMap, LocalModuleId)> {
|
||||||
self.scopes.iter().rev().find_map(|scope| match scope {
|
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,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
@ -413,21 +413,21 @@ impl Scope {
|
||||||
// def: m.module.into(),
|
// 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));
|
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);
|
let scope = PerNs::macros(macro_, Visibility::Public);
|
||||||
seen.insert((name.clone(), scope));
|
seen.insert((name.clone(), scope));
|
||||||
f(name.clone(), ScopeDef::PerNs(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)));
|
f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public)));
|
||||||
});
|
});
|
||||||
BUILTIN_SCOPE.iter().for_each(|(name, &def)| {
|
BUILTIN_SCOPE.iter().for_each(|(name, &def)| {
|
||||||
f(name.clone(), ScopeDef::PerNs(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);
|
let prelude_def_map = prelude.def_map(db);
|
||||||
prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| {
|
prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| {
|
||||||
let seen_tuple = (name.clone(), def);
|
let seen_tuple = (name.clone(), def);
|
||||||
|
@ -513,8 +513,8 @@ impl Resolver {
|
||||||
self.push_scope(Scope::ImplDefScope(impl_def))
|
self.push_scope(Scope::ImplDefScope(impl_def))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_module_scope(self, crate_def_map: Arc<DefMap>, module_id: LocalModuleId) -> Resolver {
|
fn push_module_scope(self, def_map: Arc<DefMap>, module_id: LocalModuleId) -> Resolver {
|
||||||
self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id }))
|
self.push_scope(Scope::ModuleScope(ModuleItemMap { def_map, module_id }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_expr_scope(
|
fn push_expr_scope(
|
||||||
|
@ -534,7 +534,7 @@ impl ModuleItemMap {
|
||||||
path: &ModPath,
|
path: &ModPath,
|
||||||
) -> Option<ResolveValueResult> {
|
) -> Option<ResolveValueResult> {
|
||||||
let (module_def, idx) =
|
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 {
|
match idx {
|
||||||
None => {
|
None => {
|
||||||
let value = to_value_ns(module_def)?;
|
let value = to_value_ns(module_def)?;
|
||||||
|
@ -564,7 +564,7 @@ impl ModuleItemMap {
|
||||||
path: &ModPath,
|
path: &ModPath,
|
||||||
) -> Option<(TypeNs, Option<usize>)> {
|
) -> Option<(TypeNs, Option<usize>)> {
|
||||||
let (module_def, idx) =
|
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)?;
|
let res = to_type_ns(module_def)?;
|
||||||
Some((res, idx))
|
Some((res, idx))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue