authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-12 01:25:11-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-12 02:22:46-04:00
log09b0070e876e11da0a5291106a115f66b548790b
tree5991f6c784c4bdd67477f00d1d2cf84131f8a5ba
parent41575fa868f4b75b79bf5f774b66bb9a7b1ab142

AstGen: cleanup `@as` invasion


2 files changed, 187 insertions(+), 193 deletions(-)

src/AstGen.zig+167-173
......@@ -70,10 +70,10 @@ fn addExtra(astgen: *AstGen, extra: anytype) Allocator.Error!u32 {
7070
7171fn addExtraAssumeCapacity(astgen: *AstGen, extra: anytype) u32 {
7272 const fields = std.meta.fields(@TypeOf(extra));
73 const result = @as(u32, @intCast(astgen.extra.items.len));
73 const extra_index: u32 = @intCast(astgen.extra.items.len);
7474 astgen.extra.items.len += fields.len;
75 setExtra(astgen, result, extra);
76 return result;
75 setExtra(astgen, extra_index, extra);
76 return extra_index;
7777}
7878
7979fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
......@@ -83,11 +83,12 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
8383 astgen.extra.items[i] = switch (field.type) {
8484 u32 => @field(extra, field.name),
8585 Zir.Inst.Ref => @intFromEnum(@field(extra, field.name)),
86 i32 => @as(u32, @bitCast(@field(extra, field.name))),
87 Zir.Inst.Call.Flags => @as(u32, @bitCast(@field(extra, field.name))),
88 Zir.Inst.BuiltinCall.Flags => @as(u32, @bitCast(@field(extra, field.name))),
89 Zir.Inst.SwitchBlock.Bits => @as(u32, @bitCast(@field(extra, field.name))),
90 Zir.Inst.FuncFancy.Bits => @as(u32, @bitCast(@field(extra, field.name))),
86 i32,
87 Zir.Inst.Call.Flags,
88 Zir.Inst.BuiltinCall.Flags,
89 Zir.Inst.SwitchBlock.Bits,
90 Zir.Inst.FuncFancy.Bits,
91 => @bitCast(@field(extra, field.name)),
9192 else => @compileError("bad field type"),
9293 };
9394 i += 1;
......@@ -95,19 +96,17 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
9596}
9697
9798fn reserveExtra(astgen: *AstGen, size: usize) Allocator.Error!u32 {
98 const result = @as(u32, @intCast(astgen.extra.items.len));
99 try astgen.extra.resize(astgen.gpa, result + size);
100 return result;
99 const extra_index: u32 = @intCast(astgen.extra.items.len);
100 try astgen.extra.resize(astgen.gpa, extra_index + size);
101 return extra_index;
101102}
102103
103104fn appendRefs(astgen: *AstGen, refs: []const Zir.Inst.Ref) !void {
104 const coerced = @as([]const u32, @ptrCast(refs));
105 return astgen.extra.appendSlice(astgen.gpa, coerced);
105 return astgen.extra.appendSlice(astgen.gpa, @ptrCast(refs));
106106}
107107
108108fn appendRefsAssumeCapacity(astgen: *AstGen, refs: []const Zir.Inst.Ref) void {
109 const coerced = @as([]const u32, @ptrCast(refs));
110 astgen.extra.appendSliceAssumeCapacity(coerced);
109 astgen.extra.appendSliceAssumeCapacity(@ptrCast(refs));
111110}
112111
113112pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
......@@ -176,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
176175 @typeInfo(Zir.Inst.CompileErrors.Item).Struct.fields.len);
177176
178177 astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{
179 .items_len = @as(u32, @intCast(astgen.compile_errors.items.len)),
178 .items_len = @intCast(astgen.compile_errors.items.len),
180179 });
181180
182181 for (astgen.compile_errors.items) |item| {
......@@ -192,7 +191,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
192191 astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).Struct.fields.len);
193192
194193 astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{
195 .imports_len = @as(u32, @intCast(astgen.imports.count())),
194 .imports_len = @intCast(astgen.imports.count()),
196195 });
197196
198197 var it = astgen.imports.iterator();
......@@ -1334,7 +1333,7 @@ fn fnProtoExpr(
13341333 var param_gz = block_scope.makeSubBlock(scope);
13351334 defer param_gz.unstack();
13361335 const param_type = try expr(&param_gz, scope, coerced_type_ri, param_type_node);
1337 const param_inst_expected = @as(u32, @intCast(astgen.instructions.len + 1));
1336 const param_inst_expected: u32 = @intCast(astgen.instructions.len + 1);
13381337 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);
13391338 const main_tokens = tree.nodes.items(.main_token);
13401339 const name_token = param.name_token orelse main_tokens[param_type_node];
......@@ -1468,7 +1467,7 @@ fn arrayInitExpr(
14681467 const array_type_inst = try typeExpr(gz, scope, array_init.ast.type_expr);
14691468 _ = try gz.addPlNode(.validate_array_init_ty, node, Zir.Inst.ArrayInit{
14701469 .ty = array_type_inst,
1471 .init_count = @as(u32, @intCast(array_init.ast.elements.len)),
1470 .init_count = @intCast(array_init.ast.elements.len),
14721471 });
14731472 break :inst .{
14741473 .array = array_type_inst,
......@@ -1552,7 +1551,7 @@ fn arrayInitExprRlNone(
15521551 const astgen = gz.astgen;
15531552
15541553 const payload_index = try addExtra(astgen, Zir.Inst.MultiOp{
1555 .operands_len = @as(u32, @intCast(elements.len)),
1554 .operands_len = @intCast(elements.len),
15561555 });
15571556 var extra_index = try reserveExtra(astgen, elements.len);
15581557
......@@ -1577,7 +1576,7 @@ fn arrayInitExprInner(
15771576
15781577 const len = elements.len + @intFromBool(array_ty_inst != .none);
15791578 const payload_index = try addExtra(astgen, Zir.Inst.MultiOp{
1580 .operands_len = @as(u32, @intCast(len)),
1579 .operands_len = @intCast(len),
15811580 });
15821581 var extra_index = try reserveExtra(astgen, len);
15831582 if (array_ty_inst != .none) {
......@@ -1593,7 +1592,7 @@ fn arrayInitExprInner(
15931592 .tag = .elem_type_index,
15941593 .data = .{ .bin = .{
15951594 .lhs = array_ty_inst,
1596 .rhs = @as(Zir.Inst.Ref, @enumFromInt(i)),
1595 .rhs = @enumFromInt(i),
15971596 } },
15981597 });
15991598 break :ri ResultInfo{ .rl = .{ .coerced_ty = ty_expr } };
......@@ -1638,14 +1637,14 @@ fn arrayInitExprRlPtrInner(
16381637 const astgen = gz.astgen;
16391638
16401639 const payload_index = try addExtra(astgen, Zir.Inst.Block{
1641 .body_len = @as(u32, @intCast(elements.len)),
1640 .body_len = @intCast(elements.len),
16421641 });
16431642 var extra_index = try reserveExtra(astgen, elements.len);
16441643
16451644 for (elements, 0..) |elem_init, i| {
16461645 const elem_ptr = try gz.addPlNode(.elem_ptr_imm, elem_init, Zir.Inst.ElemPtrImm{
16471646 .ptr = result_ptr,
1648 .index = @as(u32, @intCast(i)),
1647 .index = @intCast(i),
16491648 });
16501649 astgen.extra.items[extra_index] = refToIndex(elem_ptr).?;
16511650 extra_index += 1;
......@@ -1797,7 +1796,7 @@ fn structInitExprRlNone(
17971796 const tree = astgen.tree;
17981797
17991798 const payload_index = try addExtra(astgen, Zir.Inst.StructInitAnon{
1800 .fields_len = @as(u32, @intCast(struct_init.ast.fields.len)),
1799 .fields_len = @intCast(struct_init.ast.fields.len),
18011800 });
18021801 const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).Struct.fields.len;
18031802 var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
......@@ -1855,7 +1854,7 @@ fn structInitExprRlPtrInner(
18551854 const tree = astgen.tree;
18561855
18571856 const payload_index = try addExtra(astgen, Zir.Inst.Block{
1858 .body_len = @as(u32, @intCast(struct_init.ast.fields.len)),
1857 .body_len = @intCast(struct_init.ast.fields.len),
18591858 });
18601859 var extra_index = try reserveExtra(astgen, struct_init.ast.fields.len);
18611860
......@@ -1887,7 +1886,7 @@ fn structInitExprRlTy(
18871886 const tree = astgen.tree;
18881887
18891888 const payload_index = try addExtra(astgen, Zir.Inst.StructInit{
1890 .fields_len = @as(u32, @intCast(struct_init.ast.fields.len)),
1889 .fields_len = @intCast(struct_init.ast.fields.len),
18911890 });
18921891 const field_size = @typeInfo(Zir.Inst.StructInit.Item).Struct.fields.len;
18931892 var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
......@@ -2126,7 +2125,7 @@ fn breakExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) Inn
21262125 }
21272126
21282127 const operand = try reachableExpr(parent_gz, parent_scope, block_gz.break_result_info, rhs, node);
2129 const search_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
2128 const search_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
21302129
21312130 try genDefers(parent_gz, scope, parent_scope, .normal_only);
21322131
......@@ -2942,7 +2941,7 @@ fn genDefers(
29422941 .index = defer_scope.index,
29432942 .len = defer_scope.len,
29442943 });
2945 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
2944 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
29462945 gz.astgen.instructions.appendAssumeCapacity(.{
29472946 .tag = .defer_err_code,
29482947 .data = .{ .defer_err_code = .{
......@@ -3021,7 +3020,7 @@ fn deferStmt(
30213020 const sub_scope = if (!have_err_code) &defer_gen.base else blk: {
30223021 try gz.addDbgBlockBegin();
30233022 const ident_name = try gz.astgen.identAsString(payload_token);
3024 remapped_err_code = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
3023 remapped_err_code = @intCast(gz.astgen.instructions.len);
30253024 try gz.astgen.instructions.append(gz.astgen.gpa, .{
30263025 .tag = .extended,
30273026 .data = .{ .extended = .{
......@@ -3061,7 +3060,7 @@ fn deferStmt(
30613060 break :blk gz.astgen.countBodyLenAfterFixups(body) + refs;
30623061 };
30633062
3064 const index = @as(u32, @intCast(gz.astgen.extra.items.len));
3063 const index: u32 = @intCast(gz.astgen.extra.items.len);
30653064 try gz.astgen.extra.ensureUnusedCapacity(gz.astgen.gpa, body_len);
30663065 if (have_err_code) {
30673066 if (gz.astgen.ref_table.fetchRemove(remapped_err_code)) |kv| {
......@@ -3602,7 +3601,7 @@ fn ptrType(
36023601 gz.astgen.extra.appendAssumeCapacity(@intFromEnum(bit_end_ref));
36033602 }
36043603
3605 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
3604 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
36063605 const result = indexToRef(new_index);
36073606 gz.astgen.instructions.appendAssumeCapacity(.{ .tag = .ptr_type, .data = .{
36083607 .ptr_type = .{
......@@ -3693,7 +3692,7 @@ const WipMembers = struct {
36933692 const max_decl_size = 11;
36943693
36953694 fn init(gpa: Allocator, payload: *ArrayListUnmanaged(u32), decl_count: u32, field_count: u32, comptime bits_per_field: u32, comptime max_field_size: u32) Allocator.Error!Self {
3696 const payload_top = @as(u32, @intCast(payload.items.len));
3695 const payload_top: u32 = @intCast(payload.items.len);
36973696 const decls_start = payload_top + (decl_count + decls_per_u32 - 1) / decls_per_u32;
36983697 const field_bits_start = decls_start + decl_count * max_decl_size;
36993698 const fields_start = field_bits_start + if (bits_per_field > 0) blk: {
......@@ -3748,7 +3747,7 @@ const WipMembers = struct {
37483747 fn appendToDeclSlice(self: *Self, data: []const u32) void {
37493748 assert(self.decls_end + data.len <= self.field_bits_start);
37503749 @memcpy(self.payload.items[self.decls_end..][0..data.len], data);
3751 self.decls_end += @as(u32, @intCast(data.len));
3750 self.decls_end += @intCast(data.len);
37523751 }
37533752
37543753 fn appendToField(self: *Self, data: u32) void {
......@@ -3761,14 +3760,14 @@ const WipMembers = struct {
37613760 const empty_decl_slots = decls_per_u32 - (self.decl_index % decls_per_u32);
37623761 if (self.decl_index > 0 and empty_decl_slots < decls_per_u32) {
37633762 const index = self.payload_top + self.decl_index / decls_per_u32;
3764 self.payload.items[index] >>= @as(u5, @intCast(empty_decl_slots * bits_per_decl));
3763 self.payload.items[index] >>= @intCast(empty_decl_slots * bits_per_decl);
37653764 }
37663765 if (bits_per_field > 0) {
37673766 const fields_per_u32 = 32 / bits_per_field;
37683767 const empty_field_slots = fields_per_u32 - (self.field_index % fields_per_u32);
37693768 if (self.field_index > 0 and empty_field_slots < fields_per_u32) {
37703769 const index = self.field_bits_start + self.field_index / fields_per_u32;
3771 self.payload.items[index] >>= @as(u5, @intCast(empty_field_slots * bits_per_field));
3770 self.payload.items[index] >>= @intCast(empty_field_slots * bits_per_field);
37723771 }
37733772 }
37743773 }
......@@ -3930,7 +3929,7 @@ fn fnDecl(
39303929 var param_gz = decl_gz.makeSubBlock(scope);
39313930 defer param_gz.unstack();
39323931 const param_type = try expr(&param_gz, params_scope, coerced_type_ri, param_type_node);
3933 const param_inst_expected = @as(u32, @intCast(astgen.instructions.len + 1));
3932 const param_inst_expected: u32 = @intCast(astgen.instructions.len + 1);
39343933 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);
39353934
39363935 const main_tokens = tree.nodes.items(.main_token);
......@@ -4144,9 +4143,8 @@ fn fnDecl(
41444143 try decl_gz.setBlockBody(block_inst);
41454144
41464145 {
4147 const contents_hash = std.zig.hashSrc(tree.getNodeSource(decl_node));
4148 const casted = @as([4]u32, @bitCast(contents_hash));
4149 wip_members.appendToDeclSlice(&casted);
4146 const contents_hash align(@alignOf(u32)) = std.zig.hashSrc(tree.getNodeSource(decl_node));
4147 wip_members.appendToDeclSlice(std.mem.bytesAsSlice(u32, &contents_hash));
41504148 }
41514149 {
41524150 const line_delta = decl_gz.decl_line - gz.decl_line;
......@@ -4295,9 +4293,8 @@ fn globalVarDecl(
42954293 try block_scope.setBlockBody(block_inst);
42964294
42974295 {
4298 const contents_hash = std.zig.hashSrc(tree.getNodeSource(node));
4299 const casted = @as([4]u32, @bitCast(contents_hash));
4300 wip_members.appendToDeclSlice(&casted);
4296 const contents_hash align(@alignOf(u32)) = std.zig.hashSrc(tree.getNodeSource(node));
4297 wip_members.appendToDeclSlice(std.mem.bytesAsSlice(u32, &contents_hash));
43014298 }
43024299 {
43034300 const line_delta = block_scope.decl_line - gz.decl_line;
......@@ -4350,9 +4347,8 @@ fn comptimeDecl(
43504347 try decl_block.setBlockBody(block_inst);
43514348
43524349 {
4353 const contents_hash = std.zig.hashSrc(tree.getNodeSource(node));
4354 const casted = @as([4]u32, @bitCast(contents_hash));
4355 wip_members.appendToDeclSlice(&casted);
4350 const contents_hash align(@alignOf(u32)) = std.zig.hashSrc(tree.getNodeSource(node));
4351 wip_members.appendToDeclSlice(std.mem.bytesAsSlice(u32, &contents_hash));
43564352 }
43574353 {
43584354 const line_delta = decl_block.decl_line - gz.decl_line;
......@@ -4402,9 +4398,8 @@ fn usingnamespaceDecl(
44024398 try decl_block.setBlockBody(block_inst);
44034399
44044400 {
4405 const contents_hash = std.zig.hashSrc(tree.getNodeSource(node));
4406 const casted = @as([4]u32, @bitCast(contents_hash));
4407 wip_members.appendToDeclSlice(&casted);
4401 const contents_hash align(@alignOf(u32)) = std.zig.hashSrc(tree.getNodeSource(node));
4402 wip_members.appendToDeclSlice(std.mem.bytesAsSlice(u32, &contents_hash));
44084403 }
44094404 {
44104405 const line_delta = decl_block.decl_line - gz.decl_line;
......@@ -4589,9 +4584,8 @@ fn testDecl(
45894584 try decl_block.setBlockBody(block_inst);
45904585
45914586 {
4592 const contents_hash = std.zig.hashSrc(tree.getNodeSource(node));
4593 const casted = @as([4]u32, @bitCast(contents_hash));
4594 wip_members.appendToDeclSlice(&casted);
4587 const contents_hash align(@alignOf(u32)) = std.zig.hashSrc(tree.getNodeSource(node));
4588 wip_members.appendToDeclSlice(std.mem.bytesAsSlice(u32, &contents_hash));
45954589 }
45964590 {
45974591 const line_delta = decl_block.decl_line - gz.decl_line;
......@@ -4690,7 +4684,7 @@ fn structDeclInner(
46904684 };
46914685
46924686 const decl_count = try astgen.scanDecls(&namespace, container_decl.ast.members);
4693 const field_count = @as(u32, @intCast(container_decl.ast.members.len - decl_count));
4687 const field_count: u32 = @intCast(container_decl.ast.members.len - decl_count);
46944688
46954689 const bits_per_field = 4;
46964690 const max_field_size = 5;
......@@ -4803,7 +4797,7 @@ fn structDeclInner(
48034797 const old_scratch_len = astgen.scratch.items.len;
48044798 try astgen.scratch.ensureUnusedCapacity(gpa, countBodyLenAfterFixups(astgen, body));
48054799 appendBodyWithFixupsArrayList(astgen, &astgen.scratch, body);
4806 wip_members.appendToField(@as(u32, @intCast(astgen.scratch.items.len - old_scratch_len)));
4800 wip_members.appendToField(@intCast(astgen.scratch.items.len - old_scratch_len));
48074801 block_scope.instructions.items.len = block_scope.instructions_top;
48084802 } else {
48094803 wip_members.appendToField(@intFromEnum(field_type));
......@@ -4821,7 +4815,7 @@ fn structDeclInner(
48214815 const old_scratch_len = astgen.scratch.items.len;
48224816 try astgen.scratch.ensureUnusedCapacity(gpa, countBodyLenAfterFixups(astgen, body));
48234817 appendBodyWithFixupsArrayList(astgen, &astgen.scratch, body);
4824 wip_members.appendToField(@as(u32, @intCast(astgen.scratch.items.len - old_scratch_len)));
4818 wip_members.appendToField(@intCast(astgen.scratch.items.len - old_scratch_len));
48254819 block_scope.instructions.items.len = block_scope.instructions_top;
48264820 }
48274821
......@@ -4836,7 +4830,7 @@ fn structDeclInner(
48364830 const old_scratch_len = astgen.scratch.items.len;
48374831 try astgen.scratch.ensureUnusedCapacity(gpa, countBodyLenAfterFixups(astgen, body));
48384832 appendBodyWithFixupsArrayList(astgen, &astgen.scratch, body);
4839 wip_members.appendToField(@as(u32, @intCast(astgen.scratch.items.len - old_scratch_len)));
4833 wip_members.appendToField(@intCast(astgen.scratch.items.len - old_scratch_len));
48404834 block_scope.instructions.items.len = block_scope.instructions_top;
48414835 } else if (member.comptime_token) |comptime_token| {
48424836 return astgen.failTok(comptime_token, "comptime field without default initialization value", .{});
......@@ -4849,7 +4843,7 @@ fn structDeclInner(
48494843 .fields_len = field_count,
48504844 .decls_len = decl_count,
48514845 .backing_int_ref = backing_int_ref,
4852 .backing_int_body_len = @as(u32, @intCast(backing_int_body_len)),
4846 .backing_int_body_len = @intCast(backing_int_body_len),
48534847 .known_non_opv = known_non_opv,
48544848 .known_comptime_only = known_comptime_only,
48554849 .is_tuple = is_tuple,
......@@ -4909,7 +4903,7 @@ fn unionDeclInner(
49094903 defer block_scope.unstack();
49104904
49114905 const decl_count = try astgen.scanDecls(&namespace, members);
4912 const field_count = @as(u32, @intCast(members.len - decl_count));
4906 const field_count: u32 = @intCast(members.len - decl_count);
49134907
49144908 if (layout != .Auto and (auto_enum_tok != null or arg_node != 0)) {
49154909 const layout_str = if (layout == .Extern) "extern" else "packed";
......@@ -5204,7 +5198,7 @@ fn containerDecl(
52045198
52055199 const bits_per_field = 1;
52065200 const max_field_size = 3;
5207 var wip_members = try WipMembers.init(gpa, &astgen.scratch, @as(u32, @intCast(counts.decls)), @as(u32, @intCast(counts.total_fields)), bits_per_field, max_field_size);
5201 var wip_members = try WipMembers.init(gpa, &astgen.scratch, @intCast(counts.decls), @intCast(counts.total_fields), bits_per_field, max_field_size);
52085202 defer wip_members.deinit();
52095203
52105204 for (container_decl.ast.members) |member_node| {
......@@ -5262,8 +5256,8 @@ fn containerDecl(
52625256 .nonexhaustive = nonexhaustive,
52635257 .tag_type = arg_inst,
52645258 .body_len = body_len,
5265 .fields_len = @as(u32, @intCast(counts.total_fields)),
5266 .decls_len = @as(u32, @intCast(counts.decls)),
5259 .fields_len = @intCast(counts.total_fields),
5260 .decls_len = @intCast(counts.decls),
52675261 });
52685262
52695263 wip_members.finishBits(bits_per_field);
......@@ -5453,7 +5447,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi
54535447 }
54545448
54555449 setExtra(astgen, payload_index, Zir.Inst.ErrorSetDecl{
5456 .fields_len = @as(u32, @intCast(fields_len)),
5450 .fields_len = @intCast(fields_len),
54575451 });
54585452 const result = try gz.addPlNodePayloadIndex(.error_set_decl, node, payload_index);
54595453 return rvalue(gz, ri, result, node);
......@@ -6356,10 +6350,10 @@ fn whileExpr(
63566350 loop_scope.break_block = loop_block;
63576351 loop_scope.continue_block = continue_block;
63586352 if (while_full.label_token) |label_token| {
6359 loop_scope.label = @as(?GenZir.Label, GenZir.Label{
6353 loop_scope.label = .{
63606354 .token = label_token,
63616355 .block_inst = loop_block,
6362 });
6356 };
63636357 }
63646358
63656359 // done adding instructions to loop_scope, can now stack then_scope
......@@ -6972,7 +6966,7 @@ fn switchExpr(
69726966
69736967 // If any prong has an inline tag capture, allocate a shared dummy instruction for it
69746968 const tag_inst = if (any_has_tag_capture) tag_inst: {
6975 const inst = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
6969 const inst: Zir.Inst.Index = @intCast(astgen.instructions.len);
69766970 try astgen.instructions.append(astgen.gpa, .{
69776971 .tag = .extended,
69786972 .data = .{ .extended = .{
......@@ -7065,7 +7059,7 @@ fn switchExpr(
70657059 break :blk &tag_scope.base;
70667060 };
70677061
7068 const header_index = @as(u32, @intCast(payloads.items.len));
7062 const header_index: u32 = @intCast(payloads.items.len);
70697063 const body_len_index = if (is_multi_case) blk: {
70707064 payloads.items[multi_case_table + multi_case_index] = header_index;
70717065 multi_case_index += 1;
......@@ -7155,12 +7149,12 @@ fn switchExpr(
71557149 };
71567150 const body_len = refs_len + astgen.countBodyLenAfterFixups(case_slice);
71577151 try payloads.ensureUnusedCapacity(gpa, body_len);
7158 payloads.items[body_len_index] = @as(u32, @bitCast(Zir.Inst.SwitchBlock.ProngInfo{
7159 .body_len = @as(u28, @intCast(body_len)),
7152 payloads.items[body_len_index] = @bitCast(Zir.Inst.SwitchBlock.ProngInfo{
7153 .body_len = @intCast(body_len),
71607154 .capture = capture,
71617155 .is_inline = case.inline_token != null,
71627156 .has_tag_capture = has_tag_capture,
7163 }));
7157 });
71647158 if (astgen.ref_table.fetchRemove(switch_block)) |kv| {
71657159 appendPossiblyRefdBodyInst(astgen, payloads, kv.value);
71667160 }
......@@ -7188,7 +7182,7 @@ fn switchExpr(
71887182 .has_else = special_prong == .@"else",
71897183 .has_under = special_prong == .under,
71907184 .any_has_tag_capture = any_has_tag_capture,
7191 .scalar_cases_len = @as(Zir.Inst.SwitchBlock.Bits.ScalarCasesLen, @intCast(scalar_cases_len)),
7185 .scalar_cases_len = @intCast(scalar_cases_len),
71927186 },
71937187 });
71947188
......@@ -7473,7 +7467,7 @@ fn parseBitCount(buf: []const u8) std.fmt.ParseIntError!u16 {
74737467 };
74747468
74757469 if (x != 0) x = try std.math.mul(u16, x, 10);
7476 x = try std.math.add(u16, x, @as(u16, digit));
7470 x = try std.math.add(u16, x, digit);
74777471 }
74787472
74797473 return x;
......@@ -7687,7 +7681,7 @@ fn tunnelThroughClosure(
76877681 .src_tok = ns.?.declaring_gz.?.tokenIndexToRelative(token),
76887682 } },
76897683 });
7690 gop.value_ptr.* = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len - 1));
7684 gop.value_ptr.* = @intCast(gz.astgen.instructions.len - 1);
76917685 }
76927686
76937687 // Add an instruction to get the value from the closure into
......@@ -7767,7 +7761,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
77677761 const gpa = astgen.gpa;
77687762 var big_int = try std.math.big.int.Managed.init(gpa);
77697763 defer big_int.deinit();
7770 const prefix_offset = @as(u8, 2) * @intFromBool(base != .decimal);
7764 const prefix_offset: usize = if (base == .decimal) 0 else 2;
77717765 big_int.setString(@intFromEnum(base), bytes[prefix_offset..]) catch |err| switch (err) {
77727766 error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
77737767 error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
......@@ -7788,7 +7782,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
77887782 };
77897783 // If the value fits into a f64 without losing any precision, store it that way.
77907784 @setFloatMode(.Strict);
7791 const smaller_float = @as(f64, @floatCast(float_number));
7785 const smaller_float: f64 = @floatCast(float_number);
77927786 const bigger_again: f128 = smaller_float;
77937787 if (bigger_again == float_number) {
77947788 const result = try gz.addFloat(smaller_float);
......@@ -7796,12 +7790,12 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
77967790 }
77977791 // We need to use 128 bits. Break the float into 4 u32 values so we can
77987792 // put it into the `extra` array.
7799 const int_bits = @as(u128, @bitCast(float_number));
7793 const int_bits: u128 = @bitCast(float_number);
78007794 const result = try gz.addPlNode(.float128, node, Zir.Inst.Float128{
7801 .piece0 = @as(u32, @truncate(int_bits)),
7802 .piece1 = @as(u32, @truncate(int_bits >> 32)),
7803 .piece2 = @as(u32, @truncate(int_bits >> 64)),
7804 .piece3 = @as(u32, @truncate(int_bits >> 96)),
7795 .piece0 = @truncate(int_bits),
7796 .piece1 = @truncate(int_bits >> 32),
7797 .piece2 = @truncate(int_bits >> 64),
7798 .piece3 = @truncate(int_bits >> 96),
78057799 });
78067800 return rvalue(gz, ri, result, source_node);
78077801 },
......@@ -7827,22 +7821,22 @@ fn failWithNumberError(astgen: *AstGen, err: std.zig.number_literal.Error, token
78277821 });
78287822 },
78297823 .digit_after_base => return astgen.failTok(token, "expected a digit after base prefix", .{}),
7830 .upper_case_base => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "base prefix must be lowercase", .{}),
7831 .invalid_float_base => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "invalid base for float literal", .{}),
7832 .repeated_underscore => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "repeated digit separator", .{}),
7833 .invalid_underscore_after_special => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "expected digit before digit separator", .{}),
7834 .invalid_digit => |info| return astgen.failOff(token, @as(u32, @intCast(info.i)), "invalid digit '{c}' for {s} base", .{ bytes[info.i], @tagName(info.base) }),
7835 .invalid_digit_exponent => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "invalid digit '{c}' in exponent", .{bytes[i]}),
7836 .duplicate_exponent => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "duplicate exponent", .{}),
7837 .exponent_after_underscore => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "expected digit before exponent", .{}),
7838 .special_after_underscore => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "expected digit before '{c}'", .{bytes[i]}),
7839 .trailing_special => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "expected digit after '{c}'", .{bytes[i - 1]}),
7840 .trailing_underscore => |i| return astgen.failOff(token, @as(u32, @intCast(i)), "trailing digit separator", .{}),
7824 .upper_case_base => |i| return astgen.failOff(token, @intCast(i), "base prefix must be lowercase", .{}),
7825 .invalid_float_base => |i| return astgen.failOff(token, @intCast(i), "invalid base for float literal", .{}),
7826 .repeated_underscore => |i| return astgen.failOff(token, @intCast(i), "repeated digit separator", .{}),
7827 .invalid_underscore_after_special => |i| return astgen.failOff(token, @intCast(i), "expected digit before digit separator", .{}),
7828 .invalid_digit => |info| return astgen.failOff(token, @intCast(info.i), "invalid digit '{c}' for {s} base", .{ bytes[info.i], @tagName(info.base) }),
7829 .invalid_digit_exponent => |i| return astgen.failOff(token, @intCast(i), "invalid digit '{c}' in exponent", .{bytes[i]}),
7830 .duplicate_exponent => |i| return astgen.failOff(token, @intCast(i), "duplicate exponent", .{}),
7831 .exponent_after_underscore => |i| return astgen.failOff(token, @intCast(i), "expected digit before exponent", .{}),
7832 .special_after_underscore => |i| return astgen.failOff(token, @intCast(i), "expected digit before '{c}'", .{bytes[i]}),
7833 .trailing_special => |i| return astgen.failOff(token, @intCast(i), "expected digit after '{c}'", .{bytes[i - 1]}),
7834 .trailing_underscore => |i| return astgen.failOff(token, @intCast(i), "trailing digit separator", .{}),
78417835 .duplicate_period => unreachable, // Validated by tokenizer
78427836 .invalid_character => unreachable, // Validated by tokenizer
78437837 .invalid_exponent_sign => |i| {
78447838 assert(bytes.len >= 2 and bytes[0] == '0' and bytes[1] == 'x'); // Validated by tokenizer
7845 return astgen.failOff(token, @as(u32, @intCast(i)), "sign '{c}' cannot follow digit '{c}' in hex base", .{ bytes[i], bytes[i - 1] });
7839 return astgen.failOff(token, @intCast(i), "sign '{c}' cannot follow digit '{c}' in hex base", .{ bytes[i], bytes[i - 1] });
78467840 },
78477841 }
78487842}
......@@ -7909,7 +7903,7 @@ fn asmExpr(
79097903 if (output_type_bits != 0) {
79107904 return astgen.failNode(output_node, "inline assembly allows up to one output value", .{});
79117905 }
7912 output_type_bits |= @as(u32, 1) << @as(u5, @intCast(i));
7906 output_type_bits |= @as(u32, 1) << @intCast(i);
79137907 const out_type_node = node_datas[output_node].lhs;
79147908 const out_type_inst = try typeExpr(gz, scope, out_type_node);
79157909 outputs[i] = .{
......@@ -8132,7 +8126,7 @@ fn ptrCast(
81328126 node = node_datas[node].lhs;
81338127 }
81348128
8135 const flags_i = @as(u5, @bitCast(flags));
8129 const flags_i: u5 = @bitCast(flags);
81368130 assert(flags_i != 0);
81378131
81388132 const ptr_only: Zir.Inst.FullPtrCastFlags = .{ .ptr_cast = true };
......@@ -8219,8 +8213,8 @@ fn typeOf(
82198213 const body = typeof_scope.instructionsSlice();
82208214 const body_len = astgen.countBodyLenAfterFixups(body);
82218215 astgen.setExtra(payload_index, Zir.Inst.TypeOfPeer{
8222 .body_len = @as(u32, @intCast(body_len)),
8223 .body_index = @as(u32, @intCast(astgen.extra.items.len)),
8216 .body_len = @intCast(body_len),
8217 .body_index = @intCast(astgen.extra.items.len),
82248218 .src_node = gz.nodeIndexToRelative(node),
82258219 });
82268220 try astgen.extra.ensureUnusedCapacity(gpa, body_len);
......@@ -8579,7 +8573,7 @@ fn builtinCall(
85798573 .node = gz.nodeIndexToRelative(node),
85808574 .operand = operand,
85818575 });
8582 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
8576 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
85838577 gz.astgen.instructions.appendAssumeCapacity(.{
85848578 .tag = .extended,
85858579 .data = .{ .extended = .{
......@@ -9234,7 +9228,7 @@ fn callExpr(
92349228 }
92359229 assert(node != 0);
92369230
9237 const call_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
9231 const call_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
92389232 const call_inst = Zir.indexToRef(call_index);
92399233 try gz.astgen.instructions.append(astgen.gpa, undefined);
92409234 try gz.instructions.append(astgen.gpa, call_index);
......@@ -9258,7 +9252,7 @@ fn callExpr(
92589252 try astgen.scratch.ensureUnusedCapacity(astgen.gpa, countBodyLenAfterFixups(astgen, body));
92599253 appendBodyWithFixupsArrayList(astgen, &astgen.scratch, body);
92609254
9261 astgen.scratch.items[scratch_index] = @as(u32, @intCast(astgen.scratch.items.len - scratch_top));
9255 astgen.scratch.items[scratch_index] = @intCast(astgen.scratch.items.len - scratch_top);
92629256 scratch_index += 1;
92639257 }
92649258
......@@ -9276,8 +9270,8 @@ fn callExpr(
92769270 .callee = callee_obj,
92779271 .flags = .{
92789272 .pop_error_return_trace = !propagate_error_trace,
9279 .packed_modifier = @as(Zir.Inst.Call.Flags.PackedModifier, @intCast(@intFromEnum(modifier))),
9280 .args_len = @as(Zir.Inst.Call.Flags.PackedArgsLen, @intCast(call.ast.params.len)),
9273 .packed_modifier = @intCast(@intFromEnum(modifier)),
9274 .args_len = @intCast(call.ast.params.len),
92819275 },
92829276 });
92839277 if (call.ast.params.len != 0) {
......@@ -9297,8 +9291,8 @@ fn callExpr(
92979291 .field_name_start = callee_field.field_name_start,
92989292 .flags = .{
92999293 .pop_error_return_trace = !propagate_error_trace,
9300 .packed_modifier = @as(Zir.Inst.Call.Flags.PackedModifier, @intCast(@intFromEnum(modifier))),
9301 .args_len = @as(Zir.Inst.Call.Flags.PackedArgsLen, @intCast(call.ast.params.len)),
9294 .packed_modifier = @intCast(@intFromEnum(modifier)),
9295 .args_len = @intCast(call.ast.params.len),
93029296 },
93039297 });
93049298 if (call.ast.params.len != 0) {
......@@ -10773,14 +10767,14 @@ fn appendErrorNodeNotes(
1077310767) Allocator.Error!void {
1077410768 @setCold(true);
1077510769 const string_bytes = &astgen.string_bytes;
10776 const msg = @as(u32, @intCast(string_bytes.items.len));
10770 const msg: u32 = @intCast(string_bytes.items.len);
1077710771 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
1077810772 const notes_index: u32 = if (notes.len != 0) blk: {
1077910773 const notes_start = astgen.extra.items.len;
1078010774 try astgen.extra.ensureTotalCapacity(astgen.gpa, notes_start + 1 + notes.len);
10781 astgen.extra.appendAssumeCapacity(@as(u32, @intCast(notes.len)));
10775 astgen.extra.appendAssumeCapacity(@intCast(notes.len));
1078210776 astgen.extra.appendSliceAssumeCapacity(notes);
10783 break :blk @as(u32, @intCast(notes_start));
10777 break :blk @intCast(notes_start);
1078410778 } else 0;
1078510779 try astgen.compile_errors.append(astgen.gpa, .{
1078610780 .msg = msg,
......@@ -10865,14 +10859,14 @@ fn appendErrorTokNotesOff(
1086510859 @setCold(true);
1086610860 const gpa = astgen.gpa;
1086710861 const string_bytes = &astgen.string_bytes;
10868 const msg = @as(u32, @intCast(string_bytes.items.len));
10862 const msg: u32 = @intCast(string_bytes.items.len);
1086910863 try string_bytes.writer(gpa).print(format ++ "\x00", args);
1087010864 const notes_index: u32 = if (notes.len != 0) blk: {
1087110865 const notes_start = astgen.extra.items.len;
1087210866 try astgen.extra.ensureTotalCapacity(gpa, notes_start + 1 + notes.len);
10873 astgen.extra.appendAssumeCapacity(@as(u32, @intCast(notes.len)));
10867 astgen.extra.appendAssumeCapacity(@intCast(notes.len));
1087410868 astgen.extra.appendSliceAssumeCapacity(notes);
10875 break :blk @as(u32, @intCast(notes_start));
10869 break :blk @intCast(notes_start);
1087610870 } else 0;
1087710871 try astgen.compile_errors.append(gpa, .{
1087810872 .msg = msg,
......@@ -10901,7 +10895,7 @@ fn errNoteTokOff(
1090110895) Allocator.Error!u32 {
1090210896 @setCold(true);
1090310897 const string_bytes = &astgen.string_bytes;
10904 const msg = @as(u32, @intCast(string_bytes.items.len));
10898 const msg: u32 = @intCast(string_bytes.items.len);
1090510899 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
1090610900 return astgen.addExtra(Zir.Inst.CompileErrors.Item{
1090710901 .msg = msg,
......@@ -10920,7 +10914,7 @@ fn errNoteNode(
1092010914) Allocator.Error!u32 {
1092110915 @setCold(true);
1092210916 const string_bytes = &astgen.string_bytes;
10923 const msg = @as(u32, @intCast(string_bytes.items.len));
10917 const msg: u32 = @intCast(string_bytes.items.len);
1092410918 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
1092510919 return astgen.addExtra(Zir.Inst.CompileErrors.Item{
1092610920 .msg = msg,
......@@ -10934,7 +10928,7 @@ fn errNoteNode(
1093410928fn identAsString(astgen: *AstGen, ident_token: Ast.TokenIndex) !u32 {
1093510929 const gpa = astgen.gpa;
1093610930 const string_bytes = &astgen.string_bytes;
10937 const str_index = @as(u32, @intCast(string_bytes.items.len));
10931 const str_index: u32 = @intCast(string_bytes.items.len);
1093810932 try astgen.appendIdentStr(ident_token, string_bytes);
1093910933 const key: []const u8 = string_bytes.items[str_index..];
1094010934 const gop = try astgen.string_table.getOrPutContextAdapted(gpa, key, StringIndexAdapter{
......@@ -10956,7 +10950,7 @@ fn identAsString(astgen: *AstGen, ident_token: Ast.TokenIndex) !u32 {
1095610950/// `end_token` must point at the first token after the last doc coment line.
1095710951/// Returns 0 if no doc comment is present.
1095810952fn docCommentAsString(astgen: *AstGen, end_token: Ast.TokenIndex) !u32 {
10959 if (end_token == 0) return @as(u32, 0);
10953 if (end_token == 0) return 0;
1096010954
1096110955 const token_tags = astgen.tree.tokens.items(.tag);
1096210956
......@@ -10980,7 +10974,7 @@ fn docCommentAsStringFromFirst(
1098010974
1098110975 const gpa = astgen.gpa;
1098210976 const string_bytes = &astgen.string_bytes;
10983 const str_index = @as(u32, @intCast(string_bytes.items.len));
10977 const str_index: u32 = @intCast(string_bytes.items.len);
1098410978 const token_starts = astgen.tree.tokens.items(.start);
1098510979 const token_tags = astgen.tree.tokens.items(.tag);
1098610980
......@@ -11001,8 +10995,8 @@ fn docCommentAsStringFromFirst(
1100110995 }
1100210996 }
1100310997
11004 const key = string_bytes.items[str_index..];
11005 const gop = try astgen.string_table.getOrPutContextAdapted(gpa, @as([]const u8, key), StringIndexAdapter{
10998 const key: []const u8 = string_bytes.items[str_index..];
10999 const gop = try astgen.string_table.getOrPutContextAdapted(gpa, key, StringIndexAdapter{
1100611000 .bytes = string_bytes,
1100711001 }, StringIndexContext{
1100811002 .bytes = string_bytes,
......@@ -11023,11 +11017,11 @@ const IndexSlice = struct { index: u32, len: u32 };
1102311017fn strLitAsString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !IndexSlice {
1102411018 const gpa = astgen.gpa;
1102511019 const string_bytes = &astgen.string_bytes;
11026 const str_index = @as(u32, @intCast(string_bytes.items.len));
11020 const str_index: u32 = @intCast(string_bytes.items.len);
1102711021 const token_bytes = astgen.tree.tokenSlice(str_lit_token);
1102811022 try astgen.parseStrLit(str_lit_token, string_bytes, token_bytes, 0);
11029 const key = string_bytes.items[str_index..];
11030 const gop = try astgen.string_table.getOrPutContextAdapted(gpa, @as([]const u8, key), StringIndexAdapter{
11023 const key: []const u8 = string_bytes.items[str_index..];
11024 const gop = try astgen.string_table.getOrPutContextAdapted(gpa, key, StringIndexAdapter{
1103111025 .bytes = string_bytes,
1103211026 }, StringIndexContext{
1103311027 .bytes = string_bytes,
......@@ -11036,7 +11030,7 @@ fn strLitAsString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !IndexSlice {
1103611030 string_bytes.shrinkRetainingCapacity(str_index);
1103711031 return IndexSlice{
1103811032 .index = gop.key_ptr.*,
11039 .len = @as(u32, @intCast(key.len)),
11033 .len = @intCast(key.len),
1104011034 };
1104111035 } else {
1104211036 gop.key_ptr.* = str_index;
......@@ -11046,7 +11040,7 @@ fn strLitAsString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !IndexSlice {
1104611040 try string_bytes.append(gpa, 0);
1104711041 return IndexSlice{
1104811042 .index = str_index,
11049 .len = @as(u32, @intCast(key.len)),
11043 .len = @intCast(key.len),
1105011044 };
1105111045 }
1105211046}
......@@ -11083,15 +11077,15 @@ fn strLitNodeAsString(astgen: *AstGen, node: Ast.Node.Index) !IndexSlice {
1108311077 const len = string_bytes.items.len - str_index;
1108411078 try string_bytes.append(gpa, 0);
1108511079 return IndexSlice{
11086 .index = @as(u32, @intCast(str_index)),
11087 .len = @as(u32, @intCast(len)),
11080 .index = @intCast(str_index),
11081 .len = @intCast(len),
1108811082 };
1108911083}
1109011084
1109111085fn testNameString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !u32 {
1109211086 const gpa = astgen.gpa;
1109311087 const string_bytes = &astgen.string_bytes;
11094 const str_index = @as(u32, @intCast(string_bytes.items.len));
11088 const str_index: u32 = @intCast(string_bytes.items.len);
1109511089 const token_bytes = astgen.tree.tokenSlice(str_lit_token);
1109611090 try string_bytes.append(gpa, 0); // Indicates this is a test.
1109711091 try astgen.parseStrLit(str_lit_token, string_bytes, token_bytes, 0);
......@@ -11603,7 +11597,7 @@ const GenZir = struct {
1160311597 const astgen = gz.astgen;
1160411598 const gpa = astgen.gpa;
1160511599 const ret_ref = if (args.ret_ref == .void_type) .none else args.ret_ref;
11606 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
11600 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1160711601
1160811602 try astgen.instructions.ensureUnusedCapacity(gpa, 1);
1160911603
......@@ -11621,8 +11615,8 @@ const GenZir = struct {
1162111615 const block = node_datas[fn_decl].rhs;
1162211616 const rbrace_start = token_starts[tree.lastToken(block)];
1162311617 astgen.advanceSourceCursor(rbrace_start);
11624 const rbrace_line = @as(u32, @intCast(astgen.source_line - gz.decl_line));
11625 const rbrace_column = @as(u32, @intCast(astgen.source_column));
11618 const rbrace_line: u32 = @intCast(astgen.source_line - gz.decl_line);
11619 const rbrace_column: u32 = @intCast(astgen.source_column);
1162611620
1162711621 const columns = args.lbrace_column | (rbrace_column << 16);
1162811622 src_locs_buffer[0] = args.lbrace_line;
......@@ -11866,18 +11860,18 @@ const GenZir = struct {
1186611860 astgen.extra.appendAssumeCapacity(@intFromEnum(args.init));
1186711861 }
1186811862
11869 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
11863 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1187011864 astgen.instructions.appendAssumeCapacity(.{
1187111865 .tag = .extended,
1187211866 .data = .{ .extended = .{
1187311867 .opcode = .variable,
11874 .small = @as(u16, @bitCast(Zir.Inst.ExtendedVar.Small{
11868 .small = @bitCast(Zir.Inst.ExtendedVar.Small{
1187511869 .has_lib_name = args.lib_name != 0,
1187611870 .has_align = args.align_inst != .none,
1187711871 .has_init = args.init != .none,
1187811872 .is_extern = args.is_extern,
1187911873 .is_threadlocal = args.is_threadlocal,
11880 })),
11874 }),
1188111875 .operand = payload_index,
1188211876 } },
1188311877 });
......@@ -11897,7 +11891,7 @@ const GenZir = struct {
1189711891 try gz.instructions.ensureUnusedCapacity(gpa, 1);
1189811892 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
1189911893
11900 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
11894 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1190111895 gz.astgen.instructions.appendAssumeCapacity(.{
1190211896 .tag = tag,
1190311897 .data = .{ .bool_br = .{
......@@ -11923,12 +11917,12 @@ const GenZir = struct {
1192311917 try astgen.instructions.ensureUnusedCapacity(gpa, 1);
1192411918 try astgen.string_bytes.ensureUnusedCapacity(gpa, @sizeOf(std.math.big.Limb) * limbs.len);
1192511919
11926 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
11920 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1192711921 astgen.instructions.appendAssumeCapacity(.{
1192811922 .tag = .int_big,
1192911923 .data = .{ .str = .{
11930 .start = @as(u32, @intCast(astgen.string_bytes.items.len)),
11931 .len = @as(u32, @intCast(limbs.len)),
11924 .start = @intCast(astgen.string_bytes.items.len),
11925 .len = @intCast(limbs.len),
1193211926 } },
1193311927 });
1193411928 gz.instructions.appendAssumeCapacity(new_index);
......@@ -11968,7 +11962,7 @@ const GenZir = struct {
1196811962 src_node: Ast.Node.Index,
1196911963 ) !Zir.Inst.Index {
1197011964 assert(operand != .none);
11971 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
11965 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1197211966 try gz.astgen.instructions.append(gz.astgen.gpa, .{
1197311967 .tag = tag,
1197411968 .data = .{ .un_node = .{
......@@ -11991,7 +11985,7 @@ const GenZir = struct {
1199111985 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
1199211986
1199311987 const payload_index = try gz.astgen.addExtra(extra);
11994 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
11988 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1199511989 gz.astgen.instructions.appendAssumeCapacity(.{
1199611990 .tag = tag,
1199711991 .data = .{ .pl_node = .{
......@@ -12043,12 +12037,12 @@ const GenZir = struct {
1204312037 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Param{
1204412038 .name = name,
1204512039 .doc_comment = doc_comment_index,
12046 .body_len = @as(u32, @intCast(body_len)),
12040 .body_len = @intCast(body_len),
1204712041 });
1204812042 gz.astgen.appendBodyWithFixups(param_body);
1204912043 param_gz.unstack();
1205012044
12051 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12045 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1205212046 gz.astgen.instructions.appendAssumeCapacity(.{
1205312047 .tag = tag,
1205412048 .data = .{ .pl_tok = .{
......@@ -12076,7 +12070,7 @@ const GenZir = struct {
1207612070 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
1207712071
1207812072 const payload_index = try gz.astgen.addExtra(extra);
12079 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12073 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1208012074 gz.astgen.instructions.appendAssumeCapacity(.{
1208112075 .tag = .extended,
1208212076 .data = .{ .extended = .{
......@@ -12108,12 +12102,12 @@ const GenZir = struct {
1210812102 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{
1210912103 .src_node = gz.nodeIndexToRelative(node),
1211012104 });
12111 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
12105 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1211212106 astgen.instructions.appendAssumeCapacity(.{
1211312107 .tag = .extended,
1211412108 .data = .{ .extended = .{
1211512109 .opcode = opcode,
12116 .small = @as(u16, @intCast(operands.len)),
12110 .small = @intCast(operands.len),
1211712111 .operand = payload_index,
1211812112 } },
1211912113 });
......@@ -12133,12 +12127,12 @@ const GenZir = struct {
1213312127
1213412128 try gz.instructions.ensureUnusedCapacity(gpa, 1);
1213512129 try astgen.instructions.ensureUnusedCapacity(gpa, 1);
12136 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
12130 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1213712131 astgen.instructions.appendAssumeCapacity(.{
1213812132 .tag = .extended,
1213912133 .data = .{ .extended = .{
1214012134 .opcode = opcode,
12141 .small = @as(u16, @intCast(trailing_len)),
12135 .small = @intCast(trailing_len),
1214212136 .operand = payload_index,
1214312137 } },
1214412138 });
......@@ -12171,7 +12165,7 @@ const GenZir = struct {
1217112165 abs_tok_index: Ast.TokenIndex,
1217212166 ) !Zir.Inst.Index {
1217312167 const astgen = gz.astgen;
12174 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
12168 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1217512169 assert(operand != .none);
1217612170 try astgen.instructions.append(astgen.gpa, .{
1217712171 .tag = tag,
......@@ -12399,7 +12393,7 @@ const GenZir = struct {
1239912393 .data = .{ .extended = .{
1240012394 .opcode = opcode,
1240112395 .small = undefined,
12402 .operand = @as(u32, @bitCast(gz.nodeIndexToRelative(src_node))),
12396 .operand = @bitCast(gz.nodeIndexToRelative(src_node)),
1240312397 } },
1240412398 });
1240512399 }
......@@ -12423,8 +12417,8 @@ const GenZir = struct {
1242312417 try astgen.extra.ensureUnusedCapacity(
1242412418 gpa,
1242512419 @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len +
12426 @as(usize, @intFromBool(args.type_inst != .none)) +
12427 @as(usize, @intFromBool(args.align_inst != .none)),
12420 @intFromBool(args.type_inst != .none) +
12421 @intFromBool(args.align_inst != .none),
1242812422 );
1242912423 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.AllocExtended{
1243012424 .src_node = gz.nodeIndexToRelative(args.node),
......@@ -12442,7 +12436,7 @@ const GenZir = struct {
1244212436 const is_comptime: u4 = @intFromBool(args.is_comptime);
1244312437 const small: u16 = has_type | (has_align << 1) | (is_const << 2) | (is_comptime << 3);
1244412438
12445 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
12439 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1244612440 astgen.instructions.appendAssumeCapacity(.{
1244712441 .tag = .extended,
1244812442 .data = .{ .extended = .{
......@@ -12501,7 +12495,7 @@ const GenZir = struct {
1250112495 @as(u16, @intCast(args.clobbers.len << 10)) |
1250212496 (@as(u16, @intFromBool(args.is_volatile)) << 15);
1250312497
12504 const new_index = @as(Zir.Inst.Index, @intCast(astgen.instructions.len));
12498 const new_index: Zir.Inst.Index = @intCast(astgen.instructions.len);
1250512499 astgen.instructions.appendAssumeCapacity(.{
1250612500 .tag = .extended,
1250712501 .data = .{ .extended = .{
......@@ -12518,7 +12512,7 @@ const GenZir = struct {
1251812512 /// Does *not* append the block instruction to the scope.
1251912513 /// Leaves the `payload_index` field undefined.
1252012514 fn makeBlockInst(gz: *GenZir, tag: Zir.Inst.Tag, node: Ast.Node.Index) !Zir.Inst.Index {
12521 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12515 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1252212516 const gpa = gz.astgen.gpa;
1252312517 try gz.astgen.instructions.append(gpa, .{
1252412518 .tag = tag,
......@@ -12535,7 +12529,7 @@ const GenZir = struct {
1253512529 fn addCondBr(gz: *GenZir, tag: Zir.Inst.Tag, node: Ast.Node.Index) !Zir.Inst.Index {
1253612530 const gpa = gz.astgen.gpa;
1253712531 try gz.instructions.ensureUnusedCapacity(gpa, 1);
12538 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12532 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1253912533 try gz.astgen.instructions.append(gpa, .{
1254012534 .tag = tag,
1254112535 .data = .{ .pl_node = .{
......@@ -12562,11 +12556,11 @@ const GenZir = struct {
1256212556 const gpa = astgen.gpa;
1256312557
1256412558 try astgen.extra.ensureUnusedCapacity(gpa, 6);
12565 const payload_index = @as(u32, @intCast(astgen.extra.items.len));
12559 const payload_index: u32 = @intCast(astgen.extra.items.len);
1256612560
1256712561 if (args.src_node != 0) {
1256812562 const node_offset = gz.nodeIndexToRelative(args.src_node);
12569 astgen.extra.appendAssumeCapacity(@as(u32, @bitCast(node_offset)));
12563 astgen.extra.appendAssumeCapacity(@bitCast(node_offset));
1257012564 }
1257112565 if (args.fields_len != 0) {
1257212566 astgen.extra.appendAssumeCapacity(args.fields_len);
......@@ -12584,7 +12578,7 @@ const GenZir = struct {
1258412578 .tag = .extended,
1258512579 .data = .{ .extended = .{
1258612580 .opcode = .struct_decl,
12587 .small = @as(u16, @bitCast(Zir.Inst.StructDecl.Small{
12581 .small = @bitCast(Zir.Inst.StructDecl.Small{
1258812582 .has_src_node = args.src_node != 0,
1258912583 .has_fields_len = args.fields_len != 0,
1259012584 .has_decls_len = args.decls_len != 0,
......@@ -12594,7 +12588,7 @@ const GenZir = struct {
1259412588 .is_tuple = args.is_tuple,
1259512589 .name_strategy = gz.anon_name_strategy,
1259612590 .layout = args.layout,
12597 })),
12591 }),
1259812592 .operand = payload_index,
1259912593 } },
1260012594 });
......@@ -12613,11 +12607,11 @@ const GenZir = struct {
1261312607 const gpa = astgen.gpa;
1261412608
1261512609 try astgen.extra.ensureUnusedCapacity(gpa, 5);
12616 const payload_index = @as(u32, @intCast(astgen.extra.items.len));
12610 const payload_index: u32 = @intCast(astgen.extra.items.len);
1261712611
1261812612 if (args.src_node != 0) {
1261912613 const node_offset = gz.nodeIndexToRelative(args.src_node);
12620 astgen.extra.appendAssumeCapacity(@as(u32, @bitCast(node_offset)));
12614 astgen.extra.appendAssumeCapacity(@bitCast(node_offset));
1262112615 }
1262212616 if (args.tag_type != .none) {
1262312617 astgen.extra.appendAssumeCapacity(@intFromEnum(args.tag_type));
......@@ -12635,7 +12629,7 @@ const GenZir = struct {
1263512629 .tag = .extended,
1263612630 .data = .{ .extended = .{
1263712631 .opcode = .union_decl,
12638 .small = @as(u16, @bitCast(Zir.Inst.UnionDecl.Small{
12632 .small = @bitCast(Zir.Inst.UnionDecl.Small{
1263912633 .has_src_node = args.src_node != 0,
1264012634 .has_tag_type = args.tag_type != .none,
1264112635 .has_body_len = args.body_len != 0,
......@@ -12644,7 +12638,7 @@ const GenZir = struct {
1264412638 .name_strategy = gz.anon_name_strategy,
1264512639 .layout = args.layout,
1264612640 .auto_enum_tag = args.auto_enum_tag,
12647 })),
12641 }),
1264812642 .operand = payload_index,
1264912643 } },
1265012644 });
......@@ -12662,11 +12656,11 @@ const GenZir = struct {
1266212656 const gpa = astgen.gpa;
1266312657
1266412658 try astgen.extra.ensureUnusedCapacity(gpa, 5);
12665 const payload_index = @as(u32, @intCast(astgen.extra.items.len));
12659 const payload_index: u32 = @intCast(astgen.extra.items.len);
1266612660
1266712661 if (args.src_node != 0) {
1266812662 const node_offset = gz.nodeIndexToRelative(args.src_node);
12669 astgen.extra.appendAssumeCapacity(@as(u32, @bitCast(node_offset)));
12663 astgen.extra.appendAssumeCapacity(@bitCast(node_offset));
1267012664 }
1267112665 if (args.tag_type != .none) {
1267212666 astgen.extra.appendAssumeCapacity(@intFromEnum(args.tag_type));
......@@ -12684,7 +12678,7 @@ const GenZir = struct {
1268412678 .tag = .extended,
1268512679 .data = .{ .extended = .{
1268612680 .opcode = .enum_decl,
12687 .small = @as(u16, @bitCast(Zir.Inst.EnumDecl.Small{
12681 .small = @bitCast(Zir.Inst.EnumDecl.Small{
1268812682 .has_src_node = args.src_node != 0,
1268912683 .has_tag_type = args.tag_type != .none,
1269012684 .has_body_len = args.body_len != 0,
......@@ -12692,7 +12686,7 @@ const GenZir = struct {
1269212686 .has_decls_len = args.decls_len != 0,
1269312687 .name_strategy = gz.anon_name_strategy,
1269412688 .nonexhaustive = args.nonexhaustive,
12695 })),
12689 }),
1269612690 .operand = payload_index,
1269712691 } },
1269812692 });
......@@ -12706,11 +12700,11 @@ const GenZir = struct {
1270612700 const gpa = astgen.gpa;
1270712701
1270812702 try astgen.extra.ensureUnusedCapacity(gpa, 2);
12709 const payload_index = @as(u32, @intCast(astgen.extra.items.len));
12703 const payload_index: u32 = @intCast(astgen.extra.items.len);
1271012704
1271112705 if (args.src_node != 0) {
1271212706 const node_offset = gz.nodeIndexToRelative(args.src_node);
12713 astgen.extra.appendAssumeCapacity(@as(u32, @bitCast(node_offset)));
12707 astgen.extra.appendAssumeCapacity(@bitCast(node_offset));
1271412708 }
1271512709 if (args.decls_len != 0) {
1271612710 astgen.extra.appendAssumeCapacity(args.decls_len);
......@@ -12719,11 +12713,11 @@ const GenZir = struct {
1271912713 .tag = .extended,
1272012714 .data = .{ .extended = .{
1272112715 .opcode = .opaque_decl,
12722 .small = @as(u16, @bitCast(Zir.Inst.OpaqueDecl.Small{
12716 .small = @bitCast(Zir.Inst.OpaqueDecl.Small{
1272312717 .has_src_node = args.src_node != 0,
1272412718 .has_decls_len = args.decls_len != 0,
1272512719 .name_strategy = gz.anon_name_strategy,
12726 })),
12720 }),
1272712721 .operand = payload_index,
1272812722 } },
1272912723 });
......@@ -12738,7 +12732,7 @@ const GenZir = struct {
1273812732 try gz.instructions.ensureUnusedCapacity(gpa, 1);
1273912733 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
1274012734
12741 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12735 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1274212736 gz.astgen.instructions.appendAssumeCapacity(inst);
1274312737 gz.instructions.appendAssumeCapacity(new_index);
1274412738 return new_index;
......@@ -12749,7 +12743,7 @@ const GenZir = struct {
1274912743 try gz.instructions.ensureUnusedCapacity(gpa, 1);
1275012744 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
1275112745
12752 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12746 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1275312747 gz.astgen.instructions.len += 1;
1275412748 gz.instructions.appendAssumeCapacity(new_index);
1275512749 return new_index;
......@@ -12801,7 +12795,7 @@ const GenZir = struct {
1280112795 return;
1280212796 }
1280312797
12804 const new_index = @as(Zir.Inst.Index, @intCast(gz.astgen.instructions.len));
12798 const new_index: Zir.Inst.Index = @intCast(gz.astgen.instructions.len);
1280512799 try gz.astgen.instructions.append(gpa, .{ .tag = .dbg_block_end, .data = undefined });
1280612800 try gz.instructions.append(gpa, new_index);
1280712801 }
......@@ -12810,7 +12804,7 @@ const GenZir = struct {
1281012804/// This can only be for short-lived references; the memory becomes invalidated
1281112805/// when another string is added.
1281212806fn nullTerminatedString(astgen: AstGen, index: usize) [*:0]const u8 {
12813 return @as([*:0]const u8, @ptrCast(astgen.string_bytes.items.ptr)) + index;
12807 return @ptrCast(astgen.string_bytes.items[index..]);
1281412808}
1281512809
1281612810/// Local variables shadowing detection, including function parameters.
......@@ -13089,7 +13083,7 @@ fn isInferred(astgen: *AstGen, ref: Zir.Inst.Ref) bool {
1308913083 .extended => {
1309013084 const zir_data = astgen.instructions.items(.data);
1309113085 if (zir_data[inst].extended.opcode != .alloc) return false;
13092 const small = @as(Zir.Inst.AllocExtended.Small, @bitCast(zir_data[inst].extended.small));
13086 const small: Zir.Inst.AllocExtended.Small = @bitCast(zir_data[inst].extended.small);
1309313087 return !small.has_type;
1309413088 },
1309513089
......@@ -13133,7 +13127,7 @@ fn countBodyLenAfterFixups(astgen: *AstGen, body: []const Zir.Inst.Index) u32 {
1313313127 check_inst = ref_inst;
1313413128 }
1313513129 }
13136 return @as(u32, @intCast(count));
13130 return @intCast(count);
1313713131}
1313813132
1313913133fn emitDbgStmt(gz: *GenZir, lc: LineColumn) !void {
......@@ -13165,7 +13159,7 @@ fn lowerAstErrors(astgen: *AstGen) !void {
1316513159
1316613160 if (token_tags[parse_err.token + @intFromBool(parse_err.token_is_prev)] == .invalid) {
1316713161 const tok = parse_err.token + @intFromBool(parse_err.token_is_prev);
13168 const bad_off = @as(u32, @intCast(tree.tokenSlice(parse_err.token + @intFromBool(parse_err.token_is_prev)).len));
13162 const bad_off: u32 = @intCast(tree.tokenSlice(parse_err.token + @intFromBool(parse_err.token_is_prev)).len);
1316913163 const byte_abs = token_starts[parse_err.token + @intFromBool(parse_err.token_is_prev)] + bad_off;
1317013164 try notes.append(gpa, try astgen.errNoteTokOff(tok, bad_off, "invalid byte: '{'}'", .{
1317113165 std.zig.fmtEscapes(tree.source[byte_abs..][0..1]),
src/Zir.zig+20-20
......@@ -78,12 +78,13 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {
7878 inline for (fields) |field| {
7979 @field(result, field.name) = switch (field.type) {
8080 u32 => code.extra[i],
81 Inst.Ref => @as(Inst.Ref, @enumFromInt(code.extra[i])),
82 i32 => @as(i32, @bitCast(code.extra[i])),
83 Inst.Call.Flags => @as(Inst.Call.Flags, @bitCast(code.extra[i])),
84 Inst.BuiltinCall.Flags => @as(Inst.BuiltinCall.Flags, @bitCast(code.extra[i])),
85 Inst.SwitchBlock.Bits => @as(Inst.SwitchBlock.Bits, @bitCast(code.extra[i])),
86 Inst.FuncFancy.Bits => @as(Inst.FuncFancy.Bits, @bitCast(code.extra[i])),
81 Inst.Ref => @enumFromInt(code.extra[i]),
82 i32,
83 Inst.Call.Flags,
84 Inst.BuiltinCall.Flags,
85 Inst.SwitchBlock.Bits,
86 Inst.FuncFancy.Bits,
87 => @bitCast(code.extra[i]),
8788 else => @compileError("bad field type"),
8889 };
8990 i += 1;
......@@ -115,8 +116,7 @@ pub fn nullTerminatedString2(code: Zir, index: NullTerminatedString) [:0]const u
115116}
116117
117118pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref {
118 const raw_slice = code.extra[start..][0..len];
119 return @as([]Inst.Ref, @ptrCast(raw_slice));
119 return @ptrCast(code.extra[start..][0..len]);
120120}
121121
122122pub fn hasCompileErrors(code: Zir) bool {
......@@ -3266,10 +3266,10 @@ pub const DeclIterator = struct {
32663266 }
32673267 it.decl_i += 1;
32683268
3269 const flags = @as(u4, @truncate(it.cur_bit_bag));
3269 const flags: u4 = @truncate(it.cur_bit_bag);
32703270 it.cur_bit_bag >>= 4;
32713271
3272 const sub_index = @as(u32, @intCast(it.extra_index));
3272 const sub_index: u32 = @intCast(it.extra_index);
32733273 it.extra_index += 5; // src_hash(4) + line(1)
32743274 const name = it.zir.nullTerminatedString(it.zir.extra[it.extra_index]);
32753275 it.extra_index += 3; // name(1) + value(1) + doc_comment(1)
......@@ -3296,7 +3296,7 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
32963296 const extended = datas[decl_inst].extended;
32973297 switch (extended.opcode) {
32983298 .struct_decl => {
3299 const small = @as(Inst.StructDecl.Small, @bitCast(extended.small));
3299 const small: Inst.StructDecl.Small = @bitCast(extended.small);
33003300 var extra_index: usize = extended.operand;
33013301 extra_index += @intFromBool(small.has_src_node);
33023302 extra_index += @intFromBool(small.has_fields_len);
......@@ -3319,7 +3319,7 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
33193319 return declIteratorInner(zir, extra_index, decls_len);
33203320 },
33213321 .enum_decl => {
3322 const small = @as(Inst.EnumDecl.Small, @bitCast(extended.small));
3322 const small: Inst.EnumDecl.Small = @bitCast(extended.small);
33233323 var extra_index: usize = extended.operand;
33243324 extra_index += @intFromBool(small.has_src_node);
33253325 extra_index += @intFromBool(small.has_tag_type);
......@@ -3334,7 +3334,7 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
33343334 return declIteratorInner(zir, extra_index, decls_len);
33353335 },
33363336 .union_decl => {
3337 const small = @as(Inst.UnionDecl.Small, @bitCast(extended.small));
3337 const small: Inst.UnionDecl.Small = @bitCast(extended.small);
33383338 var extra_index: usize = extended.operand;
33393339 extra_index += @intFromBool(small.has_src_node);
33403340 extra_index += @intFromBool(small.has_tag_type);
......@@ -3349,7 +3349,7 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
33493349 return declIteratorInner(zir, extra_index, decls_len);
33503350 },
33513351 .opaque_decl => {
3352 const small = @as(Inst.OpaqueDecl.Small, @bitCast(extended.small));
3352 const small: Inst.OpaqueDecl.Small = @bitCast(extended.small);
33533353 var extra_index: usize = extended.operand;
33543354 extra_index += @intFromBool(small.has_src_node);
33553355 const decls_len = if (small.has_decls_len) decls_len: {
......@@ -3545,7 +3545,7 @@ fn findDeclsSwitch(
35453545
35463546 const special_prong = extra.data.bits.specialProng();
35473547 if (special_prong != .none) {
3548 const body_len = @as(u31, @truncate(zir.extra[extra_index]));
3548 const body_len: u31 = @truncate(zir.extra[extra_index]);
35493549 extra_index += 1;
35503550 const body = zir.extra[extra_index..][0..body_len];
35513551 extra_index += body.len;
......@@ -3558,7 +3558,7 @@ fn findDeclsSwitch(
35583558 var scalar_i: usize = 0;
35593559 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
35603560 extra_index += 1;
3561 const body_len = @as(u31, @truncate(zir.extra[extra_index]));
3561 const body_len: u31 = @truncate(zir.extra[extra_index]);
35623562 extra_index += 1;
35633563 const body = zir.extra[extra_index..][0..body_len];
35643564 extra_index += body_len;
......@@ -3573,7 +3573,7 @@ fn findDeclsSwitch(
35733573 extra_index += 1;
35743574 const ranges_len = zir.extra[extra_index];
35753575 extra_index += 1;
3576 const body_len = @as(u31, @truncate(zir.extra[extra_index]));
3576 const body_len: u31 = @truncate(zir.extra[extra_index]);
35773577 extra_index += 1;
35783578 const items = zir.refSlice(extra_index, items_len);
35793579 extra_index += items_len;
......@@ -3655,7 +3655,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
36553655 ret_ty_ref = .void_type;
36563656 },
36573657 1 => {
3658 ret_ty_ref = @as(Inst.Ref, @enumFromInt(zir.extra[extra_index]));
3658 ret_ty_ref = @enumFromInt(zir.extra[extra_index]);
36593659 extra_index += 1;
36603660 },
36613661 else => {
......@@ -3709,7 +3709,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
37093709 ret_ty_body = zir.extra[extra_index..][0..body_len];
37103710 extra_index += ret_ty_body.len;
37113711 } else if (extra.data.bits.has_ret_ty_ref) {
3712 ret_ty_ref = @as(Inst.Ref, @enumFromInt(zir.extra[extra_index]));
3712 ret_ty_ref = @enumFromInt(zir.extra[extra_index]);
37133713 extra_index += 1;
37143714 }
37153715
......@@ -3753,7 +3753,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
37533753pub const ref_start_index: u32 = InternPool.static_len;
37543754
37553755pub fn indexToRef(inst: Inst.Index) Inst.Ref {
3756 return @as(Inst.Ref, @enumFromInt(ref_start_index + inst));
3756 return @enumFromInt(ref_start_index + inst);
37573757}
37583758
37593759pub fn refToIndex(inst: Inst.Ref) ?Inst.Index {