Open and answer this issue on GitHub.
ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments
Part of #906 After #2535 After #2544
ADR-specialization-1 D2, D3, D5: @unroll before a for makes the loop variable a build-time value in every turn; each turn is a copy of the body with the element bound as a constant, a branch on it decided while building (D4). A list that is not a build-time value is NK1304. @unroll(up_to: N) unrolls a list of at most N elements and leaves a longer one a loop, the body checked both ways (NK1305). Each turn is checked with its value bound, a message names the loop and the turn, and every turn counts against the build’s budget (NK1152, ADR-321 D7). The lowering is shaped by the measurement #2535 owes. Was #906 item 5.
@unroll before a for (the first attribute before a statement): the list evaluated per copy, each turn a block with the element bound as a constant, continue/break through labelled Rust blocks, nested unrolling, NK1304, per-turn messages and NK1152. The checker’s and emitter’s machinery for T::fields (facts.unrolled, check_program_turns, walk.specialising, emit_stmt_for) generalised from types to values, not duplicated. Tests: an unrolled loop, a nested one, continue/break in a turn, a message naming the turn, NK1152 past the budget, NK1304.@unroll(up_to: N): unrolled at most N elements, a loop otherwise, the body checked both ways (NK1305). Test: one list under and one over N, and the NK1305 refusal.@unroll and @unroll(up_to: N) unroll a loop over a build-time list per turn and refuse with NK1304, NK1305 and NK1152 as D2-D5 say, each shown by its test; the last commit carries Fixes #N for this issue, and the report gives a Found: line per finding.
Split from #906 by Claude Code