Skip to main content

MAX_NESTING_DEPTH

Constant MAX_NESTING_DEPTH 

Source
pub const MAX_NESTING_DEPTH: usize = 256;
Expand description

Maximum nesting depth for recursive grammar productions (expressions, unary chains, type expressions).

The recursive-descent parser consumes one or more stack frames per nesting level; without a bound, pathological input like 100k nested parentheses overflows the stack and aborts the process (including the LSP server). The limit is far above any realistic engineering program — note that left-nested operator chains (1.0 + 1.0 + …) are parsed iteratively and are not limited by this bound.