Skip to main content

MAX_INTERPOLATION_NESTING

Constant MAX_INTERPOLATION_NESTING 

Source
pub const MAX_INTERPOLATION_NESTING: usize = 32;
Expand description

How deeply "…" literals may nest inside each other’s interpolation holes (§8.1, ADR-147).

A hole holds a full expression, so "{f("{y}")}" is one literal containing another and interp::text_end is recursive with the file’s own text. The bound is what keeps adversarial input off the stack.

Unlike MAX_TEMPLATE_NESTING, reaching this bound does not change what a delimiter means — it refuses to enter, and the literal is reported as unterminated. That difference is deliberate: the lexer’s resume path only ever runs for a literal the pre-scan proved closes, so a bound that answered “closed, measured differently” would put the two on different rules at exactly the depth nobody writes.