mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
fix block parse problem
This commit is contained in:
parent
0ca30b6c4b
commit
562359d706
1 changed files with 6 additions and 7 deletions
|
@ -360,10 +360,7 @@ fn lhs(
|
|||
}
|
||||
_ => {
|
||||
let (lhs, blocklike) = atom::atom_expr(p, r)?;
|
||||
return Some((
|
||||
postfix_expr(p, lhs, !(r.prefer_stmt && blocklike.is_block())),
|
||||
blocklike,
|
||||
));
|
||||
return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block())));
|
||||
}
|
||||
};
|
||||
expr_bp(p, r, 255, dollar_lvl);
|
||||
|
@ -376,8 +373,9 @@ fn postfix_expr(
|
|||
// Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple
|
||||
// E.g. `while true {break}();` is parsed as
|
||||
// `while true {break}; ();`
|
||||
mut block_like: BlockLike,
|
||||
mut allow_calls: bool,
|
||||
) -> CompletedMarker {
|
||||
) -> (CompletedMarker, BlockLike) {
|
||||
loop {
|
||||
lhs = match p.current() {
|
||||
// test stmt_postfix_expr_ambiguity
|
||||
|
@ -417,9 +415,10 @@ fn postfix_expr(
|
|||
T![as] => cast_expr(p, lhs),
|
||||
_ => break,
|
||||
};
|
||||
allow_calls = true
|
||||
allow_calls = true;
|
||||
block_like = BlockLike::NotBlock;
|
||||
}
|
||||
lhs
|
||||
(lhs, block_like)
|
||||
}
|
||||
|
||||
// test call_expr
|
||||
|
|
Loading…
Reference in a new issue