diff options
author | Jonas Schievink <[email protected]> | 2021-04-07 02:12:40 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-04-07 02:12:40 +0100 |
commit | f04f38d3d79c3cc51956bc530a34e32945cdb294 (patch) | |
tree | 130dca17ca576146796b1877a81e17def36f2f02 /crates/hir_def/src/item_scope.rs | |
parent | 3e7ac2b830f692fd993a9b30b6be96a4206b8229 (diff) |
nameres: collect unnamed consts
Diffstat (limited to 'crates/hir_def/src/item_scope.rs')
-rw-r--r-- | crates/hir_def/src/item_scope.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs index a8ee5eeac..08feee1e7 100644 --- a/crates/hir_def/src/item_scope.rs +++ b/crates/hir_def/src/item_scope.rs | |||
@@ -11,7 +11,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
11 | use stdx::format_to; | 11 | use stdx::format_to; |
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, ImplId, | 14 | db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, ConstId, ImplId, |
15 | LocalModuleId, MacroDefId, ModuleDefId, ModuleId, TraitId, | 15 | LocalModuleId, MacroDefId, ModuleDefId, ModuleId, TraitId, |
16 | }; | 16 | }; |
17 | 17 | ||
@@ -37,6 +37,7 @@ pub struct ItemScope { | |||
37 | 37 | ||
38 | defs: Vec<ModuleDefId>, | 38 | defs: Vec<ModuleDefId>, |
39 | impls: Vec<ImplId>, | 39 | impls: Vec<ImplId>, |
40 | unnamed_consts: Vec<ConstId>, | ||
40 | /// Traits imported via `use Trait as _;`. | 41 | /// Traits imported via `use Trait as _;`. |
41 | unnamed_trait_imports: FxHashMap<TraitId, Visibility>, | 42 | unnamed_trait_imports: FxHashMap<TraitId, Visibility>, |
42 | /// Macros visible in current module in legacy textual scope | 43 | /// Macros visible in current module in legacy textual scope |
@@ -156,6 +157,10 @@ impl ItemScope { | |||
156 | self.impls.push(imp) | 157 | self.impls.push(imp) |
157 | } | 158 | } |
158 | 159 | ||
160 | pub(crate) fn define_unnamed_const(&mut self, konst: ConstId) { | ||
161 | self.unnamed_consts.push(konst); | ||
162 | } | ||
163 | |||
159 | pub(crate) fn define_legacy_macro(&mut self, name: Name, mac: MacroDefId) { | 164 | pub(crate) fn define_legacy_macro(&mut self, name: Name, mac: MacroDefId) { |
160 | self.legacy_macros.insert(name, mac); | 165 | self.legacy_macros.insert(name, mac); |
161 | } | 166 | } |
@@ -295,6 +300,7 @@ impl ItemScope { | |||
295 | unresolved, | 300 | unresolved, |
296 | defs, | 301 | defs, |
297 | impls, | 302 | impls, |
303 | unnamed_consts, | ||
298 | unnamed_trait_imports, | 304 | unnamed_trait_imports, |
299 | legacy_macros, | 305 | legacy_macros, |
300 | } = self; | 306 | } = self; |
@@ -304,6 +310,7 @@ impl ItemScope { | |||
304 | unresolved.shrink_to_fit(); | 310 | unresolved.shrink_to_fit(); |
305 | defs.shrink_to_fit(); | 311 | defs.shrink_to_fit(); |
306 | impls.shrink_to_fit(); | 312 | impls.shrink_to_fit(); |
313 | unnamed_consts.shrink_to_fit(); | ||
307 | unnamed_trait_imports.shrink_to_fit(); | 314 | unnamed_trait_imports.shrink_to_fit(); |
308 | legacy_macros.shrink_to_fit(); | 315 | legacy_macros.shrink_to_fit(); |
309 | } | 316 | } |