Fix parsing of blocks without {

This commit is contained in:
Aleksey Kladov 2020-05-02 14:34:39 +02:00
parent fb8fb65131
commit 359d3be308
11 changed files with 107 additions and 62 deletions

View file

@ -2,7 +2,7 @@
mod atom;
pub(crate) use self::atom::match_arm_list;
pub(crate) use self::atom::{block_expr, match_arm_list};
pub(super) use self::atom::{literal, LITERAL_FIRST};
use super::*;
@ -49,19 +49,6 @@ fn expr_no_struct(p: &mut Parser) {
expr_bp(p, r, 1);
}
// test block
// fn a() {}
// fn b() { let _ = 1; }
// fn c() { 1; 2; }
// fn d() { 1; 2 }
pub(crate) fn block(p: &mut Parser) {
if !p.at(T!['{']) {
p.error("expected a block");
return;
}
atom::block_expr(p);
}
fn is_expr_stmt_attr_allowed(kind: SyntaxKind) -> bool {
match kind {
BIN_EXPR | RANGE_EXPR | IF_EXPR => false,