Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/item_scope.rs')
-rw-r--r--crates/hir_def/src/item_scope.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs
index 0a2a6719ed..37599371f6 100644
--- a/crates/hir_def/src/item_scope.rs
+++ b/crates/hir_def/src/item_scope.rs
@@ -44,6 +44,8 @@ pub struct ItemScope {
/// The defs declared in this scope. Each def has a single scope where it is
/// declared.
declarations: Vec<ModuleDefId>,
+ macro_declarations: Vec<MacroDefId>,
+
impls: Vec<ImplId>,
unnamed_consts: Vec<ConstId>,
/// Traits imported via `use Trait as _;`.
@@ -101,6 +103,10 @@ impl ItemScope {
self.declarations.iter().copied()
}
+ pub fn macro_declarations(&self) -> impl Iterator<Item = MacroDefId> + '_ {
+ self.macro_declarations.iter().copied()
+ }
+
pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ {
self.impls.iter().copied()
}
@@ -163,6 +169,10 @@ impl ItemScope {
self.declarations.push(def)
}
+ pub(crate) fn declare_macro(&mut self, def: MacroDefId) {
+ self.macro_declarations.push(def);
+ }
+
pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> {
self.legacy_macros.get(name).copied()
}
@@ -336,7 +346,8 @@ impl ItemScope {
values,
macros,
unresolved,
- declarations: defs,
+ declarations,
+ macro_declarations,
impls,
unnamed_consts,
unnamed_trait_imports,
@@ -348,7 +359,8 @@ impl ItemScope {
values.shrink_to_fit();
macros.shrink_to_fit();
unresolved.shrink_to_fit();
- defs.shrink_to_fit();
+ declarations.shrink_to_fit();
+ macro_declarations.shrink_to_fit();
impls.shrink_to_fit();
unnamed_consts.shrink_to_fit();
unnamed_trait_imports.shrink_to_fit();