From b2be998b7b0beb48806cd3a1552e44100b12ddb6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 5 Sep 2019 19:53:07 +0300 Subject: better error recovery for use trees --- crates/ra_parser/src/grammar/items.rs | 2 +- crates/ra_parser/src/grammar/items/use_item.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_parser/src/grammar') diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index 6d426206e..b4327b78f 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs @@ -31,7 +31,7 @@ pub(super) enum ItemFlavor { pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, - CRATE_KW + CRATE_KW, USE_KW ]; pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index c0c7d0ec6..83a65e226 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs @@ -101,7 +101,10 @@ fn use_tree(p: &mut Parser) { } _ => { m.abandon(p); - p.err_and_bump("expected one of `*`, `::`, `{`, `self`, `super` or an indentifier"); + p.err_recover( + "expected one of `*`, `::`, `{`, `self`, `super` or an identifier", + ITEM_RECOVERY_SET, + ); return; } } -- cgit v1.2.3