diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-22 18:57:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-22 18:57:24 +0100 |
commit | 0e0d77d0a3361ee08cdb08a9060f5aa6160a5741 (patch) | |
tree | 1a6e219398b29faf6dc22f8d948075ac3b804373 /crates/hir_def/src/item_scope.rs | |
parent | 16d83ccbe2d4dd80c4a5de0793d95fb67e034408 (diff) | |
parent | 4772cb6b301917820eff62d36e2d6ec359420df3 (diff) |
Merge #9376
9376: minor: clarify naming r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_def/src/item_scope.rs')
-rw-r--r-- | crates/hir_def/src/item_scope.rs | 14 |
1 files changed, 9 insertions, 5 deletions
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 { | |||
30 | 30 | ||
31 | #[derive(Debug, Default, PartialEq, Eq)] | 31 | #[derive(Debug, Default, PartialEq, Eq)] |
32 | pub struct ItemScope { | 32 | pub struct ItemScope { |
33 | /// Defs visible in this scope. This includes `declarations`, but also | ||
34 | /// imports. | ||
33 | types: FxHashMap<Name, (ModuleDefId, Visibility)>, | 35 | types: FxHashMap<Name, (ModuleDefId, Visibility)>, |
34 | values: FxHashMap<Name, (ModuleDefId, Visibility)>, | 36 | values: FxHashMap<Name, (ModuleDefId, Visibility)>, |
35 | macros: FxHashMap<Name, (MacroDefId, Visibility)>, | 37 | macros: FxHashMap<Name, (MacroDefId, Visibility)>, |
36 | unresolved: FxHashSet<Name>, | 38 | unresolved: FxHashSet<Name>, |
37 | 39 | ||
38 | defs: Vec<ModuleDefId>, | 40 | /// The defs declared in this scope. Each def has a single scope where it is |
41 | /// declared. | ||
42 | declarations: Vec<ModuleDefId>, | ||
39 | impls: Vec<ImplId>, | 43 | impls: Vec<ImplId>, |
40 | unnamed_consts: Vec<ConstId>, | 44 | unnamed_consts: Vec<ConstId>, |
41 | /// Traits imported via `use Trait as _;`. | 45 | /// Traits imported via `use Trait as _;`. |
@@ -89,7 +93,7 @@ impl ItemScope { | |||
89 | } | 93 | } |
90 | 94 | ||
91 | pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { | 95 | pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { |
92 | self.defs.iter().copied() | 96 | self.declarations.iter().copied() |
93 | } | 97 | } |
94 | 98 | ||
95 | pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ { | 99 | pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ { |
@@ -150,8 +154,8 @@ impl ItemScope { | |||
150 | .chain(self.unnamed_trait_imports.keys().copied()) | 154 | .chain(self.unnamed_trait_imports.keys().copied()) |
151 | } | 155 | } |
152 | 156 | ||
153 | pub(crate) fn define_def(&mut self, def: ModuleDefId) { | 157 | pub(crate) fn declare(&mut self, def: ModuleDefId) { |
154 | self.defs.push(def) | 158 | self.declarations.push(def) |
155 | } | 159 | } |
156 | 160 | ||
157 | pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> { | 161 | pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> { |
@@ -311,7 +315,7 @@ impl ItemScope { | |||
311 | values, | 315 | values, |
312 | macros, | 316 | macros, |
313 | unresolved, | 317 | unresolved, |
314 | defs, | 318 | declarations: defs, |
315 | impls, | 319 | impls, |
316 | unnamed_consts, | 320 | unnamed_consts, |
317 | unnamed_trait_imports, | 321 | unnamed_trait_imports, |