Skip to content

Commit

Permalink
Fix issue parsing .
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Sep 13, 2018
1 parent 2e5f30c commit ca2849a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#![feature(str_escape)]
#![feature(try_trait)]
#![feature(unicode_internals)]
#![feature(catch_expr)]

#![recursion_limit="256"]

Expand Down
7 changes: 7 additions & 0 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}


Expand Down Expand Up @@ -569,6 +571,7 @@ impl<'a> Parser<'a> {
},
desugar_doc_comments,
cfg_mods: true,
prevent_recovery: false,
};

let tok = parser.next_tok();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 `::(`.
Expand Down

0 comments on commit ca2849a

Please sign in to comment.