about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2021-12-06 11:47:36 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2021-12-06 11:47:36 +0200
commitf5db6e0e95a3987a9cc19ea6b3ede9d4657e43b4 (patch)
treef9946782db8b03165681a45d50fa069c861d5be8
parent7d6fcbc0be2151bfa85ec146545b42d8be2fb28c (diff)
downloadrust-f5db6e0e95a3987a9cc19ea6b3ede9d4657e43b4.tar.gz
rust-f5db6e0e95a3987a9cc19ea6b3ede9d4657e43b4.zip
Bump parser step limit a little
-rw-r--r--Cargo.lock1
-rw-r--r--crates/parser/Cargo.toml2
-rw-r--r--crates/parser/src/parser.rs5
3 files changed, 7 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8a0d809a1b9..3ad8244466c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1071,6 +1071,7 @@ name = "parser"
 version = "0.0.0"
 dependencies = [
  "drop_bomb",
+ "limit",
 ]
 
 [[package]]
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index c31cfaafc7e..d830ea93c82 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -11,3 +11,5 @@ doctest = false
 
 [dependencies]
 drop_bomb = "0.1.4"
+
+limit = { path = "../limit", version = "0.0.0" }
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 5820ffd77d4..44c5f8e12f5 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -3,6 +3,7 @@
 use std::cell::Cell;
 
 use drop_bomb::DropBomb;
+use limit::Limit;
 
 use crate::{
     event::Event,
@@ -26,6 +27,8 @@ pub(crate) struct Parser<'t> {
     steps: Cell<u32>,
 }
 
+static PARSER_STEP_LIMIT: Limit = Limit::new(15_000_000);
+
 impl<'t> Parser<'t> {
     pub(super) fn new(token_source: &'t mut dyn TokenSource) -> Parser<'t> {
         Parser { token_source, events: Vec::new(), steps: Cell::new(0) }
@@ -48,7 +51,7 @@ impl<'t> Parser<'t> {
         assert!(n <= 3);
 
         let steps = self.steps.get();
-        assert!(steps <= 10_000_000, "the parser seems stuck");
+        assert!(PARSER_STEP_LIMIT.check(steps as usize).is_ok(), "the parser seems stuck");
         self.steps.set(steps + 1);
 
         self.token_source.lookahead_nth(n).kind