From 51f7f937a569680ddb0b2bbca2a74f861802898b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Aug 2018 18:30:56 +0300 Subject: Safer errors --- crates/libsyntax2/src/grammar/mod.rs | 4 ++-- crates/libsyntax2/src/grammar/patterns.rs | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'crates/libsyntax2/src') diff --git a/crates/libsyntax2/src/grammar/mod.rs b/crates/libsyntax2/src/grammar/mod.rs index e1329044d..d9443f24f 100644 --- a/crates/libsyntax2/src/grammar/mod.rs +++ b/crates/libsyntax2/src/grammar/mod.rs @@ -129,7 +129,7 @@ fn name(p: &mut Parser) { p.bump(); m.complete(p, NAME); } else { - p.error("expected a name"); + p.err_and_bump("expected a name"); } } @@ -139,7 +139,7 @@ fn name_ref(p: &mut Parser) { p.bump(); m.complete(p, NAME_REF); } else { - p.error("expected identifier"); + p.err_and_bump("expected identifier"); } } diff --git a/crates/libsyntax2/src/grammar/patterns.rs b/crates/libsyntax2/src/grammar/patterns.rs index 220f36db7..71a1d5445 100644 --- a/crates/libsyntax2/src/grammar/patterns.rs +++ b/crates/libsyntax2/src/grammar/patterns.rs @@ -117,11 +117,8 @@ fn struct_pat_fields(p: &mut Parser) { p.bump(); pattern(p); } - REF_KW | MUT_KW | IDENT => { - bind_pat(p, false); - }, _ => { - p.err_and_bump("expected ident"); + bind_pat(p, false); } } if !p.at(R_CURLY) { -- cgit v1.2.3