mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Bump parser step limit a little
This commit is contained in:
parent
7d6fcbc0be
commit
f5db6e0e95
3 changed files with 7 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1071,6 +1071,7 @@ name = "parser"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"drop_bomb",
|
"drop_bomb",
|
||||||
|
"limit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -11,3 +11,5 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
drop_bomb = "0.1.4"
|
drop_bomb = "0.1.4"
|
||||||
|
|
||||||
|
limit = { path = "../limit", version = "0.0.0" }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
use drop_bomb::DropBomb;
|
use drop_bomb::DropBomb;
|
||||||
|
use limit::Limit;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
event::Event,
|
event::Event,
|
||||||
|
@ -26,6 +27,8 @@ pub(crate) struct Parser<'t> {
|
||||||
steps: Cell<u32>,
|
steps: Cell<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PARSER_STEP_LIMIT: Limit = Limit::new(15_000_000);
|
||||||
|
|
||||||
impl<'t> Parser<'t> {
|
impl<'t> Parser<'t> {
|
||||||
pub(super) fn new(token_source: &'t mut dyn TokenSource) -> Parser<'t> {
|
pub(super) fn new(token_source: &'t mut dyn TokenSource) -> Parser<'t> {
|
||||||
Parser { token_source, events: Vec::new(), steps: Cell::new(0) }
|
Parser { token_source, events: Vec::new(), steps: Cell::new(0) }
|
||||||
|
@ -48,7 +51,7 @@ impl<'t> Parser<'t> {
|
||||||
assert!(n <= 3);
|
assert!(n <= 3);
|
||||||
|
|
||||||
let steps = self.steps.get();
|
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.steps.set(steps + 1);
|
||||||
|
|
||||||
self.token_source.lookahead_nth(n).kind
|
self.token_source.lookahead_nth(n).kind
|
||||||
|
|
Loading…
Reference in a new issue