From ca2849ad5a1ee6aafb7c8ce3df75acbf2054c4dd Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 13 Sep 2018 18:14:17 +0100 Subject: [PATCH] Fix issue parsing . --- src/libsyntax/lib.rs | 1 + src/libsyntax/parse/parser.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index c8ec273a03f28..50bc81f5e635a 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -29,6 +29,7 @@ #![feature(str_escape)] #![feature(try_trait)] #![feature(unicode_internals)] +#![feature(catch_expr)] #![recursion_limit="256"] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f71aca92e35aa..2160b543a5319 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -250,6 +250,8 @@ pub struct Parser<'a> { desugar_doc_comments: bool, /// Whether we should configure out of line modules as we parse. pub cfg_mods: bool, + /// Whether we should prevent recovery from parsing areas (during backtracking). + prevent_recovery: bool, } @@ -569,6 +571,7 @@ impl<'a> Parser<'a> { }, desugar_doc_comments, cfg_mods: true, + prevent_recovery: false, }; let tok = parser.next_tok(); @@ -1111,6 +1114,9 @@ impl<'a> Parser<'a> { first = false; } else { if let Err(mut e) = self.expect(t) { + if self.prevent_recovery { + return Err(e); + } // Attempt to keep parsing if it was a similar separator if let Some(ref tokens) = t.similar_tokens() { if tokens.contains(&self.token) { @@ -2063,6 +2069,7 @@ impl<'a> Parser<'a> { // We have to save a snapshot, because it could end up being an expression // instead. parser_snapshot_before_generics = Some(self.clone()); + self.prevent_recovery = true; true } { // Generic arguments are found - `<`, `(`, `::<` or `::(`.