aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-22 18:57:24 +0100
committerGitHub <[email protected]>2021-06-22 18:57:24 +0100
commit0e0d77d0a3361ee08cdb08a9060f5aa6160a5741 (patch)
tree1a6e219398b29faf6dc22f8d948075ac3b804373
parent16d83ccbe2d4dd80c4a5de0793d95fb67e034408 (diff)
parent4772cb6b301917820eff62d36e2d6ec359420df3 (diff)
Merge #9376
9376: minor: clarify naming r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/hir_def/src/item_scope.rs14
-rw-r--r--crates/hir_def/src/nameres/collector.rs4
2 files changed, 11 insertions, 7 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)]
32pub struct ItemScope { 32pub 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,
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 927a7b6e8..634e02205 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -1506,7 +1506,7 @@ impl ModCollector<'_, '_> {
1506 } 1506 }
1507 1507
1508 if let Some(DefData { id, name, visibility, has_constructor }) = def { 1508 if let Some(DefData { id, name, visibility, has_constructor }) = def {
1509 self.def_collector.def_map.modules[self.module_id].scope.define_def(id); 1509 self.def_collector.def_map.modules[self.module_id].scope.declare(id);
1510 let vis = self 1510 let vis = self
1511 .def_collector 1511 .def_collector
1512 .def_map 1512 .def_map
@@ -1627,7 +1627,7 @@ impl ModCollector<'_, '_> {
1627 modules[self.module_id].children.insert(name.clone(), res); 1627 modules[self.module_id].children.insert(name.clone(), res);
1628 let module = self.def_collector.def_map.module_id(res); 1628 let module = self.def_collector.def_map.module_id(res);
1629 let def: ModuleDefId = module.into(); 1629 let def: ModuleDefId = module.into();
1630 self.def_collector.def_map.modules[self.module_id].scope.define_def(def); 1630 self.def_collector.def_map.modules[self.module_id].scope.declare(def);
1631 self.def_collector.update( 1631 self.def_collector.update(
1632 self.module_id, 1632 self.module_id,
1633 &[(Some(name), PerNs::from_def(def, vis, false))], 1633 &[(Some(name), PerNs::from_def(def, vis, false))],