From 408a08708fbb0abe03bfeaa835666a72d79c843d Mon Sep 17 00:00:00 2001 From: mlugg Date: Fri, 1 Mar 2024 01:20:50 +0000 Subject: [PATCH] Autodoc: do not rely on redundant block within function body --- src/Autodoc.zig | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Autodoc.zig b/src/Autodoc.zig index f321fadbb7..480651fb20 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -5137,7 +5137,7 @@ fn analyzeFancyFunction( file, scope, parent_src, - fn_info.body[0], + fn_info.body, call_ctx, ); } else { @@ -5303,7 +5303,7 @@ fn analyzeFunction( file, scope, parent_src, - fn_info.body[0], + fn_info.body, call_ctx, ); } else { @@ -5350,17 +5350,10 @@ fn getGenericReturnType( file: *File, scope: *Scope, parent_src: SrcLocInfo, // function decl line - body_main_block: Zir.Inst.Index, + body: []const Zir.Inst.Index, call_ctx: ?*const CallContext, ) !DocData.Expr { const tags = file.zir.instructions.items(.tag); - const data = file.zir.instructions.items(.data); - - // We expect `body_main_block` to be the first instruction - // inside the function body, and for it to be a block instruction. - const pl_node = data[@intFromEnum(body_main_block)].pl_node; - const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index); - const body = file.zir.bodySlice(extra.end, extra.data.body_len); if (body.len >= 4) { const maybe_ret_inst = body[body.len - 4]; switch (tags[@intFromEnum(maybe_ret_inst)]) {