E0018 — Recursion / stack usage limit exceeded
A function recursed (directly or indirectly) past the interpreter or embedded runtime’s configured stack budget.
What triggers it
Deep or unbounded recursion exhausts the call-frame budget before
the recursion base case is reached. On the embedded (no_std)
runtime this is a fixed static budget checked by rz stack-usage;
on the host interpreter/VM it’s the thread stack size.
Minimal example
fn loop_forever(int n) -> int {
return loop_forever(n + 1);
}
fn main() {
return loop_forever(0);
}
Output:
scratch.rz:2:12: error[E0018]: recursion limit exceeded in `loop_forever`
return loop_forever(n + 1);
^^^^^^^^^^^^^^^^^^^
Fix
Add a base case that terminates the recursion, or convert the
recursion to an explicit loop. For embedded targets, check
rz stack-usage against the configured budget.
Source
Emitted from the interpreter/VM call-frame guard in
resilient/src/lib.rs, and from the static stack-usage analysis
in resilient/src/stack_usage.rs.