From b79c8b6d8a3b38c94de992a54ffb9055c1ad6f31 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 27 Aug 2018 21:10:02 +0300 Subject: Fix error blocks --- crates/libsyntax2/src/grammar/expressions/atom.rs | 4 ++++ crates/libsyntax2/src/grammar/expressions/mod.rs | 1 + crates/libsyntax2/src/grammar/items/structs.rs | 4 ++++ crates/libsyntax2/src/grammar/items/traits.rs | 8 ++++++++ 4 files changed, 17 insertions(+) (limited to 'crates/libsyntax2') diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index e83c82c92..ab4aa49d2 100644 --- a/crates/libsyntax2/src/grammar/expressions/atom.rs +++ b/crates/libsyntax2/src/grammar/expressions/atom.rs @@ -269,6 +269,10 @@ fn match_arm_list(p: &mut Parser) { let m = p.start(); p.eat(L_CURLY); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected match arm"); + continue; + } // test match_arms_commas // fn foo() { // match () { diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index fb702a398..9379ed938 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs @@ -433,6 +433,7 @@ fn named_field_list(p: &mut Parser) { p.bump(); expr(p); } + L_CURLY => error_block(p, "expected a field"), _ => p.err_and_bump("expected identifier"), } if !p.at(R_CURLY) { diff --git a/crates/libsyntax2/src/grammar/items/structs.rs b/crates/libsyntax2/src/grammar/items/structs.rs index 93d3381f8..180205393 100644 --- a/crates/libsyntax2/src/grammar/items/structs.rs +++ b/crates/libsyntax2/src/grammar/items/structs.rs @@ -56,6 +56,10 @@ fn enum_variant_list(p: &mut Parser) { let m = p.start(); p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected enum variant"); + continue; + } let var = p.start(); attributes::outer_attributes(p); if p.at(IDENT) { diff --git a/crates/libsyntax2/src/grammar/items/traits.rs b/crates/libsyntax2/src/grammar/items/traits.rs index 3853ccaab..01b79e3c9 100644 --- a/crates/libsyntax2/src/grammar/items/traits.rs +++ b/crates/libsyntax2/src/grammar/items/traits.rs @@ -30,6 +30,10 @@ fn trait_item_list(p: &mut Parser) { let m = p.start(); p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected an item"); + continue; + } item_or_macro(p, true, ItemFlavor::Trait); } p.expect(R_CURLY); @@ -76,6 +80,10 @@ fn impl_item_list(p: &mut Parser) { p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected an item"); + continue; + } item_or_macro(p, true, ItemFlavor::Mod); } p.expect(R_CURLY); -- cgit v1.2.3