9376: minor: clarify naming r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-06-22 17:57:24 +00:00 committed by GitHub
commit 0e0d77d0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -30,12 +30,16 @@ pub struct PerNsGlobImports {
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, Default, PartialEq, Eq)]
pub struct ItemScope { pub struct ItemScope {
/// Defs visible in this scope. This includes `declarations`, but also
/// imports.
types: FxHashMap<Name, (ModuleDefId, Visibility)>, types: FxHashMap<Name, (ModuleDefId, Visibility)>,
values: FxHashMap<Name, (ModuleDefId, Visibility)>, values: FxHashMap<Name, (ModuleDefId, Visibility)>,
macros: FxHashMap<Name, (MacroDefId, Visibility)>, macros: FxHashMap<Name, (MacroDefId, Visibility)>,
unresolved: FxHashSet<Name>, 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>, impls: Vec<ImplId>,
unnamed_consts: Vec<ConstId>, unnamed_consts: Vec<ConstId>,
/// Traits imported via `use Trait as _;`. /// Traits imported via `use Trait as _;`.
@ -89,7 +93,7 @@ impl ItemScope {
} }
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { 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 + '_ { pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ {
@ -150,8 +154,8 @@ impl ItemScope {
.chain(self.unnamed_trait_imports.keys().copied()) .chain(self.unnamed_trait_imports.keys().copied())
} }
pub(crate) fn define_def(&mut self, def: ModuleDefId) { pub(crate) fn declare(&mut self, def: ModuleDefId) {
self.defs.push(def) self.declarations.push(def)
} }
pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> { pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> {
@ -311,7 +315,7 @@ impl ItemScope {
values, values,
macros, macros,
unresolved, unresolved,
defs, declarations: defs,
impls, impls,
unnamed_consts, unnamed_consts,
unnamed_trait_imports, unnamed_trait_imports,

View file

@ -1506,7 +1506,7 @@ impl ModCollector<'_, '_> {
} }
if let Some(DefData { id, name, visibility, has_constructor }) = def { 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 let vis = self
.def_collector .def_collector
.def_map .def_map
@ -1627,7 +1627,7 @@ impl ModCollector<'_, '_> {
modules[self.module_id].children.insert(name.clone(), res); modules[self.module_id].children.insert(name.clone(), res);
let module = self.def_collector.def_map.module_id(res); let module = self.def_collector.def_map.module_id(res);
let def: ModuleDefId = module.into(); 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.def_collector.update(
self.module_id, self.module_id,
&[(Some(name), PerNs::from_def(def, vis, false))], &[(Some(name), PerNs::from_def(def, vis, false))],