Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir_def/src/item_scope.rs2
-rw-r--r--crates/hir_def/src/nameres/collector.rs1
-rw-r--r--crates/ide_db/src/symbol_index.rs11
3 files changed, 3 insertions, 11 deletions
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs
index 8b5984bf12..37599371f6 100644
--- a/crates/hir_def/src/item_scope.rs
+++ b/crates/hir_def/src/item_scope.rs
@@ -127,7 +127,7 @@ impl ItemScope {
}
/// Iterate over all legacy textual scoped macros visible at the end of the module
- pub fn legacy_macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a {
+ pub(crate) fn legacy_macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a {
self.legacy_macros.iter().map(|(name, def)| (name, *def))
}
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 49d2a7866a..d7a35caf29 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -594,6 +594,7 @@ impl DefCollector<'_> {
) {
// Textual scoping
self.define_legacy_macro(module_id, name.clone(), macro_);
+ self.def_map.modules[module_id].scope.declare_macro(macro_);
// Module scoping
// In Rust, `#[macro_export]` macros are unconditionally visible at the
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs
index 53fa3f0881..b8efa279e1 100644
--- a/crates/ide_db/src/symbol_index.rs
+++ b/crates/ide_db/src/symbol_index.rs
@@ -490,8 +490,6 @@ impl<'a> SymbolCollector<'a> {
let module_data = &def_map[module_id.local_id];
let scope = &module_data.scope;
- dbg!(scope);
-
for module_def_id in scope.declarations() {
match module_def_id {
ModuleDefId::ModuleId(id) => self.push_module(id),
@@ -533,13 +531,6 @@ impl<'a> SymbolCollector<'a> {
self.work.push(SymbolCollectorWorkItem::Body { body: const_id.into() })
}
- // Collect legacy macros from the root module only:
- if module_data.parent.is_none() {
- for (_, macro_def_id) in scope.legacy_macros() {
- self.push_decl_macro(macro_def_id.into());
- }
- }
-
for macro_def_id in scope.macro_declarations() {
self.push_decl_macro(macro_def_id.into());
}
@@ -699,7 +690,7 @@ impl<'a> SymbolCollector<'a> {
})
}
- pub(crate) fn push_decl_macro(&mut self, macro_def: MacroDef) {
+ fn push_decl_macro(&mut self, macro_def: MacroDef) {
self.push_file_symbol(|s| {
let name = macro_def.name(s.db.upcast())?.as_text()?;
let source = macro_def.source(s.db.upcast())?;