diff --git a/lib/docs/main.js b/lib/docs/main.js index 3d258f4ce8..c842684ee7 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -1361,6 +1361,12 @@ Happy writing! return; } + case "ref": { + yield { src: "&", tag: Tag.ampersand }; + yield* ex(zigAnalysis.exprs[expr.ref], opts); + return; + } + case "call": { let call = zigAnalysis.calls[expr.call]; diff --git a/src/Autodoc.zig b/src/Autodoc.zig index 3b899cfd8f..a1552c3cd2 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -797,6 +797,7 @@ const DocData = struct { binOp: BinOp, binOpIndex: usize, load: usize, // index in `exprs` + ref: usize, // index in `exprs` const BinOp = struct { lhs: usize, // index in `exprs` rhs: usize, // index in `exprs` @@ -1521,6 +1522,23 @@ fn walkInstruction( .expr = .{ .load = load_idx }, }; }, + .ref => { + const un_tok = data[inst_index].un_tok; + const operand = try self.walkRef( + file, + parent_scope, + parent_src, + un_tok.operand, + need_type, + call_ctx, + ); + const ref_idx = self.exprs.items.len; + try self.exprs.append(self.arena, operand.expr); + + return DocData.WalkResult{ + .expr = .{ .ref = ref_idx }, + }; + }, // @check array_cat and array_mul .add,