Skip to content

Commit

Permalink
Rollup merge of rust-lang#58654 - estebank:underflow, r=nikomatsakis
Browse files Browse the repository at this point in the history
Do not underflow after resetting unmatched braces count

Fix rust-lang#58638.

r? @oli-obk
  • Loading branch information
Centril authored Feb 23, 2019
2 parents c2ad75e + cc1cd83 commit 2db0e48
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,10 @@ impl<'a> Parser<'a> {
match ate {
Some(_) => {
// See doc comment for `unmatched_angle_bracket_count`.
self.unmatched_angle_bracket_count -= 1;
debug!("expect_gt: (decrement) count={:?}", self.unmatched_angle_bracket_count);
if self.unmatched_angle_bracket_count > 0 {
self.unmatched_angle_bracket_count -= 1;
debug!("expect_gt: (decrement) count={:?}", self.unmatched_angle_bracket_count);
}

Ok(())
},
Expand Down Expand Up @@ -2248,8 +2250,10 @@ impl<'a> Parser<'a> {

// See doc comment for `unmatched_angle_bracket_count`.
self.expect(&token::Gt)?;
self.unmatched_angle_bracket_count -= 1;
debug!("parse_qpath: (decrement) count={:?}", self.unmatched_angle_bracket_count);
if self.unmatched_angle_bracket_count > 0 {
self.unmatched_angle_bracket_count -= 1;
debug!("parse_qpath: (decrement) count={:?}", self.unmatched_angle_bracket_count);
}

self.expect(&token::ModSep)?;

Expand Down

0 comments on commit 2db0e48

Please sign in to comment.