Skip to content

Commit 78f835e

Browse files
authored
Rollup merge of rust-lang#58654 - estebank:underflow, r=nikomatsakis
Do not underflow after resetting unmatched braces count Fix rust-lang#58638. r? @oli-obk
2 parents 49c79de + cc1cd83 commit 78f835e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libsyntax/parse/parser.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,10 @@ impl<'a> Parser<'a> {
11841184
match ate {
11851185
Some(_) => {
11861186
// See doc comment for `unmatched_angle_bracket_count`.
1187-
self.unmatched_angle_bracket_count -= 1;
1188-
debug!("expect_gt: (decrement) count={:?}", self.unmatched_angle_bracket_count);
1187+
if self.unmatched_angle_bracket_count > 0 {
1188+
self.unmatched_angle_bracket_count -= 1;
1189+
debug!("expect_gt: (decrement) count={:?}", self.unmatched_angle_bracket_count);
1190+
}
11891191

11901192
Ok(())
11911193
},
@@ -2248,8 +2250,10 @@ impl<'a> Parser<'a> {
22482250

22492251
// See doc comment for `unmatched_angle_bracket_count`.
22502252
self.expect(&token::Gt)?;
2251-
self.unmatched_angle_bracket_count -= 1;
2252-
debug!("parse_qpath: (decrement) count={:?}", self.unmatched_angle_bracket_count);
2253+
if self.unmatched_angle_bracket_count > 0 {
2254+
self.unmatched_angle_bracket_count -= 1;
2255+
debug!("parse_qpath: (decrement) count={:?}", self.unmatched_angle_bracket_count);
2256+
}
22532257

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

0 commit comments

Comments
 (0)