Module depth

Module depth 

Source
Expand description

The front end’s nesting ceiling: a count, and the host stack that count implies.

The front end recurses over structure the user chose — nested parentheses, nested blocks, a macro that expands into more of itself, a type inside a type. Every one of those is a host frame, and until this module existed nothing counted them: docs/42-security-assurance.md §42.2 measured an ~7.6 KB file that aborted beck check in a debug build with no span and nothing catchable.

The bound is a count, for the reason docs/adr/0007 gave for the evaluator’s: a stack-headroom budget accepts a program in a release build and refuses it in a debug one, and a diagnostic that depends on the profile is not a diagnostic. docs/adr/0012 makes that argument for the front end.

It lives in this crate because three crates share it — beck-syntax reads, beck-macro expands, beck-core checks — and a ceiling with three definitions is three ceilings.

Structs§

Nesting
A recursion counter, held by whatever is recursing.

Constants§

MAX_BLOCK
How many statements one block may hold before the front end refuses it.
MAX_NESTING
How deep the front end will follow user-chosen structure before it refuses.
STACK_BYTES
The host stack the front end needs to reach MAX_NESTING on every one of its recursions.

Functions§

on_the_front_end_stack
Run f on a thread that has STACK_BYTES, and give back what it returned.