mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Simplify NO_BLOCK testing
This commit is contained in:
parent
5205c016e9
commit
27e814e182
2 changed files with 3 additions and 11 deletions
|
@ -5,7 +5,6 @@ pub(super) use self::atom::{literal, LITERAL_FIRST};
|
|||
use super::*;
|
||||
|
||||
const EXPR_FIRST: TokenSet = LHS_FIRST;
|
||||
const EXPR_FIRST_NO_BLOCK: TokenSet = LHS_FIRST_NO_BLOCK;
|
||||
|
||||
pub(super) fn expr(p: &mut Parser) -> BlockLike {
|
||||
let r = Restrictions {
|
||||
|
@ -210,10 +209,6 @@ const LHS_FIRST: TokenSet = token_set_union![
|
|||
token_set![AMP, STAR, EXCL, DOTDOT, MINUS],
|
||||
atom::ATOM_EXPR_FIRST,
|
||||
];
|
||||
const LHS_FIRST_NO_BLOCK: TokenSet = token_set_union![
|
||||
token_set![AMP, STAR, EXCL, DOTDOT, MINUS],
|
||||
atom::ATOM_EXPR_FIRST_NO_BLOCK,
|
||||
];
|
||||
|
||||
fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
|
||||
let m;
|
||||
|
|
|
@ -36,10 +36,11 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
|
|||
}
|
||||
|
||||
// E.g. for after the break in `if break {}`, this should not match
|
||||
pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![
|
||||
pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![
|
||||
LITERAL_FIRST,
|
||||
token_set![
|
||||
L_PAREN,
|
||||
L_CURLY,
|
||||
L_BRACK,
|
||||
PIPE,
|
||||
MOVE_KW,
|
||||
|
@ -59,9 +60,6 @@ pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![
|
|||
],
|
||||
];
|
||||
|
||||
pub(super) const ATOM_EXPR_FIRST: TokenSet =
|
||||
token_set_union![ATOM_EXPR_FIRST_NO_BLOCK, token_set![L_CURLY],];
|
||||
|
||||
const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
|
||||
|
||||
pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
|
||||
|
@ -442,8 +440,7 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
|
|||
// for i in break {}
|
||||
// match break {}
|
||||
// }
|
||||
if r.forbid_structs && p.at_ts(EXPR_FIRST_NO_BLOCK) || !r.forbid_structs && p.at_ts(EXPR_FIRST)
|
||||
{
|
||||
if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(L_CURLY)) {
|
||||
expr(p);
|
||||
}
|
||||
m.complete(p, BREAK_EXPR)
|
||||
|
|
Loading…
Reference in a new issue