pub struct Nesting { /* private fields */ }Expand description
A recursion counter, held by whatever is recursing.
The discipline is enter at the recursion site and leave
on the way out — at the site, not at one grammar rule that seemed to be where nesting comes
from. That is the Scriban lesson (GHSA-p6q4-fgr8-vx4p, §42.2): a limit added at the one
production somebody thought of was bypassed through a different one.
Implementations§
Source§impl Nesting
impl Nesting
pub fn new() -> Nesting
Sourcepub fn with_limit(limit: u32) -> Nesting
pub fn with_limit(limit: u32) -> Nesting
A counter with a lower ceiling, for a test that would rather not build a 256-deep input.
Sourcepub fn resumed(&self) -> Nesting
pub fn resumed(&self) -> Nesting
A counter for a sub-parse that continues this one, starting at the depth already reached.
A sub-parser over a captured token run is still inside whatever brackets captured it, and a counter that started again at zero would be a way in — the same shape of bypass the Scriban advisory records.
pub fn limit(&self) -> u32
pub fn depth(&self) -> u32
Sourcepub fn enter(&mut self) -> bool
pub fn enter(&mut self) -> bool
Descend one level. false means the ceiling is reached and the caller must not recurse —
and must not leave either, because nothing was entered.
pub fn leave(&mut self)
Sourcepub fn should_report(&mut self) -> bool
pub fn should_report(&mut self) -> bool
True exactly once per compilation.
One over-deep expression is refused at every level on the way out, and a reader wants the count, not one copy of it per level.
Sourcepub fn note(&self) -> String
pub fn note(&self) -> String
The note every site prints, so the three of them say the same thing.
Sourcepub fn note_about(&self, what: &str) -> String
pub fn note_about(&self, what: &str) -> String
The same note, naming the axis being counted.
Two axes reach the same stack — nesting depth and the length of a flat chain
(MAX_BLOCK) — and a note that called the second “nesting” would send a reader looking
for brackets in a function that has none.