diff options
Diffstat (limited to 'src/AstGen.zig')
| -rw-r--r-- | src/AstGen.zig | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index ff3404a51b..7343515008 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -3562,17 +3562,14 @@ fn fnDecl( var ret_gz = decl_gz.makeSubBlock(params_scope); defer ret_gz.unstack(); - const ret_ref: Zir.Inst.Ref = switch (nodePrimitive(tree, fn_proto.ast.return_type)) { - .none => inst: { - const inst = try expr(&ret_gz, params_scope, coerced_type_rl, fn_proto.ast.return_type); - if (ret_gz.instructionsSlice().len == 0) { - // In this case we will send a len=0 body which can be encoded more efficiently. - break :inst inst; - } - _ = try ret_gz.addBreak(.break_inline, 0, inst); + const ret_ref: Zir.Inst.Ref = inst: { + const inst = try expr(&ret_gz, params_scope, coerced_type_rl, fn_proto.ast.return_type); + if (ret_gz.instructionsSlice().len == 0) { + // In this case we will send a len=0 body which can be encoded more efficiently. break :inst inst; - }, - else => |p| p, + } + _ = try ret_gz.addBreak(.break_inline, 0, inst); + break :inst inst; }; const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { @@ -9025,31 +9022,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { } } -fn nodePrimitive(tree: *const Ast, start_node: Ast.Node.Index) Zir.Inst.Ref { - const node_tags = tree.nodes.items(.tag); - const node_datas = tree.nodes.items(.data); - - var node = start_node; - while (true) { - switch (node_tags[node]) { - // Forward the question to the LHS sub-expression. - .grouped_expression => node = node_datas[node].lhs, - - .identifier => { - const main_tokens = tree.nodes.items(.main_token); - const ident_bytes = tree.tokenSlice(main_tokens[node]); - if (primitives.get(ident_bytes)) |primitive| { - return primitive; - } else { - return .none; - } - }, - - else => return .none, - } - } -} - /// Applies `rl` semantics to `result`. Expressions which do not do their own handling of /// result locations must call this function on their result. /// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer. |
