mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 17:58:16 +00:00
Merge #9376
9376: minor: clarify naming r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
0e0d77d0a3
2 changed files with 11 additions and 7 deletions
|
@ -30,12 +30,16 @@ pub struct PerNsGlobImports {
|
|||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
pub struct ItemScope {
|
||||
/// Defs visible in this scope. This includes `declarations`, but also
|
||||
/// imports.
|
||||
types: FxHashMap<Name, (ModuleDefId, Visibility)>,
|
||||
values: FxHashMap<Name, (ModuleDefId, Visibility)>,
|
||||
macros: FxHashMap<Name, (MacroDefId, Visibility)>,
|
||||
unresolved: FxHashSet<Name>,
|
||||
|
||||
defs: Vec<ModuleDefId>,
|
||||
/// The defs declared in this scope. Each def has a single scope where it is
|
||||
/// declared.
|
||||
declarations: Vec<ModuleDefId>,
|
||||
impls: Vec<ImplId>,
|
||||
unnamed_consts: Vec<ConstId>,
|
||||
/// Traits imported via `use Trait as _;`.
|
||||
|
@ -89,7 +93,7 @@ impl ItemScope {
|
|||
}
|
||||
|
||||
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
|
||||
self.defs.iter().copied()
|
||||
self.declarations.iter().copied()
|
||||
}
|
||||
|
||||
pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ {
|
||||
|
@ -150,8 +154,8 @@ impl ItemScope {
|
|||
.chain(self.unnamed_trait_imports.keys().copied())
|
||||
}
|
||||
|
||||
pub(crate) fn define_def(&mut self, def: ModuleDefId) {
|
||||
self.defs.push(def)
|
||||
pub(crate) fn declare(&mut self, def: ModuleDefId) {
|
||||
self.declarations.push(def)
|
||||
}
|
||||
|
||||
pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> {
|
||||
|
@ -311,7 +315,7 @@ impl ItemScope {
|
|||
values,
|
||||
macros,
|
||||
unresolved,
|
||||
defs,
|
||||
declarations: defs,
|
||||
impls,
|
||||
unnamed_consts,
|
||||
unnamed_trait_imports,
|
||||
|
|
|
@ -1506,7 +1506,7 @@ impl ModCollector<'_, '_> {
|
|||
}
|
||||
|
||||
if let Some(DefData { id, name, visibility, has_constructor }) = def {
|
||||
self.def_collector.def_map.modules[self.module_id].scope.define_def(id);
|
||||
self.def_collector.def_map.modules[self.module_id].scope.declare(id);
|
||||
let vis = self
|
||||
.def_collector
|
||||
.def_map
|
||||
|
@ -1627,7 +1627,7 @@ impl ModCollector<'_, '_> {
|
|||
modules[self.module_id].children.insert(name.clone(), res);
|
||||
let module = self.def_collector.def_map.module_id(res);
|
||||
let def: ModuleDefId = module.into();
|
||||
self.def_collector.def_map.modules[self.module_id].scope.define_def(def);
|
||||
self.def_collector.def_map.modules[self.module_id].scope.declare(def);
|
||||
self.def_collector.update(
|
||||
self.module_id,
|
||||
&[(Some(name), PerNs::from_def(def, vis, false))],
|
||||
|
|
Loading…
Reference in a new issue