about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-02-23 09:25:36 +0100
committerGitHub <noreply@github.com>2019-02-23 09:25:36 +0100
commit2db0e489bc1af7518c51463d9b5fd4dd25bb73ce (patch)
treedc91525f2578d2e0d8cc9c21327bd9cae91d5aee /src/libsyntax/parse
parentc2ad75e36409c97a49c950060d88c4ca7eaa580c (diff)
parentcc1cd8365704fe681caa26a7e4c507fce45e7f1e (diff)
downloadrust-2db0e489bc1af7518c51463d9b5fd4dd25bb73ce.tar.gz
rust-2db0e489bc1af7518c51463d9b5fd4dd25bb73ce.zip
Rollup merge of #58654 - estebank:underflow, r=nikomatsakis
Do not underflow after resetting unmatched braces count

Fix #58638.

r? @oli-obk
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index bb2e9d8ed59..5a753e1f8c8 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)?;