diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-02-22 11:17:30 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-02-22 11:52:03 -0800 |
| commit | cc1cd8365704fe681caa26a7e4c507fce45e7f1e (patch) | |
| tree | 4a2dcc682e30bf84db3fa30b1109411cd75b121a /src/libsyntax/parse/parser.rs | |
| parent | f47ec2ad5b6887b3d400aee49e2294bd27733d18 (diff) | |
| download | rust-cc1cd8365704fe681caa26a7e4c507fce45e7f1e.tar.gz rust-cc1cd8365704fe681caa26a7e4c507fce45e7f1e.zip | |
Do not underflow after resetting unmatched braces count
Fix #58638.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e22047938e5..72b201c0d54 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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(()) }, @@ -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)?; |
