mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Handle inner recursive macro rules cases
This commit is contained in:
parent
f7fbea509f
commit
13f30e9ef5
3 changed files with 34 additions and 0 deletions
|
@ -115,6 +115,10 @@ impl ItemTree {
|
|||
// still need to collect inner items.
|
||||
ctx.lower_inner_items(stmt.syntax())
|
||||
},
|
||||
ast::Item(item) => {
|
||||
// Macros can expand to stmt and other item, and we add it as top level item
|
||||
ctx.lower_single_item(item)
|
||||
},
|
||||
_ => {
|
||||
panic!("cannot create item tree from {:?} {}", syntax, syntax);
|
||||
},
|
||||
|
|
|
@ -87,6 +87,14 @@ impl Ctx {
|
|||
self.tree
|
||||
}
|
||||
|
||||
pub(super) fn lower_single_item(mut self, item: ast::Item) -> ItemTree {
|
||||
self.tree.top_level = self
|
||||
.lower_mod_item(&item, false)
|
||||
.map(|item| item.0)
|
||||
.unwrap_or_else(|| Default::default());
|
||||
self.tree
|
||||
}
|
||||
|
||||
pub(super) fn lower_inner_items(mut self, within: &SyntaxNode) -> ItemTree {
|
||||
self.collect_inner_items(within);
|
||||
self.tree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue