Skip to content

Commit f9c8646

Browse files
committed
fix symbol index collection not collecting legacy macros
1 parent 4e94fb7 commit f9c8646

File tree

4 files changed

+127
-118
lines changed

4 files changed

+127
-118
lines changed

crates/hir/src/symbols.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ impl<'a> SymbolCollector<'a> {
174174
for const_id in scope.unnamed_consts() {
175175
self.collect_from_body(const_id);
176176
}
177+
178+
for (_, id) in scope.legacy_macros() {
179+
let loc = id.lookup(self.db.upcast());
180+
if loc.container == module_id {
181+
self.push_decl(id, FileSymbolKind::Macro);
182+
}
183+
}
177184
}
178185

179186
fn collect_from_body(&mut self, body_id: impl Into<DefWithBodyId>) {

crates/hir_def/src/item_scope.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ impl ItemScope {
128128
}
129129

130130
/// Iterate over all legacy textual scoped macros visible at the end of the module
131-
pub(crate) fn legacy_macros<'a>(
132-
&'a self,
133-
) -> impl Iterator<Item = (&'a Name, MacroRulesId)> + 'a {
131+
pub fn legacy_macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroRulesId)> + 'a {
134132
self.legacy_macros.iter().map(|(name, def)| (name, *def))
135133
}
136134

crates/ide_db/src/symbol_index.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,11 @@ struct StructInModB;
425425
let symbols: Vec<_> = Crate::from(db.test_crate())
426426
.modules(&db)
427427
.into_iter()
428-
.map(|module_id| (module_id, SymbolCollector::collect(&db, module_id)))
428+
.map(|module_id| {
429+
let mut symbols = SymbolCollector::collect(&db, module_id);
430+
symbols.sort_by_key(|it| it.name.clone());
431+
(module_id, symbols)
432+
})
429433
.collect();
430434

431435
expect_file!["./test_data/test_symbol_index_collection.txt"].assert_debug_eq(&symbols);

0 commit comments

Comments
 (0)