From 4772cb6b301917820eff62d36e2d6ec359420df3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 22 Jun 2021 20:56:52 +0300 Subject: minor: clarify naming --- crates/hir_def/src/item_scope.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'crates/hir_def/src/item_scope.rs') diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs index 567ae5660..1b7cb7c8b 100644 --- a/crates/hir_def/src/item_scope.rs +++ b/crates/hir_def/src/item_scope.rs @@ -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, values: FxHashMap, macros: FxHashMap, unresolved: FxHashSet, - defs: Vec, + /// The defs declared in this scope. Each def has a single scope where it is + /// declared. + declarations: Vec, impls: Vec, unnamed_consts: Vec, /// Traits imported via `use Trait as _;`. @@ -89,7 +93,7 @@ impl ItemScope { } pub fn declarations(&self) -> impl Iterator + '_ { - self.defs.iter().copied() + self.declarations.iter().copied() } pub fn impls(&self) -> impl Iterator + 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 { @@ -311,7 +315,7 @@ impl ItemScope { values, macros, unresolved, - defs, + declarations: defs, impls, unnamed_consts, unnamed_trait_imports, -- cgit v1.2.3