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,6 +56,9 @@ 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);
|
||||||
|
if p.at(LET_KW) {
|
||||||
|
let_stmt(p, m);
|
||||||
|
} else {
|
||||||
match items::maybe_item(p, items::ItemFlavor::Mod) {
|
match items::maybe_item(p, items::ItemFlavor::Mod) {
|
||||||
items::MaybeItem::Item(kind) => {
|
items::MaybeItem::Item(kind) => {
|
||||||
m.complete(p, kind);
|
m.complete(p, kind);
|
||||||
|
@ -72,12 +71,10 @@ pub(crate) fn block(p: &mut Parser) {
|
||||||
// fn foo() { pub 92; } //FIXME
|
// fn foo() { pub 92; } //FIXME
|
||||||
items::MaybeItem::None => {
|
items::MaybeItem::None => {
|
||||||
if has_attrs {
|
if has_attrs {
|
||||||
if p.at(LET_KW) {
|
|
||||||
let_stmt(p, m);
|
|
||||||
} else {
|
|
||||||
m.abandon(p);
|
m.abandon(p);
|
||||||
p.error("expected a let statement");
|
p.error(
|
||||||
}
|
"expected a let statement or an item after attributes in block",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
|
let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
|
||||||
if p.at(R_CURLY) {
|
if p.at(R_CURLY) {
|
||||||
|
@ -110,6 +107,7 @@ pub(crate) fn block(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
p.expect(R_CURLY);
|
p.expect(R_CURLY);
|
||||||
m.complete(p, BLOCK);
|
m.complete(p, BLOCK);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue