authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-26 16:39:18-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-28 17:25:39-04:00
log70e0d8170fe3de3e9be86813fc6baff013b352b4
tree6a394539defd60f9a8d5c456faf05153e7f30f45
parentb8e6c426887e92cc5a841a7dd58eb10ebfbe0d77

Sema: cleanup `@as` invasion


1 files changed, 257 insertions(+), 249 deletions(-)

src/Sema.zig+257-249
......@@ -269,7 +269,7 @@ pub const InstMap = struct {
269269 while (true) {
270270 const extra_capacity = better_capacity / 2 + 16;
271271 better_capacity += extra_capacity;
272 better_start -|= @as(Zir.Inst.Index, @intCast(extra_capacity / 2));
272 better_start -|= @intCast(extra_capacity / 2);
273273 if (better_start <= start and end < better_capacity + better_start)
274274 break;
275275 }
......@@ -282,7 +282,7 @@ pub const InstMap = struct {
282282
283283 allocator.free(map.items);
284284 map.items = new_items;
285 map.start = @as(Zir.Inst.Index, @intCast(better_start));
285 map.start = @intCast(better_start);
286286 }
287287};
288288
......@@ -681,7 +681,7 @@ pub const Block = struct {
681681 const sema = block.sema;
682682 const ty_ref = Air.internedToRef(aggregate_ty.toIntern());
683683 try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements.len);
684 const extra_index = @as(u32, @intCast(sema.air_extra.items.len));
684 const extra_index: u32 = @intCast(sema.air_extra.items.len);
685685 sema.appendRefsAssumeCapacity(elements);
686686
687687 return block.addInst(.{
......@@ -722,7 +722,7 @@ pub const Block = struct {
722722 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);
723723 try block.instructions.ensureUnusedCapacity(gpa, 1);
724724
725 const result_index = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
725 const result_index: Air.Inst.Index = @intCast(sema.air_instructions.len);
726726 sema.air_instructions.appendAssumeCapacity(inst);
727727 block.instructions.appendAssumeCapacity(result_index);
728728 return result_index;
......@@ -740,7 +740,7 @@ pub const Block = struct {
740740
741741 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);
742742
743 const result_index = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
743 const result_index: Air.Inst.Index = @intCast(sema.air_instructions.len);
744744 sema.air_instructions.appendAssumeCapacity(inst);
745745
746746 try block.instructions.insert(gpa, index, result_index);
......@@ -1819,7 +1819,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
18191819 const i = @intFromEnum(zir_ref);
18201820 // First section of indexes correspond to a set number of constant values.
18211821 // We intentionally map the same indexes to the same values between ZIR and AIR.
1822 if (i < InternPool.static_len) return @as(Air.Inst.Ref, @enumFromInt(i));
1822 if (i < InternPool.static_len) return @enumFromInt(i);
18231823 // The last section of indexes refers to the map of ZIR => AIR.
18241824 const inst = sema.inst_map.get(i - InternPool.static_len).?;
18251825 if (inst == .generic_poison) return error.GenericPoison;
......@@ -2508,7 +2508,7 @@ fn analyzeAsAlign(
25082508 air_ref: Air.Inst.Ref,
25092509) !Alignment {
25102510 const alignment_big = try sema.analyzeAsInt(block, src, air_ref, align_ty, "alignment must be comptime-known");
2511 const alignment = @as(u32, @intCast(alignment_big)); // We coerce to u29 in the prev line.
2511 const alignment: u32 = @intCast(alignment_big); // We coerce to u29 in the prev line.
25122512 try sema.validateAlign(block, src, alignment);
25132513 return Alignment.fromNonzeroByteUnits(alignment);
25142514}
......@@ -2815,7 +2815,7 @@ pub fn analyzeStructDecl(
28152815 const struct_obj = mod.structPtr(struct_index);
28162816 const extended = sema.code.instructions.items(.data)[inst].extended;
28172817 assert(extended.opcode == .struct_decl);
2818 const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small));
2818 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
28192819
28202820 struct_obj.known_non_opv = small.known_non_opv;
28212821 if (small.known_comptime_only) {
......@@ -2852,9 +2852,9 @@ fn zirStructDecl(
28522852) CompileError!Air.Inst.Ref {
28532853 const mod = sema.mod;
28542854 const gpa = sema.gpa;
2855 const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small));
2855 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
28562856 const src: LazySrcLoc = if (small.has_src_node) blk: {
2857 const node_offset = @as(i32, @bitCast(sema.code.extra[extended.operand]));
2857 const node_offset: i32 = @bitCast(sema.code.extra[extended.operand]);
28582858 break :blk LazySrcLoc.nodeOffset(node_offset);
28592859 } else sema.src;
28602860
......@@ -3218,7 +3218,7 @@ fn zirEnumDecl(
32183218 }
32193219
32203220 const tag_overflow = if (has_tag_value) overflow: {
3221 const tag_val_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
3221 const tag_val_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
32223222 extra_index += 1;
32233223 const tag_inst = try sema.resolveInst(tag_val_ref);
32243224 last_tag_val = sema.resolveConstValue(block, .unneeded, tag_inst, "") catch |err| switch (err) {
......@@ -3300,11 +3300,11 @@ fn zirUnionDecl(
33003300
33013301 const mod = sema.mod;
33023302 const gpa = sema.gpa;
3303 const small = @as(Zir.Inst.UnionDecl.Small, @bitCast(extended.small));
3303 const small: Zir.Inst.UnionDecl.Small = @bitCast(extended.small);
33043304 var extra_index: usize = extended.operand;
33053305
33063306 const src: LazySrcLoc = if (small.has_src_node) blk: {
3307 const node_offset = @as(i32, @bitCast(sema.code.extra[extra_index]));
3307 const node_offset: i32 = @bitCast(sema.code.extra[extra_index]);
33083308 extra_index += 1;
33093309 break :blk LazySrcLoc.nodeOffset(node_offset);
33103310 } else sema.src;
......@@ -3398,11 +3398,11 @@ fn zirOpaqueDecl(
33983398 defer tracy.end();
33993399
34003400 const mod = sema.mod;
3401 const small = @as(Zir.Inst.OpaqueDecl.Small, @bitCast(extended.small));
3401 const small: Zir.Inst.OpaqueDecl.Small = @bitCast(extended.small);
34023402 var extra_index: usize = extended.operand;
34033403
34043404 const src: LazySrcLoc = if (small.has_src_node) blk: {
3405 const node_offset = @as(i32, @bitCast(sema.code.extra[extra_index]));
3405 const node_offset: i32 = @bitCast(sema.code.extra[extra_index]);
34063406 extra_index += 1;
34073407 break :blk LazySrcLoc.nodeOffset(node_offset);
34083408 } else sema.src;
......@@ -3469,7 +3469,7 @@ fn zirErrorSetDecl(
34693469 var names: InferredErrorSet.NameMap = .{};
34703470 try names.ensureUnusedCapacity(sema.arena, extra.data.fields_len);
34713471
3472 var extra_index = @as(u32, @intCast(extra.end));
3472 var extra_index: u32 = @intCast(extra.end);
34733473 const extra_index_end = extra_index + (extra.data.fields_len * 2);
34743474 while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string
34753475 const str_index = sema.code.extra[extra_index];
......@@ -3669,18 +3669,18 @@ fn zirAllocExtended(
36693669 const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand);
36703670 const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = extra.data.src_node };
36713671 const align_src: LazySrcLoc = .{ .node_offset_var_decl_align = extra.data.src_node };
3672 const small = @as(Zir.Inst.AllocExtended.Small, @bitCast(extended.small));
3672 const small: Zir.Inst.AllocExtended.Small = @bitCast(extended.small);
36733673
36743674 var extra_index: usize = extra.end;
36753675
36763676 const var_ty: Type = if (small.has_type) blk: {
3677 const type_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
3677 const type_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
36783678 extra_index += 1;
36793679 break :blk try sema.resolveType(block, ty_src, type_ref);
36803680 } else undefined;
36813681
36823682 const alignment = if (small.has_align) blk: {
3683 const align_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
3683 const align_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
36843684 extra_index += 1;
36853685 const alignment = try sema.resolveAlign(block, align_src, align_ref);
36863686 break :blk alignment;
......@@ -3698,7 +3698,7 @@ fn zirAllocExtended(
36983698 .is_const = small.is_const,
36993699 } },
37003700 });
3701 return Air.indexToRef(@as(u32, @intCast(sema.air_instructions.len - 1)));
3701 return Air.indexToRef(@intCast(sema.air_instructions.len - 1));
37023702 }
37033703 }
37043704
......@@ -3830,7 +3830,7 @@ fn zirAllocInferredComptime(
38303830 .is_const = is_const,
38313831 } },
38323832 });
3833 return Air.indexToRef(@as(u32, @intCast(sema.air_instructions.len - 1)));
3833 return Air.indexToRef(@intCast(sema.air_instructions.len - 1));
38343834}
38353835
38363836fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
......@@ -3895,7 +3895,7 @@ fn zirAllocInferred(
38953895 .is_const = is_const,
38963896 } },
38973897 });
3898 return Air.indexToRef(@as(u32, @intCast(sema.air_instructions.len - 1)));
3898 return Air.indexToRef(@intCast(sema.air_instructions.len - 1));
38993899 }
39003900
39013901 const result_index = try block.addInstAsIndex(.{
......@@ -4147,7 +4147,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
41474147 .data = .{ .ty_pl = .{
41484148 .ty = ty_inst,
41494149 .payload = sema.addExtraAssumeCapacity(Air.Block{
4150 .body_len = @as(u32, @intCast(replacement_block.instructions.items.len)),
4150 .body_len = @intCast(replacement_block.instructions.items.len),
41514151 }),
41524152 } },
41534153 });
......@@ -4231,7 +4231,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
42314231
42324232 // First pass to look for comptime values.
42334233 for (args, 0..) |zir_arg, i_usize| {
4234 const i = @as(u32, @intCast(i_usize));
4234 const i: u32 = @intCast(i_usize);
42354235 runtime_arg_lens[i] = .none;
42364236 if (zir_arg == .none) continue;
42374237 const object = try sema.resolveInst(zir_arg);
......@@ -4302,7 +4302,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
43024302 const msg = try sema.errMsg(block, src, "unbounded for loop", .{});
43034303 errdefer msg.destroy(gpa);
43044304 for (args, 0..) |zir_arg, i_usize| {
4305 const i = @as(u32, @intCast(i_usize));
4305 const i: u32 = @intCast(i_usize);
43064306 if (zir_arg == .none) continue;
43074307 const object = try sema.resolveInst(zir_arg);
43084308 const object_ty = sema.typeOf(object);
......@@ -4705,9 +4705,9 @@ fn validateStructInit(
47054705
47064706 const field_src = init_src; // TODO better source location
47074707 const default_field_ptr = if (struct_ty.isTuple(mod))
4708 try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @as(u32, @intCast(i)), true)
4708 try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @intCast(i), true)
47094709 else
4710 try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @as(u32, @intCast(i)), field_src, struct_ty, true);
4710 try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @intCast(i), field_src, struct_ty, true);
47114711 const init = Air.internedToRef(default_val.toIntern());
47124712 try sema.storePtr2(block, init_src, default_field_ptr, init_src, init, field_src, .store);
47134713 }
......@@ -4911,9 +4911,9 @@ fn validateStructInit(
49114911
49124912 const field_src = init_src; // TODO better source location
49134913 const default_field_ptr = if (struct_ty.isTuple(mod))
4914 try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @as(u32, @intCast(i)), true)
4914 try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @intCast(i), true)
49154915 else
4916 try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @as(u32, @intCast(i)), field_src, struct_ty, true);
4916 try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @intCast(i), field_src, struct_ty, true);
49174917 const init = Air.internedToRef(field_values[i]);
49184918 try sema.storePtr2(block, init_src, default_field_ptr, init_src, init, field_src, .store);
49194919 }
......@@ -5337,7 +5337,7 @@ fn storeToInferredAllocComptime(
53375337fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
53385338 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
53395339 const src = inst_data.src();
5340 const quota = @as(u32, @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime-known")));
5340 const quota: u32 = @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime-known"));
53415341 sema.branch_quota = @max(sema.branch_quota, quota);
53425342}
53435343
......@@ -5558,7 +5558,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError
55585558 // Reserve space for a Loop instruction so that generated Break instructions can
55595559 // point to it, even if it doesn't end up getting used because the code ends up being
55605560 // comptime evaluated.
5561 const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
5561 const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
55625562 const loop_inst = block_inst + 1;
55635563 try sema.air_instructions.ensureUnusedCapacity(gpa, 2);
55645564 sema.air_instructions.appendAssumeCapacity(.{
......@@ -5606,7 +5606,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError
56065606
56075607 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + loop_block_len);
56085608 sema.air_instructions.items(.data)[loop_inst].ty_pl.payload = sema.addExtraAssumeCapacity(
5609 Air.Block{ .body_len = @as(u32, @intCast(loop_block_len)) },
5609 Air.Block{ .body_len = @intCast(loop_block_len) },
56105610 );
56115611 sema.air_extra.appendSliceAssumeCapacity(loop_block.instructions.items);
56125612 }
......@@ -5756,7 +5756,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index, force_compt
57565756 // Reserve space for a Block instruction so that generated Break instructions can
57575757 // point to it, even if it doesn't end up getting used because the code ends up being
57585758 // comptime evaluated or is an unlabeled block.
5759 const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
5759 const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
57605760 try sema.air_instructions.append(gpa, .{
57615761 .tag = .block,
57625762 .data = undefined,
......@@ -5902,7 +5902,7 @@ fn analyzeBlockBody(
59025902 sema.air_instructions.items(.data)[merges.block_inst] = .{ .ty_pl = .{
59035903 .ty = ty_inst,
59045904 .payload = sema.addExtraAssumeCapacity(Air.Block{
5905 .body_len = @as(u32, @intCast(child_block.instructions.items.len)),
5905 .body_len = @intCast(child_block.instructions.items.len),
59065906 }),
59075907 } };
59085908 sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items);
......@@ -5929,11 +5929,11 @@ fn analyzeBlockBody(
59295929
59305930 // Convert the br instruction to a block instruction that has the coercion
59315931 // and then a new br inside that returns the coerced instruction.
5932 const sub_block_len = @as(u32, @intCast(coerce_block.instructions.items.len + 1));
5932 const sub_block_len: u32 = @intCast(coerce_block.instructions.items.len + 1);
59335933 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +
59345934 sub_block_len);
59355935 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);
5936 const sub_br_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
5936 const sub_br_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
59375937
59385938 sema.air_instructions.items(.tag)[br] = .block;
59395939 sema.air_instructions.items(.data)[br] = .{ .ty_pl = .{
......@@ -6291,7 +6291,7 @@ fn addDbgVar(
62916291 try sema.queueFullTypeResolution(operand_ty);
62926292
62936293 // Add the name to the AIR.
6294 const name_extra_index = @as(u32, @intCast(sema.air_extra.items.len));
6294 const name_extra_index: u32 = @intCast(sema.air_extra.items.len);
62956295 const elements_used = name.len / 4 + 1;
62966296 try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements_used);
62976297 const buffer = mem.sliceAsBytes(sema.air_extra.unusedCapacitySlice());
......@@ -6491,7 +6491,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref
64916491 .tag = .save_err_return_trace_index,
64926492 .data = .{ .ty_pl = .{
64936493 .ty = Air.internedToRef(stack_trace_ty.toIntern()),
6494 .payload = @as(u32, @intCast(field_index)),
6494 .payload = @intCast(field_index),
64956495 } },
64966496 });
64976497}
......@@ -6563,12 +6563,12 @@ fn popErrorReturnTrace(
65636563 then_block.instructions.items.len + else_block.instructions.items.len +
65646564 @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block
65656565
6566 const cond_br_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
6566 const cond_br_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
65676567 try sema.air_instructions.append(gpa, .{ .tag = .cond_br, .data = .{ .pl_op = .{
65686568 .operand = is_non_error_inst,
65696569 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
6570 .then_body_len = @as(u32, @intCast(then_block.instructions.items.len)),
6571 .else_body_len = @as(u32, @intCast(else_block.instructions.items.len)),
6570 .then_body_len = @intCast(then_block.instructions.items.len),
6571 .else_body_len = @intCast(else_block.instructions.items.len),
65726572 }),
65736573 } } });
65746574 sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items);
......@@ -6599,7 +6599,7 @@ fn zirCall(
65996599 const extra = sema.code.extraData(ExtraType, inst_data.payload_index);
66006600 const args_len = extra.data.flags.args_len;
66016601
6602 const modifier = @as(std.builtin.CallModifier, @enumFromInt(extra.data.flags.packed_modifier));
6602 const modifier: std.builtin.CallModifier = @enumFromInt(extra.data.flags.packed_modifier);
66036603 const ensure_result_used = extra.data.flags.ensure_result_used;
66046604 const pop_error_return_trace = extra.data.flags.pop_error_return_trace;
66056605
......@@ -6678,7 +6678,7 @@ fn zirCall(
66786678 .tag = .save_err_return_trace_index,
66796679 .data = .{ .ty_pl = .{
66806680 .ty = Air.internedToRef(stack_trace_ty.toIntern()),
6681 .payload = @as(u32, @intCast(field_index)),
6681 .payload = @intCast(field_index),
66826682 } },
66836683 });
66846684
......@@ -7225,7 +7225,7 @@ fn analyzeCall(
72257225 // set to in the `Block`.
72267226 // This block instruction will be used to capture the return value from the
72277227 // inlined function.
7228 const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
7228 const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
72297229 try sema.air_instructions.append(gpa, .{
72307230 .tag = .block,
72317231 .data = undefined,
......@@ -7523,7 +7523,7 @@ fn analyzeCall(
75237523 .data = .{ .pl_op = .{
75247524 .operand = func,
75257525 .payload = sema.addExtraAssumeCapacity(Air.Call{
7526 .args_len = @as(u32, @intCast(args.len)),
7526 .args_len = @intCast(args.len),
75277527 }),
75287528 } },
75297529 });
......@@ -8146,7 +8146,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
81468146 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
81478147 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
81488148 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
8149 const len = @as(u32, @intCast(try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector length must be comptime-known")));
8149 const len: u32 = @intCast(try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector length must be comptime-known"));
81508150 const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs);
81518151 try sema.checkVectorElemType(block, elem_type_src, elem_type);
81528152 const vector_type = try mod.vectorType(.{
......@@ -8891,7 +8891,7 @@ fn zirFunc(
88918891 const ret_ty: Type = switch (extra.data.ret_body_len) {
88928892 0 => Type.void,
88938893 1 => blk: {
8894 const ret_ty_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
8894 const ret_ty_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
88958895 extra_index += 1;
88968896 if (sema.resolveType(block, ret_ty_src, ret_ty_ref)) |ret_ty| {
88978897 break :blk ret_ty;
......@@ -9538,37 +9538,37 @@ fn finishFunc(
95389538 }
95399539
95409540 const arch = target.cpu.arch;
9541 if (switch (cc_resolved) {
9541 if (@as(?[]const u8, switch (cc_resolved) {
95429542 .Unspecified, .C, .Naked, .Async, .Inline => null,
95439543 .Interrupt => switch (arch) {
95449544 .x86, .x86_64, .avr, .msp430 => null,
9545 else => @as([]const u8, "x86, x86_64, AVR, and MSP430"),
9545 else => "x86, x86_64, AVR, and MSP430",
95469546 },
95479547 .Signal => switch (arch) {
95489548 .avr => null,
9549 else => @as([]const u8, "AVR"),
9549 else => "AVR",
95509550 },
95519551 .Stdcall, .Fastcall, .Thiscall => switch (arch) {
95529552 .x86 => null,
9553 else => @as([]const u8, "x86"),
9553 else => "x86",
95549554 },
95559555 .Vectorcall => switch (arch) {
95569556 .x86, .aarch64, .aarch64_be, .aarch64_32 => null,
9557 else => @as([]const u8, "x86 and AArch64"),
9557 else => "x86 and AArch64",
95589558 },
95599559 .APCS, .AAPCS, .AAPCSVFP => switch (arch) {
95609560 .arm, .armeb, .aarch64, .aarch64_be, .aarch64_32, .thumb, .thumbeb => null,
9561 else => @as([]const u8, "ARM"),
9561 else => "ARM",
95629562 },
95639563 .SysV, .Win64 => switch (arch) {
95649564 .x86_64 => null,
9565 else => @as([]const u8, "x86_64"),
9565 else => "x86_64",
95669566 },
95679567 .Kernel => switch (arch) {
95689568 .nvptx, .nvptx64, .amdgcn, .spirv32, .spirv64 => null,
9569 else => @as([]const u8, "nvptx, amdgcn and SPIR-V"),
9569 else => "nvptx, amdgcn and SPIR-V",
95709570 },
9571 }) |allowed_platform| {
9571 })) |allowed_platform| {
95729572 return sema.fail(block, cc_src, "callconv '{s}' is only available on {s}, not {s}", .{
95739573 @tagName(cc_resolved),
95749574 allowed_platform,
......@@ -10684,7 +10684,7 @@ const SwitchProngAnalysis = struct {
1068410684 const multi_idx = raw_capture_src.multi_capture;
1068510685 const src_decl_ptr = sema.mod.declPtr(block.src_decl);
1068610686 for (case_srcs, 0..) |*case_src, i| {
10687 const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @as(u32, @intCast(i)) } };
10687 const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @intCast(i) } };
1068810688 case_src.* = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none);
1068910689 }
1069010690 const capture_src = raw_capture_src.resolve(mod, src_decl_ptr, switch_node_offset, .none);
......@@ -10732,7 +10732,7 @@ const SwitchProngAnalysis = struct {
1073210732 const multi_idx = raw_capture_src.multi_capture;
1073310733 const src_decl_ptr = sema.mod.declPtr(block.src_decl);
1073410734 const capture_src = raw_capture_src.resolve(mod, src_decl_ptr, switch_node_offset, .none);
10735 const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @as(u32, @intCast(i)) } };
10735 const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @intCast(i) } };
1073610736 const case_src = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none);
1073710737 const msg = msg: {
1073810738 const msg = try sema.errMsg(block, capture_src, "capture group with incompatible types", .{});
......@@ -10833,12 +10833,12 @@ const SwitchProngAnalysis = struct {
1083310833 var coerce_block = block.makeSubBlock();
1083410834 defer coerce_block.instructions.deinit(sema.gpa);
1083510835
10836 const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @as(u32, @intCast(idx)), field_tys[idx]);
10836 const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @intCast(idx), field_tys[idx]);
1083710837 const coerced = sema.coerce(&coerce_block, capture_ty, uncoerced, .unneeded) catch |err| switch (err) {
1083810838 error.NeededSourceLocation => {
1083910839 const multi_idx = raw_capture_src.multi_capture;
1084010840 const src_decl_ptr = sema.mod.declPtr(block.src_decl);
10841 const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @as(u32, @intCast(idx)) } };
10841 const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @intCast(idx) } };
1084210842 const case_src = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none);
1084310843 _ = try sema.coerce(&coerce_block, capture_ty, uncoerced, case_src);
1084410844 unreachable;
......@@ -10849,7 +10849,7 @@ const SwitchProngAnalysis = struct {
1084910849
1085010850 try cases_extra.ensureUnusedCapacity(3 + coerce_block.instructions.items.len);
1085110851 cases_extra.appendAssumeCapacity(1); // items_len
10852 cases_extra.appendAssumeCapacity(@as(u32, @intCast(coerce_block.instructions.items.len))); // body_len
10852 cases_extra.appendAssumeCapacity(@intCast(coerce_block.instructions.items.len)); // body_len
1085310853 cases_extra.appendAssumeCapacity(@intFromEnum(case_vals[idx])); // item
1085410854 cases_extra.appendSliceAssumeCapacity(coerce_block.instructions.items); // body
1085510855 }
......@@ -10860,7 +10860,7 @@ const SwitchProngAnalysis = struct {
1086010860 defer coerce_block.instructions.deinit(sema.gpa);
1086110861
1086210862 const first_imc = in_mem_coercible.findFirstSet().?;
10863 const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @as(u32, @intCast(first_imc)), field_tys[first_imc]);
10863 const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @intCast(first_imc), field_tys[first_imc]);
1086410864 const coerced = try coerce_block.addBitCast(capture_ty, uncoerced);
1086510865 _ = try coerce_block.addBr(capture_block_inst, coerced);
1086610866
......@@ -10873,14 +10873,14 @@ const SwitchProngAnalysis = struct {
1087310873 @typeInfo(Air.Block).Struct.fields.len +
1087410874 1);
1087510875
10876 const switch_br_inst = @as(u32, @intCast(sema.air_instructions.len));
10876 const switch_br_inst: u32 = @intCast(sema.air_instructions.len);
1087710877 try sema.air_instructions.append(sema.gpa, .{
1087810878 .tag = .switch_br,
1087910879 .data = .{ .pl_op = .{
1088010880 .operand = spa.cond,
1088110881 .payload = sema.addExtraAssumeCapacity(Air.SwitchBr{
10882 .cases_len = @as(u32, @intCast(prong_count)),
10883 .else_body_len = @as(u32, @intCast(else_body_len)),
10882 .cases_len = @intCast(prong_count),
10883 .else_body_len = @intCast(else_body_len),
1088410884 }),
1088510885 } },
1088610886 });
......@@ -11067,7 +11067,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1106711067 .has_tag_capture = false,
1106811068 },
1106911069 .under, .@"else" => blk: {
11070 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[header_extra_index]));
11070 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[header_extra_index]);
1107111071 const extra_body_start = header_extra_index + 1;
1107211072 break :blk .{
1107311073 .body = sema.code.extra[extra_body_start..][0..info.body_len],
......@@ -11144,9 +11144,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1114411144 {
1114511145 var scalar_i: u32 = 0;
1114611146 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11147 const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11147 const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1114811148 extra_index += 1;
11149 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11149 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1115011150 extra_index += 1 + info.body_len;
1115111151
1115211152 case_vals.appendAssumeCapacity(try sema.validateSwitchItemEnum(
......@@ -11167,7 +11167,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1116711167 extra_index += 1;
1116811168 const ranges_len = sema.code.extra[extra_index];
1116911169 extra_index += 1;
11170 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11170 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1117111171 extra_index += 1;
1117211172 const items = sema.code.refSlice(extra_index, items_len);
1117311173 extra_index += items_len + info.body_len;
......@@ -11181,7 +11181,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1118111181 item_ref,
1118211182 operand_ty,
1118311183 src_node_offset,
11184 .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } },
11184 .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } },
1118511185 ));
1118611186 }
1118711187
......@@ -11243,9 +11243,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1124311243 {
1124411244 var scalar_i: u32 = 0;
1124511245 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11246 const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11246 const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1124711247 extra_index += 1;
11248 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11248 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1124911249 extra_index += 1 + info.body_len;
1125011250
1125111251 case_vals.appendAssumeCapacity(try sema.validateSwitchItemError(
......@@ -11265,7 +11265,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1126511265 extra_index += 1;
1126611266 const ranges_len = sema.code.extra[extra_index];
1126711267 extra_index += 1;
11268 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11268 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1126911269 extra_index += 1;
1127011270 const items = sema.code.refSlice(extra_index, items_len);
1127111271 extra_index += items_len + info.body_len;
......@@ -11278,7 +11278,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1127811278 item_ref,
1127911279 operand_ty,
1128011280 src_node_offset,
11281 .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } },
11281 .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } },
1128211282 ));
1128311283 }
1128411284
......@@ -11387,9 +11387,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1138711387 {
1138811388 var scalar_i: u32 = 0;
1138911389 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11390 const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11390 const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1139111391 extra_index += 1;
11392 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11392 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1139311393 extra_index += 1 + info.body_len;
1139411394
1139511395 case_vals.appendAssumeCapacity(try sema.validateSwitchItemInt(
......@@ -11409,7 +11409,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1140911409 extra_index += 1;
1141011410 const ranges_len = sema.code.extra[extra_index];
1141111411 extra_index += 1;
11412 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11412 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1141311413 extra_index += 1;
1141411414 const items = sema.code.refSlice(extra_index, items_len);
1141511415 extra_index += items_len;
......@@ -11422,16 +11422,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1142211422 item_ref,
1142311423 operand_ty,
1142411424 src_node_offset,
11425 .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } },
11425 .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } },
1142611426 ));
1142711427 }
1142811428
1142911429 try case_vals.ensureUnusedCapacity(gpa, 2 * ranges_len);
1143011430 var range_i: u32 = 0;
1143111431 while (range_i < ranges_len) : (range_i += 1) {
11432 const item_first = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11432 const item_first: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1143311433 extra_index += 1;
11434 const item_last = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11434 const item_last: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1143511435 extra_index += 1;
1143611436
1143711437 const vals = try sema.validateSwitchRange(
......@@ -11482,9 +11482,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1148211482 {
1148311483 var scalar_i: u32 = 0;
1148411484 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11485 const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11485 const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1148611486 extra_index += 1;
11487 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11487 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1148811488 extra_index += 1 + info.body_len;
1148911489
1149011490 case_vals.appendAssumeCapacity(try sema.validateSwitchItemBool(
......@@ -11504,7 +11504,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1150411504 extra_index += 1;
1150511505 const ranges_len = sema.code.extra[extra_index];
1150611506 extra_index += 1;
11507 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11507 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1150811508 extra_index += 1;
1150911509 const items = sema.code.refSlice(extra_index, items_len);
1151011510 extra_index += items_len + info.body_len;
......@@ -11517,7 +11517,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1151711517 &false_count,
1151811518 item_ref,
1151911519 src_node_offset,
11520 .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } },
11520 .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } },
1152111521 ));
1152211522 }
1152311523
......@@ -11564,9 +11564,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1156411564 {
1156511565 var scalar_i: u32 = 0;
1156611566 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11567 const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
11567 const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
1156811568 extra_index += 1;
11569 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11569 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1157011570 extra_index += 1;
1157111571 extra_index += info.body_len;
1157211572
......@@ -11587,7 +11587,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1158711587 extra_index += 1;
1158811588 const ranges_len = sema.code.extra[extra_index];
1158911589 extra_index += 1;
11590 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11590 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1159111591 extra_index += 1;
1159211592 const items = sema.code.refSlice(extra_index, items_len);
1159311593 extra_index += items_len + info.body_len;
......@@ -11600,7 +11600,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1160011600 item_ref,
1160111601 operand_ty,
1160211602 src_node_offset,
11603 .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } },
11603 .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } },
1160411604 ));
1160511605 }
1160611606
......@@ -11638,7 +11638,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1163811638 .tag_capture_inst = tag_capture_inst,
1163911639 };
1164011640
11641 const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
11641 const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
1164211642 try sema.air_instructions.append(gpa, .{
1164311643 .tag = .block,
1164411644 .data = undefined,
......@@ -11682,7 +11682,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1168211682 var scalar_i: usize = 0;
1168311683 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
1168411684 extra_index += 1;
11685 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11685 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1168611686 extra_index += 1;
1168711687 const body = sema.code.extra[extra_index..][0..info.body_len];
1168811688 extra_index += info.body_len;
......@@ -11696,7 +11696,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1169611696 .normal,
1169711697 body,
1169811698 info.capture,
11699 .{ .scalar_capture = @as(u32, @intCast(scalar_i)) },
11699 .{ .scalar_capture = @intCast(scalar_i) },
1170011700 &.{item},
1170111701 if (info.is_inline) operand else .none,
1170211702 info.has_tag_capture,
......@@ -11713,7 +11713,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1171311713 extra_index += 1;
1171411714 const ranges_len = sema.code.extra[extra_index];
1171511715 extra_index += 1;
11716 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11716 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1171711717 extra_index += 1 + items_len;
1171811718 const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..info.body_len];
1171911719
......@@ -11730,7 +11730,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1173011730 .normal,
1173111731 body,
1173211732 info.capture,
11733 .{ .multi_capture = @as(u32, @intCast(multi_i)) },
11733 .{ .multi_capture = @intCast(multi_i) },
1173411734 items,
1173511735 if (info.is_inline) operand else .none,
1173611736 info.has_tag_capture,
......@@ -11757,7 +11757,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1175711757 .normal,
1175811758 body,
1175911759 info.capture,
11760 .{ .multi_capture = @as(u32, @intCast(multi_i)) },
11760 .{ .multi_capture = @intCast(multi_i) },
1176111761 undefined, // case_vals may be undefined for ranges
1176211762 if (info.is_inline) operand else .none,
1176311763 info.has_tag_capture,
......@@ -11842,7 +11842,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1184211842 var scalar_i: usize = 0;
1184311843 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
1184411844 extra_index += 1;
11845 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11845 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1184611846 extra_index += 1;
1184711847 const body = sema.code.extra[extra_index..][0..info.body_len];
1184811848 extra_index += info.body_len;
......@@ -11870,7 +11870,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1187011870 .normal,
1187111871 body,
1187211872 info.capture,
11873 .{ .scalar_capture = @as(u32, @intCast(scalar_i)) },
11873 .{ .scalar_capture = @intCast(scalar_i) },
1187411874 &.{item},
1187511875 if (info.is_inline) item else .none,
1187611876 info.has_tag_capture,
......@@ -11883,7 +11883,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1188311883
1188411884 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1188511885 cases_extra.appendAssumeCapacity(1); // items_len
11886 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
11886 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1188711887 cases_extra.appendAssumeCapacity(@intFromEnum(item));
1188811888 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1188911889 }
......@@ -11903,7 +11903,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1190311903 extra_index += 1;
1190411904 const ranges_len = sema.code.extra[extra_index];
1190511905 extra_index += 1;
11906 const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index]));
11906 const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]);
1190711907 extra_index += 1 + items_len;
1190811908
1190911909 const items = case_vals.items[case_val_idx..][0..items_len];
......@@ -11946,7 +11946,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1194611946
1194711947 if (emit_bb) sema.emitBackwardBranch(block, .unneeded) catch |err| switch (err) {
1194811948 error.NeededSourceLocation => {
11949 const case_src = Module.SwitchProngSrc{ .range = .{ .prong = multi_i, .item = range_i } };
11949 const case_src = Module.SwitchProngSrc{
11950 .range = .{ .prong = multi_i, .item = range_i },
11951 };
1195011952 const decl = mod.declPtr(case_block.src_decl);
1195111953 try sema.emitBackwardBranch(block, case_src.resolve(mod, decl, src_node_offset, .none));
1195211954 unreachable;
......@@ -11968,7 +11970,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1196811970
1196911971 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1197011972 cases_extra.appendAssumeCapacity(1); // items_len
11971 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
11973 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1197211974 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1197311975 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1197411976
......@@ -11990,7 +11992,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1199011992
1199111993 if (emit_bb) sema.emitBackwardBranch(block, .unneeded) catch |err| switch (err) {
1199211994 error.NeededSourceLocation => {
11993 const case_src = Module.SwitchProngSrc{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } };
11995 const case_src = Module.SwitchProngSrc{
11996 .multi = .{ .prong = multi_i, .item = @intCast(item_i) },
11997 };
1199411998 const decl = mod.declPtr(case_block.src_decl);
1199511999 try sema.emitBackwardBranch(block, case_src.resolve(mod, decl, src_node_offset, .none));
1199612000 unreachable;
......@@ -12016,7 +12020,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1201612020
1201712021 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1201812022 cases_extra.appendAssumeCapacity(1); // items_len
12019 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12023 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1202012024 cases_extra.appendAssumeCapacity(@intFromEnum(item));
1202112025 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1202212026 }
......@@ -12064,8 +12068,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1206412068 try cases_extra.ensureUnusedCapacity(gpa, 2 + items.len +
1206512069 case_block.instructions.items.len);
1206612070
12067 cases_extra.appendAssumeCapacity(@as(u32, @intCast(items.len)));
12068 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12071 cases_extra.appendAssumeCapacity(@intCast(items.len));
12072 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1206912073
1207012074 for (items) |item| {
1207112075 cases_extra.appendAssumeCapacity(@intFromEnum(item));
......@@ -12160,8 +12164,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1216012164
1216112165 sema.air_instructions.items(.data)[prev_cond_br].pl_op.payload =
1216212166 sema.addExtraAssumeCapacity(Air.CondBr{
12163 .then_body_len = @as(u32, @intCast(prev_then_body.len)),
12164 .else_body_len = @as(u32, @intCast(cond_body.len)),
12167 .then_body_len = @intCast(prev_then_body.len),
12168 .else_body_len = @intCast(cond_body.len),
1216512169 });
1216612170 sema.air_extra.appendSliceAssumeCapacity(prev_then_body);
1216712171 sema.air_extra.appendSliceAssumeCapacity(cond_body);
......@@ -12186,7 +12190,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1218612190 if (f != null) continue;
1218712191 cases_len += 1;
1218812192
12189 const item_val = try mod.enumValueFieldIndex(operand_ty, @as(u32, @intCast(i)));
12193 const item_val = try mod.enumValueFieldIndex(operand_ty, @intCast(i));
1219012194 const item_ref = Air.internedToRef(item_val.toIntern());
1219112195
1219212196 case_block.instructions.shrinkRetainingCapacity(0);
......@@ -12217,7 +12221,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1221712221
1221812222 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1221912223 cases_extra.appendAssumeCapacity(1); // items_len
12220 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12224 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1222112225 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1222212226 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1222312227 }
......@@ -12258,7 +12262,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1225812262
1225912263 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1226012264 cases_extra.appendAssumeCapacity(1); // items_len
12261 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12265 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1226212266 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1226312267 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1226412268 }
......@@ -12289,7 +12293,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1228912293
1229012294 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1229112295 cases_extra.appendAssumeCapacity(1); // items_len
12292 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12296 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1229312297 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1229412298 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1229512299 }
......@@ -12317,7 +12321,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1231712321
1231812322 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1231912323 cases_extra.appendAssumeCapacity(1); // items_len
12320 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12324 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1232112325 cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_true));
1232212326 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1232312327 }
......@@ -12343,7 +12347,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1234312347
1234412348 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1234512349 cases_extra.appendAssumeCapacity(1); // items_len
12346 cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len)));
12350 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
1234712351 cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_false));
1234812352 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1234912353 }
......@@ -12412,8 +12416,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1241212416
1241312417 sema.air_instructions.items(.data)[prev_cond_br].pl_op.payload =
1241412418 sema.addExtraAssumeCapacity(Air.CondBr{
12415 .then_body_len = @as(u32, @intCast(prev_then_body.len)),
12416 .else_body_len = @as(u32, @intCast(case_block.instructions.items.len)),
12419 .then_body_len = @intCast(prev_then_body.len),
12420 .else_body_len = @intCast(case_block.instructions.items.len),
1241712421 });
1241812422 sema.air_extra.appendSliceAssumeCapacity(prev_then_body);
1241912423 sema.air_extra.appendSliceAssumeCapacity(case_block.instructions.items);
......@@ -12427,8 +12431,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1242712431 _ = try child_block.addInst(.{ .tag = .switch_br, .data = .{ .pl_op = .{
1242812432 .operand = operand,
1242912433 .payload = sema.addExtraAssumeCapacity(Air.SwitchBr{
12430 .cases_len = @as(u32, @intCast(cases_len)),
12431 .else_body_len = @as(u32, @intCast(final_else_body.len)),
12434 .cases_len = @intCast(cases_len),
12435 .else_body_len = @intCast(final_else_body.len),
1243212436 }),
1243312437 } } });
1243412438 sema.air_extra.appendSliceAssumeCapacity(cases_extra.items);
......@@ -13842,7 +13846,7 @@ fn analyzeTupleMul(
1384213846 var i: u32 = 0;
1384313847 while (i < tuple_len) : (i += 1) {
1384413848 const operand_src = lhs_src; // TODO better source location
13845 element_refs[i] = try sema.tupleFieldValByIndex(block, operand_src, operand, @as(u32, @intCast(i)), operand_ty);
13849 element_refs[i] = try sema.tupleFieldValByIndex(block, operand_src, operand, @intCast(i), operand_ty);
1384613850 }
1384713851 i = 1;
1384813852 while (i < factor) : (i += 1) {
......@@ -15886,10 +15890,10 @@ fn analyzePtrArithmetic(
1588615890 // The resulting pointer is aligned to the lcd between the offset (an
1588715891 // arbitrary number) and the alignment factor (always a power of two,
1588815892 // non zero).
15889 const new_align = @as(Alignment, @enumFromInt(@min(
15893 const new_align: Alignment = @enumFromInt(@min(
1589015894 @ctz(addend),
1589115895 @intFromEnum(ptr_info.flags.alignment),
15892 )));
15896 ));
1589315897 assert(new_align != .none);
1589415898
1589515899 break :t try mod.ptrType(.{
......@@ -15968,14 +15972,14 @@ fn zirAsm(
1596815972 const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand);
1596915973 const src = LazySrcLoc.nodeOffset(extra.data.src_node);
1597015974 const ret_ty_src: LazySrcLoc = .{ .node_offset_asm_ret_ty = extra.data.src_node };
15971 const outputs_len = @as(u5, @truncate(extended.small));
15972 const inputs_len = @as(u5, @truncate(extended.small >> 5));
15973 const clobbers_len = @as(u5, @truncate(extended.small >> 10));
15975 const outputs_len: u5 = @truncate(extended.small);
15976 const inputs_len: u5 = @truncate(extended.small >> 5);
15977 const clobbers_len: u5 = @truncate(extended.small >> 10);
1597415978 const is_volatile = @as(u1, @truncate(extended.small >> 15)) != 0;
1597515979 const is_global_assembly = sema.func_index == .none;
1597615980
1597715981 const asm_source: []const u8 = if (tmpl_is_expr) blk: {
15978 const tmpl = @as(Zir.Inst.Ref, @enumFromInt(extra.data.asm_source));
15982 const tmpl: Zir.Inst.Ref = @enumFromInt(extra.data.asm_source);
1597915983 const s: []const u8 = try sema.resolveConstString(block, src, tmpl, "assembly code must be comptime-known");
1598015984 break :blk s;
1598115985 } else sema.code.nullTerminatedString(extra.data.asm_source);
......@@ -16076,9 +16080,9 @@ fn zirAsm(
1607616080 .data = .{ .ty_pl = .{
1607716081 .ty = expr_ty,
1607816082 .payload = sema.addExtraAssumeCapacity(Air.Asm{
16079 .source_len = @as(u32, @intCast(asm_source.len)),
16083 .source_len = @intCast(asm_source.len),
1608016084 .outputs_len = outputs_len,
16081 .inputs_len = @as(u32, @intCast(args.len)),
16085 .inputs_len = @intCast(args.len),
1608216086 .flags = (@as(u32, @intFromBool(is_volatile)) << 31) | @as(u32, @intCast(clobbers.len)),
1608316087 }),
1608416088 } },
......@@ -16486,7 +16490,7 @@ fn zirThis(
1648616490) CompileError!Air.Inst.Ref {
1648716491 const mod = sema.mod;
1648816492 const this_decl_index = mod.namespaceDeclIndex(block.namespace);
16489 const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand)));
16493 const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand));
1649016494 return sema.analyzeDeclVal(block, src, this_decl_index);
1649116495}
1649216496
......@@ -16624,7 +16628,7 @@ fn zirFrameAddress(
1662416628 block: *Block,
1662516629 extended: Zir.Inst.Extended.InstData,
1662616630) CompileError!Air.Inst.Ref {
16627 const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand)));
16631 const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand));
1662816632 try sema.requireRuntimeBlock(block, src, null);
1662916633 return try block.addNoOp(.frame_addr);
1663016634}
......@@ -17223,7 +17227,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1722317227 else
1722417228 try mod.intern(.{ .int = .{
1722517229 .ty = .comptime_int_type,
17226 .storage = .{ .u64 = @as(u64, @intCast(i)) },
17230 .storage = .{ .u64 = @intCast(i) },
1722717231 } });
1722817232 // TODO: write something like getCoercedInts to avoid needing to dupe
1722917233 const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i]));
......@@ -18035,7 +18039,7 @@ fn zirBoolBr(
1803518039 return sema.resolveBody(parent_block, body, inst);
1803618040 }
1803718041
18038 const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
18042 const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
1803918043 try sema.air_instructions.append(gpa, .{
1804018044 .tag = .block,
1804118045 .data = .{ .ty_pl = .{
......@@ -18097,8 +18101,8 @@ fn finishCondBr(
1809718101 @typeInfo(Air.Block).Struct.fields.len + child_block.instructions.items.len + 1);
1809818102
1809918103 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
18100 .then_body_len = @as(u32, @intCast(then_block.instructions.items.len)),
18101 .else_body_len = @as(u32, @intCast(else_block.instructions.items.len)),
18104 .then_body_len = @intCast(then_block.instructions.items.len),
18105 .else_body_len = @intCast(else_block.instructions.items.len),
1810218106 });
1810318107 sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items);
1810418108 sema.air_extra.appendSliceAssumeCapacity(else_block.instructions.items);
......@@ -18109,7 +18113,7 @@ fn finishCondBr(
1810918113 } } });
1811018114
1811118115 sema.air_instructions.items(.data)[block_inst].ty_pl.payload = sema.addExtraAssumeCapacity(
18112 Air.Block{ .body_len = @as(u32, @intCast(child_block.instructions.items.len)) },
18116 Air.Block{ .body_len = @intCast(child_block.instructions.items.len) },
1811318117 );
1811418118 sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items);
1811518119
......@@ -18272,8 +18276,8 @@ fn zirCondbr(
1827218276 .data = .{ .pl_op = .{
1827318277 .operand = cond,
1827418278 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
18275 .then_body_len = @as(u32, @intCast(true_instructions.len)),
18276 .else_body_len = @as(u32, @intCast(sub_block.instructions.items.len)),
18279 .then_body_len = @intCast(true_instructions.len),
18280 .else_body_len = @intCast(sub_block.instructions.items.len),
1827718281 }),
1827818282 } },
1827918283 });
......@@ -18320,7 +18324,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
1832018324 .data = .{ .pl_op = .{
1832118325 .operand = err_union,
1832218326 .payload = sema.addExtraAssumeCapacity(Air.Try{
18323 .body_len = @as(u32, @intCast(sub_block.instructions.items.len)),
18327 .body_len = @intCast(sub_block.instructions.items.len),
1832418328 }),
1832518329 } },
1832618330 });
......@@ -18380,7 +18384,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
1838018384 .ty = res_ty_ref,
1838118385 .payload = sema.addExtraAssumeCapacity(Air.TryPtr{
1838218386 .ptr = operand,
18383 .body_len = @as(u32, @intCast(sub_block.instructions.items.len)),
18387 .body_len = @intCast(sub_block.instructions.items.len),
1838418388 }),
1838518389 } },
1838618390 });
......@@ -18396,7 +18400,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, break_data: BreakData) !voi
1839618400 const labeled_block = if (!gop.found_existing) blk: {
1839718401 try sema.post_hoc_blocks.ensureUnusedCapacity(sema.gpa, 1);
1839818402
18399 const new_block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
18403 const new_block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
1840018404 gop.value_ptr.* = Air.indexToRef(new_block_inst);
1840118405 try sema.air_instructions.append(sema.gpa, .{
1840218406 .tag = .block,
......@@ -18611,8 +18615,8 @@ fn retWithErrTracing(
1861118615 @typeInfo(Air.Block).Struct.fields.len + 1);
1861218616
1861318617 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
18614 .then_body_len = @as(u32, @intCast(then_block.instructions.items.len)),
18615 .else_body_len = @as(u32, @intCast(else_block.instructions.items.len)),
18618 .then_body_len = @intCast(then_block.instructions.items.len),
18619 .else_body_len = @intCast(else_block.instructions.items.len),
1861618620 });
1861718621 sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items);
1861818622 sema.air_extra.appendSliceAssumeCapacity(else_block.instructions.items);
......@@ -18826,7 +18830,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1882618830 var extra_i = extra.end;
1882718831
1882818832 const sentinel = if (inst_data.flags.has_sentinel) blk: {
18829 const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i]));
18833 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1883018834 extra_i += 1;
1883118835 const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src);
1883218836 const val = try sema.resolveConstValue(block, sentinel_src, coerced, "pointer sentinel value must be comptime-known");
......@@ -18834,7 +18838,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1883418838 } else .none;
1883518839
1883618840 const abi_align: Alignment = if (inst_data.flags.has_align) blk: {
18837 const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i]));
18841 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1883818842 extra_i += 1;
1883918843 const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src);
1884018844 const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime-known");
......@@ -18847,29 +18851,29 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1884718851 },
1884818852 else => {},
1884918853 }
18850 const abi_align = @as(u32, @intCast((try val.getUnsignedIntAdvanced(mod, sema)).?));
18854 const abi_align: u32 = @intCast((try val.getUnsignedIntAdvanced(mod, sema)).?);
1885118855 try sema.validateAlign(block, align_src, abi_align);
1885218856 break :blk Alignment.fromByteUnits(abi_align);
1885318857 } else .none;
1885418858
1885518859 const address_space: std.builtin.AddressSpace = if (inst_data.flags.has_addrspace) blk: {
18856 const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i]));
18860 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1885718861 extra_i += 1;
1885818862 break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer);
1885918863 } else if (elem_ty.zigTypeTag(mod) == .Fn and target.cpu.arch == .avr) .flash else .generic;
1886018864
18861 const bit_offset = if (inst_data.flags.has_bit_range) blk: {
18862 const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i]));
18865 const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: {
18866 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1886318867 extra_i += 1;
1886418868 const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime-known");
18865 break :blk @as(u16, @intCast(bit_offset));
18869 break :blk @intCast(bit_offset);
1886618870 } else 0;
1886718871
1886818872 const host_size: u16 = if (inst_data.flags.has_bit_range) blk: {
18869 const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i]));
18873 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
1887018874 extra_i += 1;
1887118875 const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime-known");
18872 break :blk @as(u16, @intCast(host_size));
18876 break :blk @intCast(host_size);
1887318877 } else 0;
1887418878
1887518879 if (host_size != 0 and bit_offset >= host_size * 8) {
......@@ -19270,7 +19274,7 @@ fn finishStructInit(
1927019274 });
1927119275 const alloc = try block.addTy(.alloc, alloc_ty);
1927219276 for (field_inits, 0..) |field_init, i_usize| {
19273 const i = @as(u32, @intCast(i_usize));
19277 const i: u32 = @intCast(i_usize);
1927419278 const field_src = dest_src;
1927519279 const field_ptr = try sema.structFieldPtrByIndex(block, dest_src, alloc, i, field_src, struct_ty, true);
1927619280 try sema.storePtr(block, dest_src, field_ptr, field_init);
......@@ -19423,7 +19427,7 @@ fn structInitAnon(
1942319427 const alloc = try block.addTy(.alloc, alloc_ty);
1942419428 var extra_index = extra_end;
1942519429 for (types, 0..) |field_ty, i_usize| {
19426 const i = @as(u32, @intCast(i_usize));
19430 const i: u32 = @intCast(i_usize);
1942719431 const item = switch (kind) {
1942819432 .anon_init => sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index),
1942919433 .typed_init => sema.code.extraData(Zir.Inst.StructInit.Item, extra_index),
......@@ -19520,7 +19524,7 @@ fn zirArrayInit(
1952019524
1952119525 const opt_runtime_index: ?u32 = for (resolved_args, 0..) |arg, i| {
1952219526 const comptime_known = try sema.isComptimeKnown(arg);
19523 if (!comptime_known) break @as(u32, @intCast(i));
19527 if (!comptime_known) break @intCast(i);
1952419528 } else null;
1952519529
1952619530 const runtime_index = opt_runtime_index orelse {
......@@ -19665,7 +19669,7 @@ fn arrayInitAnon(
1966519669 });
1966619670 const alloc = try block.addTy(.alloc, alloc_ty);
1966719671 for (operands, 0..) |operand, i_usize| {
19668 const i = @as(u32, @intCast(i_usize));
19672 const i: u32 = @intCast(i_usize);
1966919673 const field_ptr_ty = try mod.ptrType(.{
1967019674 .child = types[i],
1967119675 .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) },
......@@ -19818,7 +19822,7 @@ fn zirFrame(
1981819822 block: *Block,
1981919823 extended: Zir.Inst.Extended.InstData,
1982019824) CompileError!Air.Inst.Ref {
19821 const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand)));
19825 const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand));
1982219826 return sema.failWithUseOfAsync(block, src);
1982319827}
1982419828
......@@ -20049,7 +20053,7 @@ fn zirReify(
2004920053 const mod = sema.mod;
2005020054 const gpa = sema.gpa;
2005120055 const ip = &mod.intern_pool;
20052 const name_strategy = @as(Zir.Inst.NameStrategy, @enumFromInt(extended.small));
20056 const name_strategy: Zir.Inst.NameStrategy = @enumFromInt(extended.small);
2005320057 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
2005420058 const src = LazySrcLoc.nodeOffset(extra.node);
2005520059 const type_info_ty = try sema.getBuiltinType("Type");
......@@ -20084,7 +20088,7 @@ fn zirReify(
2008420088 );
2008520089
2008620090 const signedness = mod.toEnum(std.builtin.Signedness, signedness_val);
20087 const bits = @as(u16, @intCast(bits_val.toUnsignedInt(mod)));
20091 const bits: u16 = @intCast(bits_val.toUnsignedInt(mod));
2008820092 const ty = try mod.intType(signedness, bits);
2008920093 return Air.internedToRef(ty.toIntern());
2009020094 },
......@@ -20097,7 +20101,7 @@ fn zirReify(
2009720101 try ip.getOrPutString(gpa, "child"),
2009820102 ).?);
2009920103
20100 const len = @as(u32, @intCast(len_val.toUnsignedInt(mod)));
20104 const len: u32 = @intCast(len_val.toUnsignedInt(mod));
2010120105 const child_ty = child_val.toType();
2010220106
2010320107 try sema.checkVectorElemType(block, src, child_ty);
......@@ -20114,7 +20118,7 @@ fn zirReify(
2011420118 try ip.getOrPutString(gpa, "bits"),
2011520119 ).?);
2011620120
20117 const bits = @as(u16, @intCast(bits_val.toUnsignedInt(mod)));
20121 const bits: u16 = @intCast(bits_val.toUnsignedInt(mod));
2011820122 const ty = switch (bits) {
2011920123 16 => Type.f16,
2012020124 32 => Type.f32,
......@@ -20382,7 +20386,7 @@ fn zirReify(
2038220386 }
2038320387
2038420388 // Define our empty enum decl
20385 const fields_len = @as(u32, @intCast(try sema.usizeCast(block, src, fields_val.sliceLen(mod))));
20389 const fields_len: u32 = @intCast(try sema.usizeCast(block, src, fields_val.sliceLen(mod)));
2038620390 const incomplete_enum = try ip.getIncompleteEnum(gpa, .{
2038720391 .decl = new_decl_index,
2038820392 .namespace = .none,
......@@ -20753,7 +20757,7 @@ fn zirReify(
2075320757 if (!try sema.intFitsInType(alignment_val, Type.u32, null)) {
2075420758 return sema.fail(block, src, "alignment must fit in 'u32'", .{});
2075520759 }
20756 const alignment = @as(u29, @intCast(alignment_val.toUnsignedInt(mod)));
20760 const alignment: u29 = @intCast(alignment_val.toUnsignedInt(mod));
2075720761 if (alignment == target_util.defaultFunctionAlignment(target)) {
2075820762 break :alignment .none;
2075920763 } else {
......@@ -21034,7 +21038,7 @@ fn reifyStruct(
2103421038 try sema.checkBackingIntType(block, src, backing_int_ty, fields_bit_sum);
2103521039 struct_obj.backing_int_ty = backing_int_ty;
2103621040 } else {
21037 struct_obj.backing_int_ty = try mod.intType(.unsigned, @as(u16, @intCast(fields_bit_sum)));
21041 struct_obj.backing_int_ty = try mod.intType(.unsigned, @intCast(fields_bit_sum));
2103821042 }
2103921043
2104021044 struct_obj.status = .have_layout;
......@@ -21105,7 +21109,7 @@ fn zirCVaEnd(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
2110521109}
2110621110
2110721111fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
21108 const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand)));
21112 const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand));
2110921113
2111021114 const va_list_ty = try sema.getBuiltinType("VaList");
2111121115 try sema.requireRuntimeBlock(block, src, null);
......@@ -21482,7 +21486,10 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
2148221486}
2148321487
2148421488fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
21485 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(u5, @truncate(extended.small)));
21489 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(
21490 @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?,
21491 @truncate(extended.small),
21492 ));
2148621493 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
2148721494 const src = LazySrcLoc.nodeOffset(extra.node);
2148821495 const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node };
......@@ -21885,7 +21892,10 @@ fn ptrCastFull(
2188521892
2188621893fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
2188721894 const mod = sema.mod;
21888 const flags = @as(Zir.Inst.FullPtrCastFlags, @bitCast(@as(u5, @truncate(extended.small))));
21895 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(
21896 @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?,
21897 @truncate(extended.small),
21898 ));
2188921899 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
2189021900 const src = LazySrcLoc.nodeOffset(extra.node);
2189121901 const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node };
......@@ -22950,12 +22960,12 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2295022960 else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(sema.mod)}),
2295122961 };
2295222962 mask_ty = try mod.vectorType(.{
22953 .len = @as(u32, @intCast(mask_len)),
22963 .len = @intCast(mask_len),
2295422964 .child = .i32_type,
2295522965 });
2295622966 mask = try sema.coerce(block, mask_ty, mask, mask_src);
2295722967 const mask_val = try sema.resolveConstMaybeUndefVal(block, mask_src, mask, "shuffle mask must be comptime-known");
22958 return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @as(u32, @intCast(mask_len)));
22968 return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @intCast(mask_len));
2295922969}
2296022970
2296122971fn analyzeShuffle(
......@@ -22999,8 +23009,8 @@ fn analyzeShuffle(
2299923009 if (maybe_a_len == null and maybe_b_len == null) {
2300023010 return mod.undefRef(res_ty);
2300123011 }
23002 const a_len = @as(u32, @intCast(maybe_a_len orelse maybe_b_len.?));
23003 const b_len = @as(u32, @intCast(maybe_b_len orelse a_len));
23012 const a_len: u32 = @intCast(maybe_a_len orelse maybe_b_len.?);
23013 const b_len: u32 = @intCast(maybe_b_len orelse a_len);
2300423014
2300523015 const a_ty = try mod.vectorType(.{
2300623016 .len = a_len,
......@@ -23019,17 +23029,17 @@ fn analyzeShuffle(
2301923029 .{ b_len, b_src, b_ty },
2302023030 };
2302123031
23022 for (0..@as(usize, @intCast(mask_len))) |i| {
23032 for (0..@intCast(mask_len)) |i| {
2302323033 const elem = try mask.elemValue(sema.mod, i);
2302423034 if (elem.isUndef(mod)) continue;
2302523035 const int = elem.toSignedInt(mod);
2302623036 var unsigned: u32 = undefined;
2302723037 var chosen: u32 = undefined;
2302823038 if (int >= 0) {
23029 unsigned = @as(u32, @intCast(int));
23039 unsigned = @intCast(int);
2303023040 chosen = 0;
2303123041 } else {
23032 unsigned = @as(u32, @intCast(~int));
23042 unsigned = @intCast(~int);
2303323043 chosen = 1;
2303423044 }
2303523045 if (unsigned >= operand_info[chosen][0]) {
......@@ -23062,7 +23072,7 @@ fn analyzeShuffle(
2306223072 continue;
2306323073 }
2306423074 const int = mask_elem_val.toSignedInt(mod);
23065 const unsigned = if (int >= 0) @as(u32, @intCast(int)) else @as(u32, @intCast(~int));
23075 const unsigned: u32 = @intCast(if (int >= 0) int else ~int);
2306623076 values[i] = try (try (if (int >= 0) a_val else b_val).elemValue(mod, unsigned)).intern(elem_ty, mod);
2306723077 }
2306823078 return Air.internedToRef((try mod.intern(.{ .aggregate = .{
......@@ -23083,23 +23093,23 @@ fn analyzeShuffle(
2308323093 const max_len = try sema.usizeCast(block, max_src, @max(a_len, b_len));
2308423094
2308523095 const expand_mask_values = try sema.arena.alloc(InternPool.Index, max_len);
23086 for (@as(usize, @intCast(0))..@as(usize, @intCast(min_len))) |i| {
23096 for (@intCast(0)..@intCast(min_len)) |i| {
2308723097 expand_mask_values[i] = (try mod.intValue(Type.comptime_int, i)).toIntern();
2308823098 }
23089 for (@as(usize, @intCast(min_len))..@as(usize, @intCast(max_len))) |i| {
23099 for (@intCast(min_len)..@intCast(max_len)) |i| {
2309023100 expand_mask_values[i] = (try mod.intValue(Type.comptime_int, -1)).toIntern();
2309123101 }
2309223102 const expand_mask = try mod.intern(.{ .aggregate = .{
23093 .ty = (try mod.vectorType(.{ .len = @as(u32, @intCast(max_len)), .child = .comptime_int_type })).toIntern(),
23103 .ty = (try mod.vectorType(.{ .len = @intCast(max_len), .child = .comptime_int_type })).toIntern(),
2309423104 .storage = .{ .elems = expand_mask_values },
2309523105 } });
2309623106
2309723107 if (a_len < b_len) {
2309823108 const undef = try mod.undefRef(a_ty);
23099 a = try sema.analyzeShuffle(block, src_node, elem_ty, a, undef, expand_mask.toValue(), @as(u32, @intCast(max_len)));
23109 a = try sema.analyzeShuffle(block, src_node, elem_ty, a, undef, expand_mask.toValue(), @intCast(max_len));
2310023110 } else {
2310123111 const undef = try mod.undefRef(b_ty);
23102 b = try sema.analyzeShuffle(block, src_node, elem_ty, b, undef, expand_mask.toValue(), @as(u32, @intCast(max_len)));
23112 b = try sema.analyzeShuffle(block, src_node, elem_ty, b, undef, expand_mask.toValue(), @intCast(max_len));
2310323113 }
2310423114 }
2310523115
......@@ -23136,7 +23146,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
2313623146 .Vector, .Array => pred_ty.arrayLen(mod),
2313723147 else => return sema.fail(block, pred_src, "expected vector or array, found '{}'", .{pred_ty.fmt(mod)}),
2313823148 };
23139 const vec_len = @as(u32, @intCast(try sema.usizeCast(block, pred_src, vec_len_u64)));
23149 const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64));
2314023150
2314123151 const bool_vec_ty = try mod.vectorType(.{
2314223152 .len = vec_len,
......@@ -23504,7 +23514,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2350423514
2350523515 var resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod));
2350623516 for (resolved_args, 0..) |*resolved, i| {
23507 resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @as(u32, @intCast(i)), args_ty);
23517 resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @intCast(i), args_ty);
2350823518 }
2350923519
2351023520 const callee_ty = sema.typeOf(func);
......@@ -23636,7 +23646,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
2363623646 .ty = Air.internedToRef(result_ptr.toIntern()),
2363723647 .payload = try block.sema.addExtra(Air.FieldParentPtr{
2363823648 .field_ptr = casted_field_ptr,
23639 .field_index = @as(u32, @intCast(field_index)),
23649 .field_index = @intCast(field_index),
2364023650 }),
2364123651 } },
2364223652 });
......@@ -24295,7 +24305,7 @@ fn zirVarExtended(
2429524305 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);
2429624306 const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = 0 };
2429724307 const init_src: LazySrcLoc = .{ .node_offset_var_decl_init = 0 };
24298 const small = @as(Zir.Inst.ExtendedVar.Small, @bitCast(extended.small));
24308 const small: Zir.Inst.ExtendedVar.Small = @bitCast(extended.small);
2429924309
2430024310 var extra_index: usize = extra.end;
2430124311
......@@ -24310,7 +24320,7 @@ fn zirVarExtended(
2431024320 assert(!small.has_align);
2431124321
2431224322 const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: {
24313 const init_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
24323 const init_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2431424324 extra_index += 1;
2431524325 break :blk try sema.resolveInst(init_ref);
2431624326 } else .none;
......@@ -24387,7 +24397,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2438724397 if (val.isGenericPoison()) {
2438824398 break :blk null;
2438924399 }
24390 const alignment = @as(u32, @intCast(val.toUnsignedInt(mod)));
24400 const alignment: u32 = @intCast(val.toUnsignedInt(mod));
2439124401 try sema.validateAlign(block, align_src, alignment);
2439224402 if (alignment == target_util.defaultFunctionAlignment(target)) {
2439324403 break :blk .none;
......@@ -24395,7 +24405,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2439524405 break :blk Alignment.fromNonzeroByteUnits(alignment);
2439624406 }
2439724407 } else if (extra.data.bits.has_align_ref) blk: {
24398 const align_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
24408 const align_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2439924409 extra_index += 1;
2440024410 const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime-known") catch |err| switch (err) {
2440124411 error.GenericPoison => {
......@@ -24403,7 +24413,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2440324413 },
2440424414 else => |e| return e,
2440524415 };
24406 const alignment = @as(u32, @intCast(align_tv.val.toUnsignedInt(mod)));
24416 const alignment: u32 = @intCast(align_tv.val.toUnsignedInt(mod));
2440724417 try sema.validateAlign(block, align_src, alignment);
2440824418 if (alignment == target_util.defaultFunctionAlignment(target)) {
2440924419 break :blk .none;
......@@ -24425,7 +24435,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2442524435 }
2442624436 break :blk mod.toEnum(std.builtin.AddressSpace, val);
2442724437 } else if (extra.data.bits.has_addrspace_ref) blk: {
24428 const addrspace_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
24438 const addrspace_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2442924439 extra_index += 1;
2443024440 const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime-known") catch |err| switch (err) {
2443124441 error.GenericPoison => {
......@@ -24449,7 +24459,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2444924459 }
2445024460 break :blk .{ .explicit = try val.toIpString(ty, mod) };
2445124461 } else if (extra.data.bits.has_section_ref) blk: {
24452 const section_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
24462 const section_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2445324463 extra_index += 1;
2445424464 const section_name = sema.resolveConstStringIntern(block, section_src, section_ref, "linksection must be comptime-known") catch |err| switch (err) {
2445524465 error.GenericPoison => {
......@@ -24473,7 +24483,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2447324483 }
2447424484 break :blk mod.toEnum(std.builtin.CallingConvention, val);
2447524485 } else if (extra.data.bits.has_cc_ref) blk: {
24476 const cc_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
24486 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2447724487 extra_index += 1;
2447824488 const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime-known") catch |err| switch (err) {
2447924489 error.GenericPoison => {
......@@ -24497,7 +24507,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2449724507 const ty = val.toType();
2449824508 break :blk ty;
2449924509 } else if (extra.data.bits.has_ret_ty_ref) blk: {
24500 const ret_ty_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index]));
24510 const ret_ty_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
2450124511 extra_index += 1;
2450224512 const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) {
2450324513 error.GenericPoison => {
......@@ -24606,7 +24616,7 @@ fn zirWasmMemorySize(
2460624616 return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});
2460724617 }
2460824618
24609 const index = @as(u32, @intCast(try sema.resolveInt(block, index_src, extra.operand, Type.u32, "wasm memory size index must be comptime-known")));
24619 const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.operand, Type.u32, "wasm memory size index must be comptime-known"));
2461024620 try sema.requireRuntimeBlock(block, builtin_src, null);
2461124621 return block.addInst(.{
2461224622 .tag = .wasm_memory_size,
......@@ -24631,7 +24641,7 @@ fn zirWasmMemoryGrow(
2463124641 return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});
2463224642 }
2463324643
24634 const index = @as(u32, @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, "wasm memory size index must be comptime-known")));
24644 const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, "wasm memory size index must be comptime-known"));
2463524645 const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src);
2463624646
2463724647 try sema.requireRuntimeBlock(block, builtin_src, null);
......@@ -24671,7 +24681,7 @@ fn resolvePrefetchOptions(
2467124681
2467224682 return std.builtin.PrefetchOptions{
2467324683 .rw = mod.toEnum(std.builtin.PrefetchOptions.Rw, rw_val),
24674 .locality = @as(u2, @intCast(locality_val.toUnsignedInt(mod))),
24684 .locality = @intCast(locality_val.toUnsignedInt(mod)),
2467524685 .cache = mod.toEnum(std.builtin.PrefetchOptions.Cache, cache_val),
2467624686 };
2467724687}
......@@ -24870,7 +24880,7 @@ fn zirWorkItem(
2487024880 },
2487124881 }
2487224882
24873 const dimension = @as(u32, @intCast(try sema.resolveInt(block, dimension_src, extra.operand, Type.u32, "dimension must be comptime-known")));
24883 const dimension: u32 = @intCast(try sema.resolveInt(block, dimension_src, extra.operand, Type.u32, "dimension must be comptime-known"));
2487424884 try sema.requireRuntimeBlock(block, builtin_src, null);
2487524885
2487624886 return block.addInst(.{
......@@ -25412,7 +25422,7 @@ fn addSafetyCheckExtra(
2541225422 fail_block.instructions.items.len);
2541325423
2541425424 try sema.air_instructions.ensureUnusedCapacity(gpa, 3);
25415 const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len));
25425 const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len);
2541625426 const cond_br_inst = block_inst + 1;
2541725427 const br_inst = cond_br_inst + 1;
2541825428 sema.air_instructions.appendAssumeCapacity(.{
......@@ -25432,7 +25442,7 @@ fn addSafetyCheckExtra(
2543225442 .operand = ok,
2543325443 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
2543425444 .then_body_len = 1,
25435 .else_body_len = @as(u32, @intCast(fail_block.instructions.items.len)),
25445 .else_body_len = @intCast(fail_block.instructions.items.len),
2543625446 }),
2543725447 } },
2543825448 });
......@@ -25785,7 +25795,7 @@ fn fieldVal(
2578525795 try sema.resolveTypeFields(child_type);
2578625796 if (child_type.unionTagType(mod)) |enum_ty| {
2578725797 if (enum_ty.enumFieldIndex(field_name, mod)) |field_index_usize| {
25788 const field_index = @as(u32, @intCast(field_index_usize));
25798 const field_index: u32 = @intCast(field_index_usize);
2578925799 return Air.internedToRef((try mod.enumValueFieldIndex(enum_ty, field_index)).toIntern());
2579025800 }
2579125801 }
......@@ -25799,7 +25809,7 @@ fn fieldVal(
2579925809 }
2580025810 const field_index_usize = child_type.enumFieldIndex(field_name, mod) orelse
2580125811 return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name);
25802 const field_index = @as(u32, @intCast(field_index_usize));
25812 const field_index: u32 = @intCast(field_index_usize);
2580325813 const enum_val = try mod.enumValueFieldIndex(child_type, field_index);
2580425814 return Air.internedToRef(enum_val.toIntern());
2580525815 },
......@@ -26011,7 +26021,7 @@ fn fieldPtr(
2601126021 try sema.resolveTypeFields(child_type);
2601226022 if (child_type.unionTagType(mod)) |enum_ty| {
2601326023 if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| {
26014 const field_index_u32 = @as(u32, @intCast(field_index));
26024 const field_index_u32: u32 = @intCast(field_index);
2601526025 var anon_decl = try block.startAnonDecl();
2601626026 defer anon_decl.deinit();
2601726027 return sema.analyzeDeclRef(try anon_decl.finish(
......@@ -26032,7 +26042,7 @@ fn fieldPtr(
2603226042 const field_index = child_type.enumFieldIndex(field_name, mod) orelse {
2603326043 return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name);
2603426044 };
26035 const field_index_u32 = @as(u32, @intCast(field_index));
26045 const field_index_u32: u32 = @intCast(field_index);
2603626046 var anon_decl = try block.startAnonDecl();
2603726047 defer anon_decl.deinit();
2603826048 return sema.analyzeDeclRef(try anon_decl.finish(
......@@ -26117,7 +26127,7 @@ fn fieldCallBind(
2611726127 if (mod.typeToStruct(concrete_ty)) |struct_obj| {
2611826128 const field_index_usize = struct_obj.fields.getIndex(field_name) orelse
2611926129 break :find_field;
26120 const field_index = @as(u32, @intCast(field_index_usize));
26130 const field_index: u32 = @intCast(field_index_usize);
2612126131 const field = struct_obj.fields.values()[field_index];
2612226132
2612326133 return sema.finishFieldCallBind(block, src, ptr_ty, field.ty, field_index, object_ptr);
......@@ -26132,7 +26142,7 @@ fn fieldCallBind(
2613226142 } else {
2613326143 const max = concrete_ty.structFieldCount(mod);
2613426144 for (0..max) |i_usize| {
26135 const i = @as(u32, @intCast(i_usize));
26145 const i: u32 = @intCast(i_usize);
2613626146 if (field_name == concrete_ty.structFieldName(i, mod)) {
2613726147 return sema.finishFieldCallBind(block, src, ptr_ty, concrete_ty.structFieldType(i, mod), i, object_ptr);
2613826148 }
......@@ -26364,7 +26374,7 @@ fn structFieldPtr(
2636426374
2636526375 const field_index_big = struct_obj.fields.getIndex(field_name) orelse
2636626376 return sema.failWithBadStructFieldAccess(block, struct_obj, field_name_src, field_name);
26367 const field_index = @as(u32, @intCast(field_index_big));
26377 const field_index: u32 = @intCast(field_index_big);
2636826378
2636926379 return sema.structFieldPtrByIndex(block, src, struct_ptr, field_index, field_name_src, struct_ty, initializing);
2637026380}
......@@ -26413,7 +26423,7 @@ fn structFieldPtrByIndex(
2641326423 if (i == field_index) {
2641426424 ptr_ty_data.packed_offset.bit_offset = running_bits;
2641526425 }
26416 running_bits += @as(u16, @intCast(f.ty.bitSize(mod)));
26426 running_bits += @intCast(f.ty.bitSize(mod));
2641726427 }
2641826428 ptr_ty_data.packed_offset.host_size = (running_bits + 7) / 8;
2641926429
......@@ -26441,7 +26451,7 @@ fn structFieldPtrByIndex(
2644126451 const elem_size_bits = ptr_ty_data.child.toType().bitSize(mod);
2644226452 if (elem_size_bytes * 8 == elem_size_bits) {
2644326453 const byte_offset = ptr_ty_data.packed_offset.bit_offset / 8;
26444 const new_align = @as(Alignment, @enumFromInt(@ctz(byte_offset | parent_align)));
26454 const new_align: Alignment = @enumFromInt(@ctz(byte_offset | parent_align));
2644526455 assert(new_align != .none);
2644626456 ptr_ty_data.flags.alignment = new_align;
2644726457 ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 };
......@@ -26505,7 +26515,7 @@ fn structFieldVal(
2650526515
2650626516 const field_index_usize = struct_obj.fields.getIndex(field_name) orelse
2650726517 return sema.failWithBadStructFieldAccess(block, struct_obj, field_name_src, field_name);
26508 const field_index = @as(u32, @intCast(field_index_usize));
26518 const field_index: u32 = @intCast(field_index_usize);
2650926519 const field = struct_obj.fields.values()[field_index];
2651026520
2651126521 if (field.is_comptime) {
......@@ -26815,7 +26825,7 @@ fn elemPtr(
2681526825 .Struct => {
2681626826 // Tuple field access.
2681726827 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known");
26818 const index = @as(u32, @intCast(index_val.toUnsignedInt(mod)));
26828 const index: u32 = @intCast(index_val.toUnsignedInt(mod));
2681926829 return sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init);
2682026830 },
2682126831 else => {
......@@ -26850,7 +26860,7 @@ fn elemPtrOneLayerOnly(
2685026860 const runtime_src = rs: {
2685126861 const ptr_val = maybe_ptr_val orelse break :rs indexable_src;
2685226862 const index_val = maybe_index_val orelse break :rs elem_index_src;
26853 const index = @as(usize, @intCast(index_val.toUnsignedInt(mod)));
26863 const index: usize = @intCast(index_val.toUnsignedInt(mod));
2685426864 const result_ty = try sema.elemPtrType(indexable_ty, index);
2685526865 const elem_ptr = try ptr_val.elemPtr(result_ty, index, mod);
2685626866 return Air.internedToRef(elem_ptr.toIntern());
......@@ -26869,7 +26879,7 @@ fn elemPtrOneLayerOnly(
2686926879 .Struct => {
2687026880 assert(child_ty.isTuple(mod));
2687126881 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known");
26872 const index = @as(u32, @intCast(index_val.toUnsignedInt(mod)));
26882 const index: u32 = @intCast(index_val.toUnsignedInt(mod));
2687326883 return sema.tupleFieldPtr(block, indexable_src, indexable, elem_index_src, index, false);
2687426884 },
2687526885 else => unreachable, // Guaranteed by checkIndexable
......@@ -26907,7 +26917,7 @@ fn elemVal(
2690726917 const runtime_src = rs: {
2690826918 const indexable_val = maybe_indexable_val orelse break :rs indexable_src;
2690926919 const index_val = maybe_index_val orelse break :rs elem_index_src;
26910 const index = @as(usize, @intCast(index_val.toUnsignedInt(mod)));
26920 const index: usize = @intCast(index_val.toUnsignedInt(mod));
2691126921 const elem_ty = indexable_ty.elemType2(mod);
2691226922 const many_ptr_ty = try mod.manyConstPtrType(elem_ty);
2691326923 const many_ptr_val = try mod.getCoerced(indexable_val, many_ptr_ty);
......@@ -26944,7 +26954,7 @@ fn elemVal(
2694426954 .Struct => {
2694526955 // Tuple field access.
2694626956 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known");
26947 const index = @as(u32, @intCast(index_val.toUnsignedInt(mod)));
26957 const index: u32 = @intCast(index_val.toUnsignedInt(mod));
2694826958 return sema.tupleField(block, indexable_src, indexable, elem_index_src, index);
2694926959 },
2695026960 else => unreachable,
......@@ -27105,7 +27115,7 @@ fn elemValArray(
2710527115 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
2710627116
2710727117 if (maybe_index_val) |index_val| {
27108 const index = @as(usize, @intCast(index_val.toUnsignedInt(mod)));
27118 const index: usize = @intCast(index_val.toUnsignedInt(mod));
2710927119 if (array_sent) |s| {
2711027120 if (index == array_len) {
2711127121 return Air.internedToRef(s.toIntern());
......@@ -27121,7 +27131,7 @@ fn elemValArray(
2712127131 return mod.undefRef(elem_ty);
2712227132 }
2712327133 if (maybe_index_val) |index_val| {
27124 const index = @as(usize, @intCast(index_val.toUnsignedInt(mod)));
27134 const index: usize = @intCast(index_val.toUnsignedInt(mod));
2712527135 const elem_val = try array_val.elemValue(mod, index);
2712627136 return Air.internedToRef(elem_val.toIntern());
2712727137 }
......@@ -27234,7 +27244,7 @@ fn elemValSlice(
2723427244 return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{});
2723527245 }
2723627246 if (maybe_index_val) |index_val| {
27237 const index = @as(usize, @intCast(index_val.toUnsignedInt(mod)));
27247 const index: usize = @intCast(index_val.toUnsignedInt(mod));
2723827248 if (index >= slice_len_s) {
2723927249 const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else "";
2724027250 return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label });
......@@ -27878,7 +27888,7 @@ fn coerceExtra(
2787827888 };
2787927889 return sema.failWithOwnedErrorMsg(msg);
2788027890 };
27881 return Air.internedToRef((try mod.enumValueFieldIndex(dest_ty, @as(u32, @intCast(field_index)))).toIntern());
27891 return Air.internedToRef((try mod.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern());
2788227892 },
2788327893 .Union => blk: {
2788427894 // union to its own tag type
......@@ -28282,8 +28292,8 @@ const InMemoryCoercionResult = union(enum) {
2828228292 var index: u6 = 0;
2828328293 var actual_noalias = false;
2828428294 while (true) : (index += 1) {
28285 const actual = @as(u1, @truncate(param.actual >> index));
28286 const wanted = @as(u1, @truncate(param.wanted >> index));
28295 const actual: u1 = @truncate(param.actual >> index);
28296 const wanted: u1 = @truncate(param.wanted >> index);
2828728297 if (actual != wanted) {
2828828298 actual_noalias = actual == 1;
2828928299 break;
......@@ -29446,7 +29456,7 @@ fn beginComptimePtrMutation(
2944629456 // bytes.len may be one greater than dest_len because of the case when
2944729457 // assigning `[N:S]T` to `[N]T`. This is allowed; the sentinel is omitted.
2944829458 assert(bytes.len >= dest_len);
29449 const elems = try arena.alloc(Value, @as(usize, @intCast(dest_len)));
29459 const elems = try arena.alloc(Value, @intCast(dest_len));
2945029460 for (elems, 0..) |*elem, i| {
2945129461 elem.* = try mod.intValue(elem_ty, bytes[i]);
2945229462 }
......@@ -29458,7 +29468,7 @@ fn beginComptimePtrMutation(
2945829468 block,
2945929469 src,
2946029470 elem_ty,
29461 &elems[@as(usize, @intCast(elem_ptr.index))],
29471 &elems[@intCast(elem_ptr.index)],
2946229472 ptr_elem_ty,
2946329473 parent.mut_decl,
2946429474 );
......@@ -29486,7 +29496,7 @@ fn beginComptimePtrMutation(
2948629496 block,
2948729497 src,
2948829498 elem_ty,
29489 &elems[@as(usize, @intCast(elem_ptr.index))],
29499 &elems[@intCast(elem_ptr.index)],
2949029500 ptr_elem_ty,
2949129501 parent.mut_decl,
2949229502 );
......@@ -29497,7 +29507,7 @@ fn beginComptimePtrMutation(
2949729507 block,
2949829508 src,
2949929509 elem_ty,
29500 &val_ptr.castTag(.aggregate).?.data[@as(usize, @intCast(elem_ptr.index))],
29510 &val_ptr.castTag(.aggregate).?.data[@intCast(elem_ptr.index)],
2950129511 ptr_elem_ty,
2950229512 parent.mut_decl,
2950329513 ),
......@@ -29523,7 +29533,7 @@ fn beginComptimePtrMutation(
2952329533 block,
2952429534 src,
2952529535 elem_ty,
29526 &elems[@as(usize, @intCast(elem_ptr.index))],
29536 &elems[@intCast(elem_ptr.index)],
2952729537 ptr_elem_ty,
2952829538 parent.mut_decl,
2952929539 );
......@@ -29578,7 +29588,7 @@ fn beginComptimePtrMutation(
2957829588 },
2957929589 .field => |field_ptr| {
2958029590 const base_child_ty = mod.intern_pool.typeOf(field_ptr.base).toType().childType(mod);
29581 const field_index = @as(u32, @intCast(field_ptr.index));
29591 const field_index: u32 = @intCast(field_ptr.index);
2958229592
2958329593 var parent = try sema.beginComptimePtrMutation(block, src, field_ptr.base.toValue(), base_child_ty);
2958429594 switch (parent.pointee) {
......@@ -30015,12 +30025,12 @@ fn beginComptimePtrLoad(
3001530025 }
3001630026 deref.pointee = TypedValue{
3001730027 .ty = elem_ty,
30018 .val = try array_tv.val.elemValue(mod, @as(usize, @intCast(elem_ptr.index))),
30028 .val = try array_tv.val.elemValue(mod, @intCast(elem_ptr.index)),
3001930029 };
3002030030 break :blk deref;
3002130031 },
3002230032 .field => |field_ptr| blk: {
30023 const field_index = @as(u32, @intCast(field_ptr.index));
30033 const field_index: u32 = @intCast(field_ptr.index);
3002430034 const container_ty = mod.intern_pool.typeOf(field_ptr.base).toType().childType(mod);
3002530035 var deref = try sema.beginComptimePtrLoad(block, src, field_ptr.base.toValue(), container_ty);
3002630036
......@@ -30602,7 +30612,7 @@ fn coerceTupleToArray(
3060230612
3060330613 var runtime_src: ?LazySrcLoc = null;
3060430614 for (element_vals, element_refs, 0..) |*val, *ref, i_usize| {
30605 const i = @as(u32, @intCast(i_usize));
30615 const i: u32 = @intCast(i_usize);
3060630616 if (i_usize == inst_len) {
3060730617 const sentinel_val = dest_ty.sentinel(mod).?;
3060830618 val.* = sentinel_val.toIntern();
......@@ -30713,7 +30723,7 @@ fn coerceTupleToStruct(
3071330723 else => unreachable,
3071430724 };
3071530725 for (0..field_count) |field_index_usize| {
30716 const field_i = @as(u32, @intCast(field_index_usize));
30726 const field_i: u32 = @intCast(field_index_usize);
3071730727 const field_src = inst_src; // TODO better source location
3071830728 // https://github.com/ziglang/zig/issues/15709
3071930729 const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) {
......@@ -30829,7 +30839,7 @@ fn coerceTupleToTuple(
3082930839
3083030840 var runtime_src: ?LazySrcLoc = null;
3083130841 for (0..dest_field_count) |field_index_usize| {
30832 const field_i = @as(u32, @intCast(field_index_usize));
30842 const field_i: u32 = @intCast(field_index_usize);
3083330843 const field_src = inst_src; // TODO better source location
3083430844 // https://github.com/ziglang/zig/issues/15709
3083530845 const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) {
......@@ -32185,7 +32195,7 @@ fn compareIntsOnlyPossibleResult(
3218532195
3218632196 const ty = try mod.intType(
3218732197 if (is_negative) .signed else .unsigned,
32188 @as(u16, @intCast(req_bits)),
32198 @intCast(req_bits),
3218932199 );
3219032200 const pop_count = lhs_val.popCount(ty, mod);
3219132201
......@@ -32960,7 +32970,7 @@ fn resolvePeerTypesInner(
3296032970 };
3296132971
3296232972 return .{ .success = try mod.vectorType(.{
32963 .len = @as(u32, @intCast(len.?)),
32973 .len = @intCast(len.?),
3296432974 .child = child_ty.toIntern(),
3296532975 }) };
3296632976 },
......@@ -34090,7 +34100,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void {
3409034100
3409134101 for (struct_obj.fields.values(), 0..) |field, i| {
3409234102 optimized_order[i] = if (try sema.typeHasRuntimeBits(field.ty))
34093 @as(u32, @intCast(i))
34103 @intCast(i)
3409434104 else
3409534105 Module.Struct.omitted_field;
3409634106 }
......@@ -34131,7 +34141,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi
3413134141 const zir = mod.namespacePtr(struct_obj.namespace).file_scope.zir;
3413234142 const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended;
3413334143 assert(extended.opcode == .struct_decl);
34134 const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small));
34144 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
3413534145
3413634146 if (small.has_backing_int) {
3413734147 var extra_index: usize = extended.operand;
......@@ -34182,7 +34192,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi
3418234192 const backing_int_src: LazySrcLoc = .{ .node_offset_container_tag = 0 };
3418334193 const backing_int_ty = blk: {
3418434194 if (backing_int_body_len == 0) {
34185 const backing_int_ref = @as(Zir.Inst.Ref, @enumFromInt(zir.extra[extra_index]));
34195 const backing_int_ref: Zir.Inst.Ref = @enumFromInt(zir.extra[extra_index]);
3418634196 break :blk try sema.resolveType(&block, backing_int_src, backing_int_ref);
3418734197 } else {
3418834198 const body = zir.extra[extra_index..][0..backing_int_body_len];
......@@ -34228,7 +34238,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi
3422834238 };
3422934239 return sema.fail(&block, LazySrcLoc.nodeOffset(0), "size of packed struct '{d}' exceeds maximum bit width of 65535", .{fields_bit_sum});
3423034240 }
34231 struct_obj.backing_int_ty = try mod.intType(.unsigned, @as(u16, @intCast(fields_bit_sum)));
34241 struct_obj.backing_int_ty = try mod.intType(.unsigned, @intCast(fields_bit_sum));
3423234242 }
3423334243}
3423434244
......@@ -34789,7 +34799,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3478934799 const zir = mod.namespacePtr(struct_obj.namespace).file_scope.zir;
3479034800 const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended;
3479134801 assert(extended.opcode == .struct_decl);
34792 const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small));
34802 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
3479334803 var extra_index: usize = extended.operand;
3479434804
3479534805 const src = LazySrcLoc.nodeOffset(0);
......@@ -34917,7 +34927,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3491734927 if (has_type_body) {
3491834928 fields[field_i].type_body_len = zir.extra[extra_index];
3491934929 } else {
34920 fields[field_i].type_ref = @as(Zir.Inst.Ref, @enumFromInt(zir.extra[extra_index]));
34930 fields[field_i].type_ref = @enumFromInt(zir.extra[extra_index]);
3492134931 }
3492234932 extra_index += 1;
3492334933
......@@ -36076,13 +36086,12 @@ pub fn addExtra(sema: *Sema, extra: anytype) Allocator.Error!u32 {
3607636086
3607736087pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {
3607836088 const fields = std.meta.fields(@TypeOf(extra));
36079 const result = @as(u32, @intCast(sema.air_extra.items.len));
36089 const result: u32 = @intCast(sema.air_extra.items.len);
3608036090 inline for (fields) |field| {
3608136091 sema.air_extra.appendAssumeCapacity(switch (field.type) {
3608236092 u32 => @field(extra, field.name),
36083 Air.Inst.Ref => @intFromEnum(@field(extra, field.name)),
36084 i32 => @as(u32, @bitCast(@field(extra, field.name))),
36085 InternPool.Index => @intFromEnum(@field(extra, field.name)),
36093 i32 => @bitCast(@field(extra, field.name)),
36094 Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(extra, field.name)),
3608636095 else => @compileError("bad field type: " ++ @typeName(field.type)),
3608736096 });
3608836097 }
......@@ -36090,8 +36099,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {
3609036099}
3609136100
3609236101fn appendRefsAssumeCapacity(sema: *Sema, refs: []const Air.Inst.Ref) void {
36093 const coerced = @as([]const u32, @ptrCast(refs));
36094 sema.air_extra.appendSliceAssumeCapacity(coerced);
36102 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(refs));
3609536103}
3609636104
3609736105fn getBreakBlock(sema: *Sema, inst_index: Air.Inst.Index) ?Air.Inst.Index {
......@@ -36547,7 +36555,7 @@ fn structFieldAlignment(sema: *Sema, field: Module.Struct.Field, layout: std.bui
3654736555 const mod = sema.mod;
3654836556 if (field.abi_align.toByteUnitsOptional()) |a| {
3654936557 assert(layout != .Packed);
36550 return @as(u32, @intCast(a));
36558 return @intCast(a);
3655136559 }
3655236560 switch (layout) {
3655336561 .Packed => return 0,
......@@ -36612,7 +36620,7 @@ fn structFieldIndex(
3661236620 const struct_obj = mod.typeToStruct(struct_ty).?;
3661336621 const field_index_usize = struct_obj.fields.getIndex(field_name) orelse
3661436622 return sema.failWithBadStructFieldAccess(block, struct_obj, field_src, field_name);
36615 return @as(u32, @intCast(field_index_usize));
36623 return @intCast(field_index_usize);
3661636624 }
3661736625}
3661836626
......@@ -36626,12 +36634,12 @@ fn anonStructFieldIndex(
3662636634 const mod = sema.mod;
3662736635 switch (mod.intern_pool.indexToKey(struct_ty.toIntern())) {
3662836636 .anon_struct_type => |anon_struct_type| for (anon_struct_type.names, 0..) |name, i| {
36629 if (name == field_name) return @as(u32, @intCast(i));
36637 if (name == field_name) return @intCast(i);
3663036638 },
3663136639 .struct_type => |struct_type| if (mod.structPtrUnwrap(struct_type.index)) |struct_obj| {
3663236640 for (struct_obj.fields.keys(), 0..) |name, i| {
3663336641 if (name == field_name) {
36634 return @as(u32, @intCast(i));
36642 return @intCast(i);
3663536643 }
3663636644 }
3663736645 },
......@@ -37229,9 +37237,9 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {
3722937237 if (!is_packed) break :blk .{};
3723037238
3723137239 break :blk .{
37232 .host_size = @as(u16, @intCast(parent_ty.arrayLen(mod))),
37233 .alignment = @as(u32, @intCast(parent_ty.abiAlignment(mod))),
37234 .vector_index = if (offset) |some| @as(VI, @enumFromInt(some)) else .runtime,
37240 .host_size = @intCast(parent_ty.arrayLen(mod)),
37241 .alignment = @intCast(parent_ty.abiAlignment(mod)),
37242 .vector_index = if (offset) |some| @enumFromInt(some) else .runtime,
3723537243 };
3723637244 } else .{};
3723737245
......@@ -37250,10 +37258,10 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {
3725037258 // The resulting pointer is aligned to the lcd between the offset (an
3725137259 // arbitrary number) and the alignment factor (always a power of two,
3725237260 // non zero).
37253 const new_align = @as(Alignment, @enumFromInt(@min(
37261 const new_align: Alignment = @enumFromInt(@min(
3725437262 @ctz(addend),
3725537263 @intFromEnum(ptr_info.flags.alignment),
37256 )));
37264 ));
3725737265 assert(new_align != .none);
3725837266 break :a new_align;
3725937267 };