mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-17 10:18:31 +00:00
Auto merge of #14286 - Veykril:block-def-tail-mac, r=Veykril
fix: Fix block defmap not looking into tail expressions for macro calls Fixes https://github.com/rust-lang/rust-analyzer/issues/14263
This commit is contained in:
commit
3d904e024b
2 changed files with 29 additions and 0 deletions
|
@ -395,3 +395,25 @@ fn foo() {
|
|||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trailing_expr_macro_expands_stmts() {
|
||||
check_at(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
() => { const FOO: u32 = 0;const BAR: u32 = 0; };
|
||||
}
|
||||
fn f() {$0
|
||||
foo!{}
|
||||
};
|
||||
"#,
|
||||
expect![[r#"
|
||||
block scope
|
||||
BAR: v
|
||||
FOO: v
|
||||
|
||||
crate
|
||||
f: v
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
|
|
@ -90,6 +90,13 @@ impl<'a> Ctx<'a> {
|
|||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
if let Some(ast::Expr::MacroExpr(expr)) = block.tail_expr() {
|
||||
if let Some(call) = expr.macro_call() {
|
||||
if let Some(mod_item) = self.lower_mod_item(&call.into()) {
|
||||
self.tree.top_level.push(mod_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.tree
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue