Open and answer this issue on GitHub.
ready · opened 2026-11-10 · updated 2026-11-10 · 0 comments
Since ADR-306 D26 (proved checks dropped by default), a proved operation is written as unsafe { nikaia_std::proven::… }. f4107113 keeps one proved operation inside another in a single unsafe block (EmitOut.unsafe_depth, open_unsafe / close_unsafe). A block the user wrote does not count yet:
fn main() {
let t: Vec[i64] = [1, 2, 3, 4]
let i: i64 = 1
let x = unsafe { t[i] } // proved read inside the user's unsafe
println(x)
}
The emitted Rust holds unsafe { … unsafe { nikaia_std::proven::read(…) } … }, and rustc warns “unnecessary unsafe block” about a file nobody wrote.
emit_expr.nika, Expr::Unsafe arm (about line 390): raise out.unsafe_depth around the emission of the block’s body. Check first that no nested fn item or closure body that is emitted in that block can land outside it; if one can, reset the depth for it.tests/compiler/ with the probe above: at both settings, no rustc warning, and the count of unsafe { in the lowered text is 1.A proved operation inside a user’s unsafe block is emitted without an unsafe of its own, and the test passes at both settings.
Generated by Claude Code