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. Public Function
pubfnassertTrackable(zir: Zir, inst_idx: Zir.Inst.Index) void {
comptimeassert(Zir.inst_tracking_version == 0);
constinst = zir.instructions.get(@backingInt(inst_idx));
switch (inst.tag) {
.struct_init,
.struct_init_ref,
.struct_init_anon,
=> {}, // tracked in order, as the owner instructions of anonymous struct types
.func, .func_inferred => {
// These are tracked provided they are actual function declarations, not just bodies.constextra = zir.extraData(Inst.Func, inst.data.pl_node.payload_index);
assert(extra.data.body_len != 0);
},
.func_fancy => {
// These are tracked provided they are actual function declarations, not just bodies.constextra = zir.extraData(Inst.FuncFancy, inst.data.pl_node.payload_index);
assert(extra.data.body_len != 0);
},
.declaration => {}, // tracked by correlating names in the namespace of the parent container
.extended => switch (inst.data.extended.opcode) {
.struct_decl,
.union_decl,
.enum_decl,
.opaque_decl,
.reify_enum,
.reify_struct,
.reify_union,
.reify_spirv_type,
=> {}, // tracked in order, as the owner instructions of explicit container typeselse => unreachable, // assertion failure; not trackable
},
else => unreachable, // assertion failure; not trackable
}
}
Asserts that a ZIR instruction is tracked across incremental updates, and thus may be given an
InternPool.TrackedInst.