mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Fix macro expansion for statements w/o semicolon
This commit is contained in:
parent
c0a2b4e826
commit
8e07b23b84
10 changed files with 99 additions and 61 deletions
|
@ -54,7 +54,7 @@ fn is_expr_stmt_attr_allowed(kind: SyntaxKind) -> bool {
|
|||
!forbid
|
||||
}
|
||||
|
||||
pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
|
||||
pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) {
|
||||
let m = p.start();
|
||||
// test attr_on_expr_stmt
|
||||
// fn foo() {
|
||||
|
@ -90,7 +90,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
|
|||
p.error(format!("attributes are not allowed on {:?}", kind));
|
||||
}
|
||||
|
||||
if p.at(T!['}']) {
|
||||
if p.at(T!['}']) || (prefer_expr && p.at(EOF)) {
|
||||
// test attr_on_last_expr_in_block
|
||||
// fn foo() {
|
||||
// { #[A] bar!()? }
|
||||
|
@ -198,7 +198,7 @@ pub(super) fn expr_block_contents(p: &mut Parser) {
|
|||
continue;
|
||||
}
|
||||
|
||||
stmt(p, StmtWithSemi::Yes)
|
||||
stmt(p, StmtWithSemi::Yes, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue