Stop using let_stmt twice
This commit is contained in:
parent
7055d43c3a
commit
4d35cc3875
1 changed files with 41 additions and 43 deletions
|
@ -45,10 +45,6 @@ pub(crate) fn block(p: &mut Parser) {
|
||||||
|
|
||||||
while !p.at(EOF) && !p.at(R_CURLY) {
|
while !p.at(EOF) && !p.at(R_CURLY) {
|
||||||
match p.current() {
|
match p.current() {
|
||||||
LET_KW => {
|
|
||||||
let m = p.start();
|
|
||||||
let_stmt(p, m)
|
|
||||||
}
|
|
||||||
// test nocontentexpr
|
// test nocontentexpr
|
||||||
// fn foo(){
|
// fn foo(){
|
||||||
// ;;;some_expr();;;;{;;;};;;;Ok(())
|
// ;;;some_expr();;;;{;;;};;;;Ok(())
|
||||||
|
@ -60,49 +56,51 @@ pub(crate) fn block(p: &mut Parser) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
let has_attrs = p.at(POUND);
|
let has_attrs = p.at(POUND);
|
||||||
attributes::outer_attributes(p);
|
attributes::outer_attributes(p);
|
||||||
match items::maybe_item(p, items::ItemFlavor::Mod) {
|
if p.at(LET_KW) {
|
||||||
items::MaybeItem::Item(kind) => {
|
let_stmt(p, m);
|
||||||
m.complete(p, kind);
|
} else {
|
||||||
}
|
match items::maybe_item(p, items::ItemFlavor::Mod) {
|
||||||
items::MaybeItem::Modifiers => {
|
items::MaybeItem::Item(kind) => {
|
||||||
m.abandon(p);
|
m.complete(p, kind);
|
||||||
p.error("expected an item");
|
}
|
||||||
}
|
items::MaybeItem::Modifiers => {
|
||||||
// test pub_expr
|
m.abandon(p);
|
||||||
// fn foo() { pub 92; } //FIXME
|
p.error("expected an item");
|
||||||
items::MaybeItem::None => {
|
}
|
||||||
if has_attrs {
|
// test pub_expr
|
||||||
if p.at(LET_KW) {
|
// fn foo() { pub 92; } //FIXME
|
||||||
let_stmt(p, m);
|
items::MaybeItem::None => {
|
||||||
} else {
|
if has_attrs {
|
||||||
m.abandon(p);
|
|
||||||
p.error("expected a let statement");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
|
|
||||||
if p.at(R_CURLY) {
|
|
||||||
m.abandon(p);
|
m.abandon(p);
|
||||||
|
p.error(
|
||||||
|
"expected a let statement or an item after attributes in block",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// test no_semi_after_block
|
let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
|
||||||
// fn foo() {
|
if p.at(R_CURLY) {
|
||||||
// if true {}
|
m.abandon(p);
|
||||||
// loop {}
|
|
||||||
// match () {}
|
|
||||||
// while true {}
|
|
||||||
// for _ in () {}
|
|
||||||
// {}
|
|
||||||
// {}
|
|
||||||
// macro_rules! test {
|
|
||||||
// () => {}
|
|
||||||
// }
|
|
||||||
// test!{}
|
|
||||||
// }
|
|
||||||
if is_blocklike {
|
|
||||||
p.eat(SEMI);
|
|
||||||
} else {
|
} else {
|
||||||
p.expect(SEMI);
|
// test no_semi_after_block
|
||||||
|
// fn foo() {
|
||||||
|
// if true {}
|
||||||
|
// loop {}
|
||||||
|
// match () {}
|
||||||
|
// while true {}
|
||||||
|
// for _ in () {}
|
||||||
|
// {}
|
||||||
|
// {}
|
||||||
|
// macro_rules! test {
|
||||||
|
// () => {}
|
||||||
|
// }
|
||||||
|
// test!{}
|
||||||
|
// }
|
||||||
|
if is_blocklike {
|
||||||
|
p.eat(SEMI);
|
||||||
|
} else {
|
||||||
|
p.expect(SEMI);
|
||||||
|
}
|
||||||
|
m.complete(p, EXPR_STMT);
|
||||||
}
|
}
|
||||||
m.complete(p, EXPR_STMT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue