This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function
Restore the error return trace index. Performs the restore only if the result is a non-error or if the result location is a non-error-handling expression.
fnrestoreErrRetIndex(
gz: *GenZir,
bt: GenZir.BranchTarget,
ri: ResultInfo,
node: Ast.Node.Index,
result: Zir.Inst.Ref,
) !void {
constop = switch (nodeMayEvalToError(gz.astgen.tree, node)) {
.always => return, // never restore/pop
.never => .none, // always restore/pop
.maybe => switch (ri.ctx) {
.error_handling_expr, .@"return", .fn_arg, .const_init => switch (ri.rl) {
.ptr => |ptr_res| trygz.addUnNode(.load, ptr_res.inst, node),
.inferred_ptr => blk: {
// This is a terrible workaround for Sema's inability to load from a .alloc_inferred ptr// before its type has been resolved. There is no valid operand to use here, so error// traces will be popped prematurely.// TODO: Update this to do a proper load from the rl_ptr, once Sema can support it.break :blk .none;
},
.destructure => return, // value must be a tuple or array, so never restore/popelse => result,
},
else => .none, // always restore/pop
},
};
_ = trygz.addRestoreErrRetIndex(bt, .{ .if_non_error = op }, node);
}
Restore the error return trace index. Performs the restore only if the result is a non-error or if the result location is a non-error-handling expression.