mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
fix assertione error on block parsing
This commit is contained in:
parent
fed5727ea2
commit
838820ad98
@ -148,11 +148,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
|
||||
p.eat(MOVE_KW);
|
||||
params::param_list_opt_types(p);
|
||||
if opt_fn_ret_type(p) {
|
||||
if p.at(L_CURLY) {
|
||||
block(p);
|
||||
} else {
|
||||
p.error("expected a block");
|
||||
}
|
||||
block(p);
|
||||
} else {
|
||||
expr(p);
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ fn expr_no_struct(p: &mut Parser) {
|
||||
// fn c() { 1; 2; }
|
||||
// fn d() { 1; 2 }
|
||||
pub(crate) fn block(p: &mut Parser) {
|
||||
assert!(p.at(L_CURLY));
|
||||
if !p.at(L_CURLY) {
|
||||
p.error("expected a block");
|
||||
return;
|
||||
}
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
while !p.at(EOF) && !p.at(R_CURLY) {
|
||||
|
@ -252,10 +252,10 @@ fn function(p: &mut Parser, flavor: ItemFlavor) {
|
||||
|
||||
// test fn_decl
|
||||
// trait T { fn foo(); }
|
||||
if p.at(L_CURLY) {
|
||||
expressions::block(p);
|
||||
if p.at(SEMI) {
|
||||
p.bump();
|
||||
} else {
|
||||
p.expect(SEMI);
|
||||
expressions::block(p)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ ROOT@[0; 14)
|
||||
L_PAREN@[6; 7)
|
||||
err: `expected value parameter`
|
||||
err: `expected R_PAREN`
|
||||
err: `expected SEMI`
|
||||
err: `expected a block`
|
||||
err: `expected an item`
|
||||
ERROR@[7; 8)
|
||||
R_CURLY@[7; 8)
|
||||
|
Loading…
Reference in New Issue
Block a user