authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-14 09:10:53+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-19 11:11:49+00:00
logb35589343894791a48b1423aa6d4a59b4858dfdb
tree62fb0542c4e49dd8748294bcfb75cf0c12fa5e23
parent172c2797bdd5f939e53acc26ea6820896e62733a
signature Commit is signed but in an unrecognized format.

compiler: correct unnecessary uses of 'var'


47 files changed, 210 insertions(+), 202 deletions(-)

src/Air.zig+1-1
......@@ -1787,7 +1787,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
17871787 => false,
17881788
17891789 .assembly => {
1790 var extra = air.extraData(Air.Asm, data.ty_pl.payload);
1790 const extra = air.extraData(Air.Asm, data.ty_pl.payload);
17911791 const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
17921792 return is_volatile or if (extra.data.outputs_len == 1)
17931793 @as(Air.Inst.Ref, @enumFromInt(air.extra[extra.end])) != .none
src/AstGen.zig+2-2
......@@ -6707,7 +6707,7 @@ fn forExpr(
67076707 };
67086708 }
67096709
6710 var then_node = for_full.ast.then_expr;
6710 const then_node = for_full.ast.then_expr;
67116711 var then_scope = parent_gz.makeSubBlock(&cond_scope.base);
67126712 defer then_scope.unstack();
67136713
......@@ -8160,7 +8160,7 @@ fn typeOf(
81608160 }
81618161 const payload_size: u32 = std.meta.fields(Zir.Inst.TypeOfPeer).len;
81628162 const payload_index = try reserveExtra(astgen, payload_size + args.len);
8163 var args_index = payload_index + payload_size;
8163 const args_index = payload_index + payload_size;
81648164
81658165 const typeof_inst = try gz.addExtendedMultiOpPayloadIndex(.typeof_peer, payload_index, args.len);
81668166
src/Autodoc.zig+50-50
......@@ -985,7 +985,7 @@ fn walkInstruction(
985985 },
986986 .import => {
987987 const str_tok = data[@intFromEnum(inst)].str_tok;
988 var path = str_tok.get(file.zir);
988 const path = str_tok.get(file.zir);
989989
990990 // importFile cannot error out since all files
991991 // are already loaded at this point
......@@ -1210,7 +1210,7 @@ fn walkInstruction(
12101210 .compile_error => {
12111211 const un_node = data[@intFromEnum(inst)].un_node;
12121212
1213 var operand: DocData.WalkResult = try self.walkRef(
1213 const operand: DocData.WalkResult = try self.walkRef(
12141214 file,
12151215 parent_scope,
12161216 parent_src,
......@@ -1252,7 +1252,7 @@ fn walkInstruction(
12521252 const byte_count = str.len * @sizeOf(std.math.big.Limb);
12531253 const limb_bytes = file.zir.string_bytes[str.start..][0..byte_count];
12541254
1255 var limbs = try self.arena.alloc(std.math.big.Limb, str.len);
1255 const limbs = try self.arena.alloc(std.math.big.Limb, str.len);
12561256 @memcpy(std.mem.sliceAsBytes(limbs)[0..limb_bytes.len], limb_bytes);
12571257
12581258 const big_int = std.math.big.int.Const{
......@@ -1281,7 +1281,7 @@ fn walkInstruction(
12811281 const slice_index = self.exprs.items.len;
12821282 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
12831283
1284 var lhs: DocData.WalkResult = try self.walkRef(
1284 const lhs: DocData.WalkResult = try self.walkRef(
12851285 file,
12861286 parent_scope,
12871287 parent_src,
......@@ -1289,7 +1289,7 @@ fn walkInstruction(
12891289 false,
12901290 call_ctx,
12911291 );
1292 var start: DocData.WalkResult = try self.walkRef(
1292 const start: DocData.WalkResult = try self.walkRef(
12931293 file,
12941294 parent_scope,
12951295 parent_src,
......@@ -1321,7 +1321,7 @@ fn walkInstruction(
13211321 const slice_index = self.exprs.items.len;
13221322 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
13231323
1324 var lhs: DocData.WalkResult = try self.walkRef(
1324 const lhs: DocData.WalkResult = try self.walkRef(
13251325 file,
13261326 parent_scope,
13271327 parent_src,
......@@ -1329,7 +1329,7 @@ fn walkInstruction(
13291329 false,
13301330 call_ctx,
13311331 );
1332 var start: DocData.WalkResult = try self.walkRef(
1332 const start: DocData.WalkResult = try self.walkRef(
13331333 file,
13341334 parent_scope,
13351335 parent_src,
......@@ -1337,7 +1337,7 @@ fn walkInstruction(
13371337 false,
13381338 call_ctx,
13391339 );
1340 var end: DocData.WalkResult = try self.walkRef(
1340 const end: DocData.WalkResult = try self.walkRef(
13411341 file,
13421342 parent_scope,
13431343 parent_src,
......@@ -1371,7 +1371,7 @@ fn walkInstruction(
13711371 const slice_index = self.exprs.items.len;
13721372 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
13731373
1374 var lhs: DocData.WalkResult = try self.walkRef(
1374 const lhs: DocData.WalkResult = try self.walkRef(
13751375 file,
13761376 parent_scope,
13771377 parent_src,
......@@ -1379,7 +1379,7 @@ fn walkInstruction(
13791379 false,
13801380 call_ctx,
13811381 );
1382 var start: DocData.WalkResult = try self.walkRef(
1382 const start: DocData.WalkResult = try self.walkRef(
13831383 file,
13841384 parent_scope,
13851385 parent_src,
......@@ -1387,7 +1387,7 @@ fn walkInstruction(
13871387 false,
13881388 call_ctx,
13891389 );
1390 var end: DocData.WalkResult = try self.walkRef(
1390 const end: DocData.WalkResult = try self.walkRef(
13911391 file,
13921392 parent_scope,
13931393 parent_src,
......@@ -1395,7 +1395,7 @@ fn walkInstruction(
13951395 false,
13961396 call_ctx,
13971397 );
1398 var sentinel: DocData.WalkResult = try self.walkRef(
1398 const sentinel: DocData.WalkResult = try self.walkRef(
13991399 file,
14001400 parent_scope,
14011401 parent_src,
......@@ -1436,7 +1436,7 @@ fn walkInstruction(
14361436 const slice_index = self.exprs.items.len;
14371437 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
14381438
1439 var lhs: DocData.WalkResult = try self.walkRef(
1439 const lhs: DocData.WalkResult = try self.walkRef(
14401440 file,
14411441 parent_scope,
14421442 parent_src,
......@@ -1444,7 +1444,7 @@ fn walkInstruction(
14441444 false,
14451445 call_ctx,
14461446 );
1447 var start: DocData.WalkResult = try self.walkRef(
1447 const start: DocData.WalkResult = try self.walkRef(
14481448 file,
14491449 parent_scope,
14501450 parent_src,
......@@ -1452,7 +1452,7 @@ fn walkInstruction(
14521452 false,
14531453 call_ctx,
14541454 );
1455 var len: DocData.WalkResult = try self.walkRef(
1455 const len: DocData.WalkResult = try self.walkRef(
14561456 file,
14571457 parent_scope,
14581458 parent_src,
......@@ -1460,7 +1460,7 @@ fn walkInstruction(
14601460 false,
14611461 call_ctx,
14621462 );
1463 var sentinel_opt: ?DocData.WalkResult = if (extra.data.sentinel != .none)
1463 const sentinel_opt: ?DocData.WalkResult = if (extra.data.sentinel != .none)
14641464 try self.walkRef(
14651465 file,
14661466 parent_scope,
......@@ -1574,7 +1574,7 @@ fn walkInstruction(
15741574 const binop_index = self.exprs.items.len;
15751575 try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });
15761576
1577 var lhs: DocData.WalkResult = try self.walkRef(
1577 const lhs: DocData.WalkResult = try self.walkRef(
15781578 file,
15791579 parent_scope,
15801580 parent_src,
......@@ -1582,7 +1582,7 @@ fn walkInstruction(
15821582 false,
15831583 call_ctx,
15841584 );
1585 var rhs: DocData.WalkResult = try self.walkRef(
1585 const rhs: DocData.WalkResult = try self.walkRef(
15861586 file,
15871587 parent_scope,
15881588 parent_src,
......@@ -1620,7 +1620,7 @@ fn walkInstruction(
16201620 const binop_index = self.exprs.items.len;
16211621 try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });
16221622
1623 var lhs: DocData.WalkResult = try self.walkRef(
1623 const lhs: DocData.WalkResult = try self.walkRef(
16241624 file,
16251625 parent_scope,
16261626 parent_src,
......@@ -1628,7 +1628,7 @@ fn walkInstruction(
16281628 false,
16291629 call_ctx,
16301630 );
1631 var rhs: DocData.WalkResult = try self.walkRef(
1631 const rhs: DocData.WalkResult = try self.walkRef(
16321632 file,
16331633 parent_scope,
16341634 parent_src,
......@@ -1786,7 +1786,7 @@ fn walkInstruction(
17861786 const pl_node = data[@intFromEnum(inst)].pl_node;
17871787 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
17881788
1789 var rhs: DocData.WalkResult = try self.walkRef(
1789 const rhs: DocData.WalkResult = try self.walkRef(
17901790 file,
17911791 parent_scope,
17921792 parent_src,
......@@ -1801,7 +1801,7 @@ fn walkInstruction(
18011801 const rhs_index = self.exprs.items.len;
18021802 try self.exprs.append(self.arena, rhs.expr);
18031803
1804 var lhs: DocData.WalkResult = try self.walkRef(
1804 const lhs: DocData.WalkResult = try self.walkRef(
18051805 file,
18061806 parent_scope,
18071807 parent_src,
......@@ -1850,7 +1850,7 @@ fn walkInstruction(
18501850 const binop_index = self.exprs.items.len;
18511851 try self.exprs.append(self.arena, .{ .builtinBin = .{ .lhs = 0, .rhs = 0 } });
18521852
1853 var lhs: DocData.WalkResult = try self.walkRef(
1853 const lhs: DocData.WalkResult = try self.walkRef(
18541854 file,
18551855 parent_scope,
18561856 parent_src,
......@@ -1858,7 +1858,7 @@ fn walkInstruction(
18581858 false,
18591859 call_ctx,
18601860 );
1861 var rhs: DocData.WalkResult = try self.walkRef(
1861 const rhs: DocData.WalkResult = try self.walkRef(
18621862 file,
18631863 parent_scope,
18641864 parent_src,
......@@ -1882,7 +1882,7 @@ fn walkInstruction(
18821882 const pl_node = data[@intFromEnum(inst)].pl_node;
18831883 const extra = file.zir.extraData(Zir.Inst.MulAdd, pl_node.payload_index);
18841884
1885 var mul1: DocData.WalkResult = try self.walkRef(
1885 const mul1: DocData.WalkResult = try self.walkRef(
18861886 file,
18871887 parent_scope,
18881888 parent_src,
......@@ -1890,7 +1890,7 @@ fn walkInstruction(
18901890 false,
18911891 call_ctx,
18921892 );
1893 var mul2: DocData.WalkResult = try self.walkRef(
1893 const mul2: DocData.WalkResult = try self.walkRef(
18941894 file,
18951895 parent_scope,
18961896 parent_src,
......@@ -1898,7 +1898,7 @@ fn walkInstruction(
18981898 false,
18991899 call_ctx,
19001900 );
1901 var add: DocData.WalkResult = try self.walkRef(
1901 const add: DocData.WalkResult = try self.walkRef(
19021902 file,
19031903 parent_scope,
19041904 parent_src,
......@@ -1914,7 +1914,7 @@ fn walkInstruction(
19141914 const add_index = self.exprs.items.len;
19151915 try self.exprs.append(self.arena, add.expr);
19161916
1917 var type_index: usize = self.exprs.items.len;
1917 const type_index: usize = self.exprs.items.len;
19181918 try self.exprs.append(self.arena, add.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) });
19191919
19201920 return DocData.WalkResult{
......@@ -1933,7 +1933,7 @@ fn walkInstruction(
19331933 const pl_node = data[@intFromEnum(inst)].pl_node;
19341934 const extra = file.zir.extraData(Zir.Inst.UnionInit, pl_node.payload_index);
19351935
1936 var union_type: DocData.WalkResult = try self.walkRef(
1936 const union_type: DocData.WalkResult = try self.walkRef(
19371937 file,
19381938 parent_scope,
19391939 parent_src,
......@@ -1941,7 +1941,7 @@ fn walkInstruction(
19411941 false,
19421942 call_ctx,
19431943 );
1944 var field_name: DocData.WalkResult = try self.walkRef(
1944 const field_name: DocData.WalkResult = try self.walkRef(
19451945 file,
19461946 parent_scope,
19471947 parent_src,
......@@ -1949,7 +1949,7 @@ fn walkInstruction(
19491949 false,
19501950 call_ctx,
19511951 );
1952 var init: DocData.WalkResult = try self.walkRef(
1952 const init: DocData.WalkResult = try self.walkRef(
19531953 file,
19541954 parent_scope,
19551955 parent_src,
......@@ -1980,7 +1980,7 @@ fn walkInstruction(
19801980 const pl_node = data[@intFromEnum(inst)].pl_node;
19811981 const extra = file.zir.extraData(Zir.Inst.BuiltinCall, pl_node.payload_index);
19821982
1983 var modifier: DocData.WalkResult = try self.walkRef(
1983 const modifier: DocData.WalkResult = try self.walkRef(
19841984 file,
19851985 parent_scope,
19861986 parent_src,
......@@ -1989,7 +1989,7 @@ fn walkInstruction(
19891989 call_ctx,
19901990 );
19911991
1992 var callee: DocData.WalkResult = try self.walkRef(
1992 const callee: DocData.WalkResult = try self.walkRef(
19931993 file,
19941994 parent_scope,
19951995 parent_src,
......@@ -1998,7 +1998,7 @@ fn walkInstruction(
19981998 call_ctx,
19991999 );
20002000
2001 var args: DocData.WalkResult = try self.walkRef(
2001 const args: DocData.WalkResult = try self.walkRef(
20022002 file,
20032003 parent_scope,
20042004 parent_src,
......@@ -2028,7 +2028,7 @@ fn walkInstruction(
20282028 const pl_node = data[@intFromEnum(inst)].pl_node;
20292029 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
20302030
2031 var lhs: DocData.WalkResult = try self.walkRef(
2031 const lhs: DocData.WalkResult = try self.walkRef(
20322032 file,
20332033 parent_scope,
20342034 parent_src,
......@@ -2036,7 +2036,7 @@ fn walkInstruction(
20362036 false,
20372037 call_ctx,
20382038 );
2039 var rhs: DocData.WalkResult = try self.walkRef(
2039 const rhs: DocData.WalkResult = try self.walkRef(
20402040 file,
20412041 parent_scope,
20422042 parent_src,
......@@ -2060,7 +2060,7 @@ fn walkInstruction(
20602060 const pl_node = data[@intFromEnum(inst)].pl_node;
20612061 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
20622062
2063 var lhs: DocData.WalkResult = try self.walkRef(
2063 const lhs: DocData.WalkResult = try self.walkRef(
20642064 file,
20652065 parent_scope,
20662066 parent_src,
......@@ -2068,7 +2068,7 @@ fn walkInstruction(
20682068 false,
20692069 call_ctx,
20702070 );
2071 var rhs: DocData.WalkResult = try self.walkRef(
2071 const rhs: DocData.WalkResult = try self.walkRef(
20722072 file,
20732073 parent_scope,
20742074 parent_src,
......@@ -2090,7 +2090,7 @@ fn walkInstruction(
20902090 // .elem_type => {
20912091 // const un_node = data[@intFromEnum(inst)].un_node;
20922092
2093 // var operand: DocData.WalkResult = try self.walkRef(
2093 // const operand: DocData.WalkResult = try self.walkRef(
20942094 // file,
20952095 // parent_scope, parent_src,
20962096 // un_node.operand,
......@@ -2158,7 +2158,7 @@ fn walkInstruction(
21582158 address_space = ref_result.expr;
21592159 extra_index += 1;
21602160 }
2161 var bit_start: ?DocData.Expr = null;
2161 const bit_start: ?DocData.Expr = null;
21622162 if (ptr.flags.has_bit_range) {
21632163 const ref = @as(Zir.Inst.Ref, @enumFromInt(file.zir.extra[extra_index]));
21642164 const ref_result = try self.walkRef(
......@@ -2292,7 +2292,7 @@ fn walkInstruction(
22922292 const array_data = try self.arena.alloc(usize, operands.len - 1);
22932293
22942294 std.debug.assert(operands.len > 0);
2295 var array_type = try self.walkRef(
2295 const array_type = try self.walkRef(
22962296 file,
22972297 parent_scope,
22982298 parent_src,
......@@ -2352,7 +2352,7 @@ fn walkInstruction(
23522352 const array_data = try self.arena.alloc(usize, operands.len - 1);
23532353
23542354 std.debug.assert(operands.len > 0);
2355 var array_type = try self.walkRef(
2355 const array_type = try self.walkRef(
23562356 file,
23572357 parent_scope,
23582358 parent_src,
......@@ -2578,7 +2578,7 @@ fn walkInstruction(
25782578 const pl_node = data[@intFromEnum(inst)].pl_node;
25792579 const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
25802580 const body = file.zir.extra[extra.end..][extra.data.body_len - 1];
2581 var operand: DocData.WalkResult = try self.walkRef(
2581 const operand: DocData.WalkResult = try self.walkRef(
25822582 file,
25832583 parent_scope,
25842584 parent_src,
......@@ -2903,7 +2903,7 @@ fn walkInstruction(
29032903 => {
29042904 const un_node = data[@intFromEnum(inst)].un_node;
29052905
2906 var operand: DocData.WalkResult = try self.walkRef(
2906 const operand: DocData.WalkResult = try self.walkRef(
29072907 file,
29082908 parent_scope,
29092909 parent_src,
......@@ -2920,7 +2920,7 @@ fn walkInstruction(
29202920 .struct_init_empty_ref_result => {
29212921 const un_node = data[@intFromEnum(inst)].un_node;
29222922
2923 var operand: DocData.WalkResult = try self.walkRef(
2923 const operand: DocData.WalkResult = try self.walkRef(
29242924 file,
29252925 parent_scope,
29262926 parent_src,
......@@ -3937,7 +3937,7 @@ fn walkInstruction(
39373937 try self.exprs.append(self.arena, last_type);
39383938
39393939 const ptr_index = self.exprs.items.len;
3940 var ptr: DocData.WalkResult = try self.walkRef(
3940 const ptr: DocData.WalkResult = try self.walkRef(
39413941 file,
39423942 parent_scope,
39433943 parent_src,
......@@ -3948,7 +3948,7 @@ fn walkInstruction(
39483948 try self.exprs.append(self.arena, ptr.expr);
39493949
39503950 const expected_value_index = self.exprs.items.len;
3951 var expected_value: DocData.WalkResult = try self.walkRef(
3951 const expected_value: DocData.WalkResult = try self.walkRef(
39523952 file,
39533953 parent_scope,
39543954 parent_src,
......@@ -3959,7 +3959,7 @@ fn walkInstruction(
39593959 try self.exprs.append(self.arena, expected_value.expr);
39603960
39613961 const new_value_index = self.exprs.items.len;
3962 var new_value: DocData.WalkResult = try self.walkRef(
3962 const new_value: DocData.WalkResult = try self.walkRef(
39633963 file,
39643964 parent_scope,
39653965 parent_src,
......@@ -3970,7 +3970,7 @@ fn walkInstruction(
39703970 try self.exprs.append(self.arena, new_value.expr);
39713971
39723972 const success_order_index = self.exprs.items.len;
3973 var success_order: DocData.WalkResult = try self.walkRef(
3973 const success_order: DocData.WalkResult = try self.walkRef(
39743974 file,
39753975 parent_scope,
39763976 parent_src,
......@@ -3981,7 +3981,7 @@ fn walkInstruction(
39813981 try self.exprs.append(self.arena, success_order.expr);
39823982
39833983 const failure_order_index = self.exprs.items.len;
3984 var failure_order: DocData.WalkResult = try self.walkRef(
3984 const failure_order: DocData.WalkResult = try self.walkRef(
39853985 file,
39863986 parent_scope,
39873987 parent_src,
src/Compilation.zig+6-6
......@@ -1759,7 +1759,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
17591759
17601760 const digest = hash.final();
17611761 const artifact_sub_dir = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
1762 var artifact_dir = try options.local_cache_directory.handle.makeOpenPath(artifact_sub_dir, .{});
1762 const artifact_dir = try options.local_cache_directory.handle.makeOpenPath(artifact_sub_dir, .{});
17631763 owned_link_dir = artifact_dir;
17641764 const link_artifact_directory: Directory = .{
17651765 .handle = artifact_dir,
......@@ -2173,7 +2173,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
21732173 // LLD might drop some symbols as unused during LTO and GCing, therefore,
21742174 // we force mark them for resolution here.
21752175
2176 var tls_index_sym = switch (comp.getTarget().cpu.arch) {
2176 const tls_index_sym = switch (comp.getTarget().cpu.arch) {
21772177 .x86 => "__tls_index",
21782178 else => "_tls_index",
21792179 };
......@@ -2576,7 +2576,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
25762576 var artifact_dir = try comp.local_cache_directory.handle.openDir(o_sub_path, .{});
25772577 defer artifact_dir.close();
25782578
2579 var dir_path = try comp.local_cache_directory.join(comp.gpa, &.{o_sub_path});
2579 const dir_path = try comp.local_cache_directory.join(comp.gpa, &.{o_sub_path});
25802580 defer comp.gpa.free(dir_path);
25812581
25822582 module.zig_cache_artifact_directory = .{
......@@ -4961,7 +4961,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
49614961
49624962 var cli_diagnostics = resinator.cli.Diagnostics.init(comp.gpa);
49634963 defer cli_diagnostics.deinit();
4964 var options = resinator.cli.parse(comp.gpa, resinator_args.items, &cli_diagnostics) catch |err| switch (err) {
4964 const options = resinator.cli.parse(comp.gpa, resinator_args.items, &cli_diagnostics) catch |err| switch (err) {
49654965 error.ParseError => {
49664966 return comp.failWin32ResourceCli(win32_resource, &cli_diagnostics);
49674967 },
......@@ -5062,7 +5062,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
50625062 log.warn("failed to delete '{s}': {s}", .{ out_dep_path, @errorName(err) });
50635063 };
50645064
5065 var full_input = std.fs.cwd().readFileAlloc(arena, out_rcpp_path, std.math.maxInt(usize)) catch |err| switch (err) {
5065 const full_input = std.fs.cwd().readFileAlloc(arena, out_rcpp_path, std.math.maxInt(usize)) catch |err| switch (err) {
50665066 error.OutOfMemory => return error.OutOfMemory,
50675067 else => |e| {
50685068 return comp.failWin32Resource(win32_resource, "failed to read preprocessed file '{s}': {s}", .{ out_rcpp_path, @errorName(e) });
......@@ -5072,7 +5072,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
50725072 var mapping_results = try resinator.source_mapping.parseAndRemoveLineCommands(arena, full_input, full_input, .{ .initial_filename = rc_src.src_path });
50735073 defer mapping_results.mappings.deinit(arena);
50745074
5075 var final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);
5075 const final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);
50765076
50775077 var output_file = zig_cache_tmp_dir.createFile(out_res_path, .{}) catch |err| {
50785078 return comp.failWin32Resource(win32_resource, "failed to create output file '{s}': {s}", .{ out_res_path, @errorName(err) });
src/Package/Fetch/git.zig+9-9
......@@ -83,7 +83,7 @@ pub const Repository = struct {
8383 ) !void {
8484 try repository.odb.seekOid(commit_oid);
8585 const tree_oid = tree_oid: {
86 var commit_object = try repository.odb.readObject();
86 const commit_object = try repository.odb.readObject();
8787 if (commit_object.type != .commit) return error.NotACommit;
8888 break :tree_oid try getCommitTree(commit_object.data);
8989 };
......@@ -122,14 +122,14 @@ pub const Repository = struct {
122122 var file = try dir.createFile(entry.name, .{});
123123 defer file.close();
124124 try repository.odb.seekOid(entry.oid);
125 var file_object = try repository.odb.readObject();
125 const file_object = try repository.odb.readObject();
126126 if (file_object.type != .blob) return error.InvalidFile;
127127 try file.writeAll(file_object.data);
128128 try file.sync();
129129 },
130130 .symlink => {
131131 try repository.odb.seekOid(entry.oid);
132 var symlink_object = try repository.odb.readObject();
132 const symlink_object = try repository.odb.readObject();
133133 if (symlink_object.type != .blob) return error.InvalidFile;
134134 const link_name = symlink_object.data;
135135 dir.symLink(link_name, entry.name, .{}) catch |e| {
......@@ -1230,7 +1230,7 @@ fn resolveDeltaChain(
12301230 const delta_offset = delta_offsets[i];
12311231 try pack.seekTo(delta_offset);
12321232 const delta_header = try EntryHeader.read(pack.reader());
1233 var delta_data = try readObjectRaw(allocator, pack.reader(), delta_header.uncompressedLength());
1233 const delta_data = try readObjectRaw(allocator, pack.reader(), delta_header.uncompressedLength());
12341234 defer allocator.free(delta_data);
12351235 var delta_stream = std.io.fixedBufferStream(delta_data);
12361236 const delta_reader = delta_stream.reader();
......@@ -1238,7 +1238,7 @@ fn resolveDeltaChain(
12381238 const expanded_size = try readSizeVarInt(delta_reader);
12391239
12401240 const expanded_alloc_size = std.math.cast(usize, expanded_size) orelse return error.ObjectTooLarge;
1241 var expanded_data = try allocator.alloc(u8, expanded_alloc_size);
1241 const expanded_data = try allocator.alloc(u8, expanded_alloc_size);
12421242 errdefer allocator.free(expanded_data);
12431243 var expanded_delta_stream = std.io.fixedBufferStream(expanded_data);
12441244 var base_stream = std.io.fixedBufferStream(base_data);
......@@ -1259,7 +1259,7 @@ fn readObjectRaw(allocator: Allocator, reader: anytype, size: u64) ![]u8 {
12591259 var buffered_reader = std.io.bufferedReader(reader);
12601260 var decompress_stream = try std.compress.zlib.decompressStream(allocator, buffered_reader.reader());
12611261 defer decompress_stream.deinit();
1262 var data = try allocator.alloc(u8, alloc_size);
1262 const data = try allocator.alloc(u8, alloc_size);
12631263 errdefer allocator.free(data);
12641264 try decompress_stream.reader().readNoEof(data);
12651265 _ = decompress_stream.reader().readByte() catch |e| switch (e) {
......@@ -1290,14 +1290,14 @@ fn expandDelta(base_object: anytype, delta_reader: anytype, writer: anytype) !vo
12901290 size2: bool,
12911291 size3: bool,
12921292 } = @bitCast(inst.value);
1293 var offset_parts: packed struct { offset1: u8, offset2: u8, offset3: u8, offset4: u8 } = .{
1293 const offset_parts: packed struct { offset1: u8, offset2: u8, offset3: u8, offset4: u8 } = .{
12941294 .offset1 = if (available.offset1) try delta_reader.readByte() else 0,
12951295 .offset2 = if (available.offset2) try delta_reader.readByte() else 0,
12961296 .offset3 = if (available.offset3) try delta_reader.readByte() else 0,
12971297 .offset4 = if (available.offset4) try delta_reader.readByte() else 0,
12981298 };
12991299 const offset: u32 = @bitCast(offset_parts);
1300 var size_parts: packed struct { size1: u8, size2: u8, size3: u8 } = .{
1300 const size_parts: packed struct { size1: u8, size2: u8, size3: u8 } = .{
13011301 .size1 = if (available.size1) try delta_reader.readByte() else 0,
13021302 .size2 = if (available.size2) try delta_reader.readByte() else 0,
13031303 .size3 = if (available.size3) try delta_reader.readByte() else 0,
......@@ -1414,7 +1414,7 @@ test "packfile indexing and checkout" {
14141414 defer walker.deinit();
14151415 while (try walker.next()) |entry| {
14161416 if (entry.kind != .file) continue;
1417 var path = try testing.allocator.dupe(u8, entry.path);
1417 const path = try testing.allocator.dupe(u8, entry.path);
14181418 errdefer testing.allocator.free(path);
14191419 mem.replaceScalar(u8, path, std.fs.path.sep, '/');
14201420 try actual_files.append(testing.allocator, path);
src/Sema.zig+9-9
......@@ -22899,7 +22899,7 @@ fn checkSimdBinOp(
2289922899 const rhs_ty = sema.typeOf(uncasted_rhs);
2290022900
2290122901 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
22902 var vec_len: ?usize = if (lhs_ty.zigTypeTag(mod) == .Vector) lhs_ty.vectorLen(mod) else null;
22902 const vec_len: ?usize = if (lhs_ty.zigTypeTag(mod) == .Vector) lhs_ty.vectorLen(mod) else null;
2290322903 const result_ty = try sema.resolvePeerTypes(block, src, &.{ uncasted_lhs, uncasted_rhs }, .{
2290422904 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },
2290522905 });
......@@ -23286,8 +23286,8 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2328623286
2328723287 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
2328823288 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
23289 var a = try sema.resolveInst(extra.a);
23290 var b = try sema.resolveInst(extra.b);
23289 const a = try sema.resolveInst(extra.a);
23290 const b = try sema.resolveInst(extra.b);
2329123291 var mask = try sema.resolveInst(extra.mask);
2329223292 var mask_ty = sema.typeOf(mask);
2329323293
......@@ -23328,7 +23328,7 @@ fn analyzeShuffle(
2332823328 .child = elem_ty.toIntern(),
2332923329 });
2333023330
23331 var maybe_a_len = switch (sema.typeOf(a).zigTypeTag(mod)) {
23331 const maybe_a_len = switch (sema.typeOf(a).zigTypeTag(mod)) {
2333223332 .Array, .Vector => sema.typeOf(a).arrayLen(mod),
2333323333 .Undefined => null,
2333423334 else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{
......@@ -23336,7 +23336,7 @@ fn analyzeShuffle(
2333623336 sema.typeOf(a).fmt(sema.mod),
2333723337 }),
2333823338 };
23339 var maybe_b_len = switch (sema.typeOf(b).zigTypeTag(mod)) {
23339 const maybe_b_len = switch (sema.typeOf(b).zigTypeTag(mod)) {
2334023340 .Array, .Vector => sema.typeOf(b).arrayLen(mod),
2334123341 .Undefined => null,
2334223342 else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{
......@@ -23801,7 +23801,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2380123801 const call_src = inst_data.src();
2380223802
2380323803 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
23804 var func = try sema.resolveInst(extra.callee);
23804 const func = try sema.resolveInst(extra.callee);
2380523805
2380623806 const modifier_ty = try sema.getBuiltinType("CallModifier");
2380723807 const air_ref = try sema.resolveInst(extra.modifier);
......@@ -23859,7 +23859,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2385923859 return sema.fail(block, args_src, "expected a tuple, found '{}'", .{args_ty.fmt(sema.mod)});
2386023860 }
2386123861
23862 var resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod));
23862 const resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod));
2386323863 for (resolved_args, 0..) |*resolved, i| {
2386423864 resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @intCast(i), args_ty);
2386523865 }
......@@ -33274,8 +33274,8 @@ fn resolvePeerTypes(
3327433274 else => {},
3327533275 }
3327633276
33277 var peer_tys = try sema.arena.alloc(?Type, instructions.len);
33278 var peer_vals = try sema.arena.alloc(?Value, instructions.len);
33277 const peer_tys = try sema.arena.alloc(?Type, instructions.len);
33278 const peer_vals = try sema.arena.alloc(?Value, instructions.len);
3327933279
3328033280 for (instructions, peer_tys, peer_vals) |inst, *ty, *val| {
3328133281 ty.* = sema.typeOf(inst);
src/arch/riscv64/CodeGen.zig+5
......@@ -2648,6 +2648,11 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
26482648 // conventions
26492649 var next_register: usize = 0;
26502650 var next_stack_offset: u32 = 0;
2651 // TODO: this is never assigned, which is a bug, but I don't know how this code works
2652 // well enough to try and fix it. I *think* `next_register += next_stack_offset` is
2653 // supposed to be `next_stack_offset += param_size` in every case where it appears.
2654 _ = &next_stack_offset;
2655
26512656 const argument_registers = [_]Register{ .a0, .a1, .a2, .a3, .a4, .a5, .a6, .a7 };
26522657
26532658 for (fn_info.param_types.get(ip), result.args) |ty, *result_arg| {
src/arch/sparc64/CodeGen.zig+4
......@@ -4481,6 +4481,10 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)
44814481
44824482 var next_register: usize = 0;
44834483 var next_stack_offset: u32 = 0;
4484 // TODO: this is never assigned, which is a bug, but I don't know how this code works
4485 // well enough to try and fix it. I *think* `next_register += next_stack_offset` is
4486 // supposed to be `next_stack_offset += param_size` in every case where it appears.
4487 _ = &next_stack_offset;
44844488
44854489 // The caller puts the argument in %o0-%o5, which becomes %i0-%i5 inside the callee.
44864490 const argument_registers = switch (role) {
src/arch/wasm/CodeGen.zig+4-4
......@@ -2139,7 +2139,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
21392139 const mod = func.bin_file.base.options.module.?;
21402140 const child_type = func.typeOfIndex(inst).childType(mod);
21412141
2142 var result = result: {
2142 const result = result: {
21432143 if (!child_type.isFnOrHasRuntimeBitsIgnoreComptime(mod)) {
21442144 break :result try func.allocStack(Type.usize); // create pointer to void
21452145 }
......@@ -5001,7 +5001,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
50015001 return func.finishAir(inst, try WValue.toLocal(.stack, func, elem_ty), &.{ bin_op.lhs, bin_op.rhs });
50025002 },
50035003 else => {
5004 var stack_vec = try func.allocStack(array_ty);
5004 const stack_vec = try func.allocStack(array_ty);
50055005 try func.store(stack_vec, array, array_ty, 0);
50065006
50075007 // Is a non-unrolled vector (v128)
......@@ -5944,7 +5944,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
59445944 rhs.free(func);
59455945 };
59465946
5947 var bin_op = try (try func.binOp(lhs, rhs, lhs_ty, op)).toLocal(func, lhs_ty);
5947 const bin_op = try (try func.binOp(lhs, rhs, lhs_ty, op)).toLocal(func, lhs_ty);
59485948 var result = if (wasm_bits != int_info.bits) blk: {
59495949 break :blk try (try func.wrapOperand(bin_op, lhs_ty)).toLocal(func, lhs_ty);
59505950 } else bin_op;
......@@ -6335,7 +6335,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
63356335 const lhs_ext = try func.fpext(lhs, ty, Type.f32);
63366336 const addend_ext = try func.fpext(addend, ty, Type.f32);
63376337 // call to compiler-rt `fn fmaf(f32, f32, f32) f32`
6338 var result = try func.callIntrinsic(
6338 const result = try func.callIntrinsic(
63396339 "fmaf",
63406340 &.{ .f32_type, .f32_type, .f32_type },
63416341 Type.f32,
src/arch/x86_64/CodeGen.zig+1-1
......@@ -2181,7 +2181,7 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
21812181 const ret_reg = param_regs[0];
21822182 const enum_mcv = MCValue{ .register = param_regs[1] };
21832183
2184 var exitlude_jump_relocs = try self.gpa.alloc(Mir.Inst.Index, enum_ty.enumFieldCount(mod));
2184 const exitlude_jump_relocs = try self.gpa.alloc(Mir.Inst.Index, enum_ty.enumFieldCount(mod));
21852185 defer self.gpa.free(exitlude_jump_relocs);
21862186
21872187 const data_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
src/arch/x86_64/Disassembler.zig+1-2
......@@ -234,13 +234,12 @@ fn inst(encoding: Encoding, args: struct {
234234 op3: Instruction.Operand = .none,
235235 op4: Instruction.Operand = .none,
236236}) Instruction {
237 var i = Instruction{ .encoding = encoding, .prefix = args.prefix, .ops = .{
237 return .{ .encoding = encoding, .prefix = args.prefix, .ops = .{
238238 args.op1,
239239 args.op2,
240240 args.op3,
241241 args.op4,
242242 } };
243 return i;
244243}
245244
246245const Prefixes = struct {
src/arch/x86_64/Lower.zig+1-1
......@@ -342,7 +342,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
342342 .Lib => lower.bin_file.options.link_mode == .Static,
343343 };
344344
345 var emit_prefix = prefix;
345 const emit_prefix = prefix;
346346 var emit_mnemonic = mnemonic;
347347 var emit_ops_storage: [4]Operand = undefined;
348348 const emit_ops = emit_ops_storage[0..ops.len];
src/arch/x86_64/encoder.zig+2-2
......@@ -244,7 +244,7 @@ pub const Instruction = struct {
244244 }),
245245 },
246246 .imm => |imm| if (enc_op.isSigned()) {
247 var imms = imm.asSigned(enc_op.immBitSize());
247 const imms = imm.asSigned(enc_op.immBitSize());
248248 if (imms < 0) try writer.writeByte('-');
249249 try writer.print("0x{x}", .{@abs(imms)});
250250 } else try writer.print("0x{x}", .{imm.asUnsigned(enc_op.immBitSize())}),
......@@ -1077,7 +1077,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8, assembly: []co
10771077 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{std.fmt.fmtSliceHexLower(given)});
10781078 defer testing.allocator.free(given_fmt);
10791079 const idx = std.mem.indexOfDiff(u8, expected_fmt, given_fmt).?;
1080 var padding = try testing.allocator.alloc(u8, idx + 5);
1080 const padding = try testing.allocator.alloc(u8, idx + 5);
10811081 defer testing.allocator.free(padding);
10821082 @memset(padding, ' ');
10831083 std.debug.print("\nASM: {s}\nEXP: {s}\nGIV: {s}\n{s}^ -- first differing byte\n", .{
src/aro_translate_c.zig+2-2
......@@ -346,7 +346,7 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void {
346346 defer block_scope.deinit();
347347
348348 var scope = &block_scope.base;
349 _ = scope;
349 _ = &scope;
350350
351351 var param_id: c_uint = 0;
352352 for (proto_payload.data.params, fn_ty.data.func.params) |*param, param_info| {
......@@ -534,7 +534,7 @@ fn transFnType(
534534 ctx: FnProtoContext,
535535) !ZigNode {
536536 const param_count: usize = fn_ty.data.func.params.len;
537 var fn_params = try c.arena.alloc(ast.Payload.Param, param_count);
537 const fn_params = try c.arena.alloc(ast.Payload.Param, param_count);
538538
539539 for (fn_ty.data.func.params, fn_params) |param_info, *param_node| {
540540 const param_ty = param_info.ty;
src/codegen.zig+1-1
......@@ -368,7 +368,7 @@ pub fn generateSymbol(
368368 .bytes => |bytes| try code.appendSlice(bytes),
369369 .elems, .repeated_elem => {
370370 var index: u64 = 0;
371 var len_including_sentinel =
371 const len_including_sentinel =
372372 array_type.len + @intFromBool(array_type.sentinel != .none);
373373 while (index < len_including_sentinel) : (index += 1) {
374374 switch (try generateSymbol(bin_file, src_loc, .{
src/codegen/llvm/BitcodeReader.zig+1-1
......@@ -410,7 +410,7 @@ fn readVbr(bc: *BitcodeReader, comptime T: type, bits: u7) !T {
410410 var result: u64 = 0;
411411 var shift: u6 = 0;
412412 while (true) {
413 var chunk = try bc.readFixed(u64, bits);
413 const chunk = try bc.readFixed(u64, bits);
414414 result |= (chunk & (chunk_msb - 1)) << shift;
415415 if (chunk & chunk_msb == 0) break;
416416 shift += chunk_bits;
src/codegen/spirv.zig+4-4
......@@ -1284,7 +1284,7 @@ const DeclGen = struct {
12841284
12851285 const elem_ty = ty.childType(mod);
12861286 const elem_ty_ref = try self.resolveType(elem_ty, .indirect);
1287 var total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(mod)) orelse {
1287 const total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(mod)) orelse {
12881288 return self.fail("array type of {} elements is too large", .{ty.arrayLenIncludingSentinel(mod)});
12891289 };
12901290 const ty_ref = if (!elem_ty.hasRuntimeBitsIgnoreComptime(mod)) blk: {
......@@ -2115,7 +2115,7 @@ const DeclGen = struct {
21152115 const child_ty = ty.childType(mod);
21162116 const vector_len = ty.vectorLen(mod);
21172117
2118 var constituents = try self.gpa.alloc(IdRef, vector_len);
2118 const constituents = try self.gpa.alloc(IdRef, vector_len);
21192119 defer self.gpa.free(constituents);
21202120
21212121 for (constituents, 0..) |*constituent, i| {
......@@ -2312,7 +2312,7 @@ const DeclGen = struct {
23122312 if (ty.isVector(mod)) {
23132313 const child_ty = ty.childType(mod);
23142314 const vector_len = ty.vectorLen(mod);
2315 var constituents = try self.gpa.alloc(IdRef, vector_len);
2315 const constituents = try self.gpa.alloc(IdRef, vector_len);
23162316 defer self.gpa.free(constituents);
23172317
23182318 for (constituents, 0..) |*constituent, i| {
......@@ -2727,7 +2727,7 @@ const DeclGen = struct {
27272727 const child_ty = ty.childType(mod);
27282728 const vector_len = ty.vectorLen(mod);
27292729
2730 var constituents = try self.gpa.alloc(IdRef, vector_len);
2730 const constituents = try self.gpa.alloc(IdRef, vector_len);
27312731 defer self.gpa.free(constituents);
27322732
27332733 for (constituents, 0..) |*constituent, i| {
src/link/C.zig+1-1
......@@ -103,7 +103,7 @@ pub fn openPath(gpa: Allocator, sub_path: []const u8, options: link.Options) !*C
103103 });
104104 errdefer file.close();
105105
106 var c_file = try gpa.create(C);
106 const c_file = try gpa.create(C);
107107 errdefer gpa.destroy(c_file);
108108
109109 c_file.* = .{
src/link/Coff.zig+5-5
......@@ -563,7 +563,7 @@ fn allocateAtom(self: *Coff, atom_index: Atom.Index, new_atom_size: u32, alignme
563563
564564 // First we look for an appropriately sized free list node.
565565 // The list is unordered. We'll just take the first thing that works.
566 var vaddr = blk: {
566 const vaddr = blk: {
567567 var i: usize = 0;
568568 while (i < free_list.items.len) {
569569 const big_atom_index = free_list.items[i];
......@@ -815,7 +815,7 @@ fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void {
815815}
816816
817817fn debugMem(allocator: Allocator, handle: std.ChildProcess.Id, pvaddr: std.os.windows.LPVOID, code: []const u8) !void {
818 var buffer = try allocator.alloc(u8, code.len);
818 const buffer = try allocator.alloc(u8, code.len);
819819 defer allocator.free(buffer);
820820 const memread = try std.os.windows.ReadProcessMemory(handle, pvaddr, buffer);
821821 log.debug("to write: {x}", .{std.fmt.fmtSliceHexLower(code)});
......@@ -1071,7 +1071,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:
10711071 &code_buffer,
10721072 .none,
10731073 );
1074 var code = switch (res) {
1074 const code = switch (res) {
10751075 .ok => code_buffer.items,
10761076 .fail => |em| {
10771077 decl.analysis = .codegen_failure;
......@@ -1132,7 +1132,7 @@ fn lowerConst(self: *Coff, name: []const u8, tv: TypedValue, required_alignment:
11321132 const res = try codegen.generateSymbol(&self.base, src_loc, tv, &code_buffer, .none, .{
11331133 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,
11341134 });
1135 var code = switch (res) {
1135 const code = switch (res) {
11361136 .ok => code_buffer.items,
11371137 .fail => |em| return .{ .fail = em },
11381138 };
......@@ -1196,7 +1196,7 @@ pub fn updateDecl(
11961196 }, &code_buffer, .none, .{
11971197 .parent_atom_index = atom.getSymbolIndex().?,
11981198 });
1199 var code = switch (res) {
1199 const code = switch (res) {
12001200 .ok => code_buffer.items,
12011201 .fail => |em| {
12021202 decl.analysis = .codegen_failure;
src/link/Dwarf.zig+3-3
......@@ -303,7 +303,7 @@ pub const DeclState = struct {
303303 // DW.AT.name, DW.FORM.string
304304 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});
305305 // DW.AT.type, DW.FORM.ref4
306 var index = dbg_info_buffer.items.len;
306 const index = dbg_info_buffer.items.len;
307307 try dbg_info_buffer.resize(index + 4);
308308 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));
309309 // DW.AT.data_member_location, DW.FORM.udata
......@@ -329,7 +329,7 @@ pub const DeclState = struct {
329329 // DW.AT.name, DW.FORM.string
330330 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});
331331 // DW.AT.type, DW.FORM.ref4
332 var index = dbg_info_buffer.items.len;
332 const index = dbg_info_buffer.items.len;
333333 try dbg_info_buffer.resize(index + 4);
334334 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));
335335 // DW.AT.data_member_location, DW.FORM.udata
......@@ -350,7 +350,7 @@ pub const DeclState = struct {
350350 dbg_info_buffer.appendSliceAssumeCapacity(field_name);
351351 dbg_info_buffer.appendAssumeCapacity(0);
352352 // DW.AT.type, DW.FORM.ref4
353 var index = dbg_info_buffer.items.len;
353 const index = dbg_info_buffer.items.len;
354354 try dbg_info_buffer.resize(index + 4);
355355 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));
356356 // DW.AT.data_member_location, DW.FORM.udata
src/link/Elf.zig+5-5
......@@ -967,7 +967,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
967967 // --verbose-link
968968 if (self.base.options.verbose_link) try self.dumpArgv(comp);
969969
970 var csu = try CsuObjects.init(arena, self.base.options, comp);
970 const csu = try CsuObjects.init(arena, self.base.options, comp);
971971 const compiler_rt_path: ?[]const u8 = blk: {
972972 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
973973 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
......@@ -1493,7 +1493,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
14931493 } else null;
14941494 const gc_sections = self.base.options.gc_sections orelse false;
14951495
1496 var csu = try CsuObjects.init(arena, self.base.options, comp);
1496 const csu = try CsuObjects.init(arena, self.base.options, comp);
14971497 const compiler_rt_path: ?[]const u8 = blk: {
14981498 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
14991499 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
......@@ -2599,7 +2599,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
25992599 try argv.append(full_out_path);
26002600
26012601 // csu prelude
2602 var csu = try CsuObjects.init(arena, self.base.options, comp);
2602 const csu = try CsuObjects.init(arena, self.base.options, comp);
26032603 if (csu.crt0) |v| try argv.append(v);
26042604 if (csu.crti) |v| try argv.append(v);
26052605 if (csu.crtbegin) |v| try argv.append(v);
......@@ -3852,7 +3852,7 @@ fn sortPhdrs(self: *Elf) error{OutOfMemory}!void {
38523852 backlinks[entry.phndx] = @as(u16, @intCast(i));
38533853 }
38543854
3855 var slice = try self.phdrs.toOwnedSlice(gpa);
3855 const slice = try self.phdrs.toOwnedSlice(gpa);
38563856 defer gpa.free(slice);
38573857
38583858 try self.phdrs.ensureTotalCapacityPrecise(gpa, slice.len);
......@@ -3957,7 +3957,7 @@ fn sortShdrs(self: *Elf) !void {
39573957 backlinks[entry.shndx] = @as(u16, @intCast(i));
39583958 }
39593959
3960 var slice = try self.shdrs.toOwnedSlice(gpa);
3960 const slice = try self.shdrs.toOwnedSlice(gpa);
39613961 defer gpa.free(slice);
39623962
39633963 try self.shdrs.ensureTotalCapacityPrecise(gpa, slice.len);
src/link/Elf/eh_frame.zig+1-1
......@@ -217,7 +217,7 @@ pub const Iterator = struct {
217217 var stream = std.io.fixedBufferStream(it.data[it.pos..]);
218218 const reader = stream.reader();
219219
220 var size = try reader.readInt(u32, .little);
220 const size = try reader.readInt(u32, .little);
221221 if (size == 0xFFFFFFFF) @panic("TODO");
222222
223223 const id = try reader.readInt(u32, .little);
src/link/MachO.zig+7-7
......@@ -2252,7 +2252,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air:
22522252 else
22532253 try codegen.generateFunction(&self.base, decl.srcLoc(mod), func_index, air, liveness, &code_buffer, .none);
22542254
2255 var code = switch (res) {
2255 const code = switch (res) {
22562256 .ok => code_buffer.items,
22572257 .fail => |em| {
22582258 decl.analysis = .codegen_failure;
......@@ -2332,7 +2332,7 @@ fn lowerConst(
23322332 const res = try codegen.generateSymbol(&self.base, src_loc, tv, &code_buffer, .none, .{
23332333 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,
23342334 });
2335 var code = switch (res) {
2335 const code = switch (res) {
23362336 .ok => code_buffer.items,
23372337 .fail => |em| return .{ .fail = em },
23382338 };
......@@ -2418,7 +2418,7 @@ pub fn updateDecl(self: *MachO, mod: *Module, decl_index: Module.Decl.Index) !vo
24182418 .parent_atom_index = sym_index,
24192419 });
24202420
2421 var code = switch (res) {
2421 const code = switch (res) {
24222422 .ok => code_buffer.items,
24232423 .fail => |em| {
24242424 decl.analysis = .codegen_failure;
......@@ -2587,7 +2587,7 @@ fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.D
25872587 .parent_atom_index = init_sym_index,
25882588 });
25892589
2590 var code = switch (res) {
2590 const code = switch (res) {
25912591 .ok => code_buffer.items,
25922592 .fail => |em| {
25932593 decl.analysis = .codegen_failure;
......@@ -3427,7 +3427,7 @@ fn allocateAtom(self: *MachO, atom_index: Atom.Index, new_atom_size: u64, alignm
34273427
34283428 // First we look for an appropriately sized free list node.
34293429 // The list is unordered. We'll just take the first thing that works.
3430 var vaddr = blk: {
3430 const vaddr = blk: {
34313431 var i: usize = 0;
34323432 while (i < free_list.items.len) {
34333433 const big_atom_index = free_list.items[i];
......@@ -3971,7 +3971,7 @@ fn writeDyldInfoData(self: *MachO) !void {
39713971 link_seg.filesize = needed_size;
39723972 assert(mem.isAlignedGeneric(u64, link_seg.fileoff + link_seg.filesize, @alignOf(u64)));
39733973
3974 var buffer = try gpa.alloc(u8, needed_size);
3974 const buffer = try gpa.alloc(u8, needed_size);
39753975 defer gpa.free(buffer);
39763976 @memset(buffer, 0);
39773977
......@@ -5228,7 +5228,7 @@ fn reportMissingLibraryError(
52285228) error{OutOfMemory}!void {
52295229 const gpa = self.base.allocator;
52305230 try self.misc_errors.ensureUnusedCapacity(gpa, 1);
5231 var notes = try gpa.alloc(File.ErrorMsg, checked_paths.len);
5231 const notes = try gpa.alloc(File.ErrorMsg, checked_paths.len);
52325232 errdefer gpa.free(notes);
52335233 for (checked_paths, notes) |path, *note| {
52345234 note.* = .{ .msg = try std.fmt.allocPrint(gpa, "tried {s}", .{path}) };
src/link/MachO/Archive.zig+3-3
......@@ -98,7 +98,7 @@ pub fn parse(self: *Archive, allocator: Allocator, reader: anytype) !void {
9898 _ = try reader.readBytesNoEof(SARMAG);
9999 self.header = try reader.readStruct(ar_hdr);
100100 const name_or_length = try self.header.nameOrLength();
101 var embedded_name = try parseName(allocator, name_or_length, reader);
101 const embedded_name = try parseName(allocator, name_or_length, reader);
102102 log.debug("parsing archive '{s}' at '{s}'", .{ embedded_name, self.name });
103103 defer allocator.free(embedded_name);
104104
......@@ -124,7 +124,7 @@ fn parseName(allocator: Allocator, name_or_length: ar_hdr.NameOrLength, reader:
124124
125125fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) !void {
126126 const symtab_size = try reader.readInt(u32, .little);
127 var symtab = try allocator.alloc(u8, symtab_size);
127 const symtab = try allocator.alloc(u8, symtab_size);
128128 defer allocator.free(symtab);
129129
130130 reader.readNoEof(symtab) catch {
......@@ -133,7 +133,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) !
133133 };
134134
135135 const strtab_size = try reader.readInt(u32, .little);
136 var strtab = try allocator.alloc(u8, strtab_size);
136 const strtab = try allocator.alloc(u8, strtab_size);
137137 defer allocator.free(strtab);
138138
139139 reader.readNoEof(strtab) catch {
src/link/MachO/Dylib.zig+3-3
......@@ -167,7 +167,7 @@ pub fn parseFromBinary(
167167 .REEXPORT_DYLIB => {
168168 if (should_lookup_reexports) {
169169 // Parse install_name to dependent dylib.
170 var id = try Id.fromLoadCommand(
170 const id = try Id.fromLoadCommand(
171171 allocator,
172172 cmd.cast(macho.dylib_command).?,
173173 cmd.getDylibPathName(),
......@@ -410,7 +410,7 @@ pub fn parseFromStub(
410410
411411 log.debug(" (found re-export '{s}')", .{lib});
412412
413 var dep_id = try Id.default(allocator, lib);
413 const dep_id = try Id.default(allocator, lib);
414414 try dependent_libs.writeItem(.{ .id = dep_id, .parent = dylib_id });
415415 }
416416 }
......@@ -527,7 +527,7 @@ pub fn parseFromStub(
527527
528528 log.debug(" (found re-export '{s}')", .{lib});
529529
530 var dep_id = try Id.default(allocator, lib);
530 const dep_id = try Id.default(allocator, lib);
531531 try dependent_libs.writeItem(.{ .id = dep_id, .parent = dylib_id });
532532 }
533533 }
src/link/MachO/Trie.zig+8-8
......@@ -150,7 +150,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void {
150150}
151151
152152test "Trie node count" {
153 var gpa = testing.allocator;
153 const gpa = testing.allocator;
154154 var trie: Trie = .{};
155155 defer trie.deinit(gpa);
156156 try trie.init(gpa);
......@@ -196,7 +196,7 @@ test "Trie node count" {
196196}
197197
198198test "Trie basic" {
199 var gpa = testing.allocator;
199 const gpa = testing.allocator;
200200 var trie: Trie = .{};
201201 defer trie.deinit(gpa);
202202 try trie.init(gpa);
......@@ -254,7 +254,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {
254254 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{std.fmt.fmtSliceHexLower(given)});
255255 defer testing.allocator.free(given_fmt);
256256 const idx = mem.indexOfDiff(u8, expected_fmt, given_fmt).?;
257 var padding = try testing.allocator.alloc(u8, idx + 5);
257 const padding = try testing.allocator.alloc(u8, idx + 5);
258258 defer testing.allocator.free(padding);
259259 @memset(padding, ' ');
260260 std.debug.print("\nEXP: {s}\nGIV: {s}\n{s}^ -- first differing byte\n", .{ expected_fmt, given_fmt, padding });
......@@ -292,7 +292,7 @@ test "write Trie to a byte stream" {
292292 0x3, 0x0, 0x80, 0x20, 0x0, // terminal node
293293 };
294294
295 var buffer = try gpa.alloc(u8, trie.size);
295 const buffer = try gpa.alloc(u8, trie.size);
296296 defer gpa.free(buffer);
297297 var stream = std.io.fixedBufferStream(buffer);
298298 {
......@@ -331,7 +331,7 @@ test "parse Trie from byte stream" {
331331
332332 try trie.finalize(gpa);
333333
334 var out_buffer = try gpa.alloc(u8, trie.size);
334 const out_buffer = try gpa.alloc(u8, trie.size);
335335 defer gpa.free(out_buffer);
336336 var out_stream = std.io.fixedBufferStream(out_buffer);
337337 _ = try trie.write(out_stream.writer());
......@@ -362,7 +362,7 @@ test "ordering bug" {
362362 0x00, 0x12, 0x03, 0x00, 0xD8, 0x0A, 0x00,
363363 };
364364
365 var buffer = try gpa.alloc(u8, trie.size);
365 const buffer = try gpa.alloc(u8, trie.size);
366366 defer gpa.free(buffer);
367367 var stream = std.io.fixedBufferStream(buffer);
368368 // Writing finalized trie again should yield the same result.
......@@ -426,7 +426,7 @@ pub const Node = struct {
426426 // To: A -> C -> B
427427 const mid = try allocator.create(Node);
428428 mid.* = .{ .base = self.base };
429 var to_label = try allocator.dupe(u8, edge.label[match..]);
429 const to_label = try allocator.dupe(u8, edge.label[match..]);
430430 allocator.free(edge.label);
431431 const to_node = edge.to;
432432 edge.to = mid;
......@@ -573,7 +573,7 @@ pub const Node = struct {
573573 /// Updates offset of this node in the output byte stream.
574574 fn finalize(self: *Node, offset_in_trie: u64) !FinalizeResult {
575575 var stream = std.io.countingWriter(std.io.null_writer);
576 var writer = stream.writer();
576 const writer = stream.writer();
577577
578578 var node_size: u64 = 0;
579579 if (self.terminal_info) |info| {
src/link/MachO/UnwindInfo.zig+1-1
......@@ -417,7 +417,7 @@ pub fn collect(info: *UnwindInfo, macho_file: *MachO) !void {
417417 gop.value_ptr.count += 1;
418418 }
419419
420 var slice = common_encodings_counts.values();
420 const slice = common_encodings_counts.values();
421421 mem.sort(CommonEncWithCount, slice, {}, CommonEncWithCount.greaterThan);
422422
423423 var i: u7 = 0;
src/link/MachO/eh_frame.zig+1-1
......@@ -586,7 +586,7 @@ pub const Iterator = struct {
586586 var stream = std.io.fixedBufferStream(it.data[it.pos..]);
587587 const reader = stream.reader();
588588
589 var size = try reader.readInt(u32, .little);
589 const size = try reader.readInt(u32, .little);
590590 if (size == 0xFFFFFFFF) {
591591 log.debug("MachO doesn't support 64bit DWARF CFI __eh_frame records", .{});
592592 return error.BadDwarfCfi;
src/link/MachO/load_commands.zig+1-1
......@@ -112,7 +112,7 @@ pub fn calcMinHeaderPad(gpa: Allocator, options: *const link.Options, ctx: CalcL
112112 log.debug("minimum requested headerpad size 0x{x}", .{padding + @sizeOf(macho.mach_header_64)});
113113
114114 if (options.headerpad_max_install_names) {
115 var min_headerpad_size: u32 = try calcLCsSize(gpa, options, ctx, true);
115 const min_headerpad_size: u32 = try calcLCsSize(gpa, options, ctx, true);
116116 log.debug("headerpad_max_install_names minimum headerpad size 0x{x}", .{
117117 min_headerpad_size + @sizeOf(macho.mach_header_64),
118118 });
src/link/MachO/zld.zig+1-1
......@@ -503,7 +503,7 @@ pub fn linkWithZld(
503503 const size = math.cast(usize, linkedit.fileoff - start) orelse return error.Overflow;
504504 if (size > 0) {
505505 log.debug("zeroing out zerofill area of length {x} at {x}", .{ size, start });
506 var padding = try gpa.alloc(u8, size);
506 const padding = try gpa.alloc(u8, size);
507507 defer gpa.free(padding);
508508 @memset(padding, 0);
509509 try macho_file.base.file.?.pwriteAll(padding, start);
src/link/Plan9.zig+6-6
......@@ -300,7 +300,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 {
300300 else => return error.UnsupportedP9Architecture,
301301 };
302302
303 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
303 const arena_allocator = std.heap.ArenaAllocator.init(gpa);
304304
305305 const self = try gpa.create(Plan9);
306306 self.* = .{
......@@ -467,7 +467,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I
467467
468468 const sym_index = try self.allocateSymbolIndex();
469469 const new_atom_idx = try self.createAtom();
470 var info: Atom = .{
470 const info: Atom = .{
471471 .type = .d,
472472 .offset = null,
473473 .sym_index = sym_index,
......@@ -496,7 +496,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I
496496 },
497497 };
498498 // duped_code is freed when the unnamed const is freed
499 var duped_code = try self.base.allocator.dupe(u8, code);
499 const duped_code = try self.base.allocator.dupe(u8, code);
500500 errdefer self.base.allocator.free(duped_code);
501501 const new_atom = self.getAtomPtr(new_atom_idx);
502502 new_atom.* = info;
......@@ -1024,7 +1024,7 @@ pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void {
10241024 const decl = mod.declPtr(decl_index);
10251025 const is_fn = decl.val.isFuncBody(mod);
10261026 if (is_fn) {
1027 var symidx_and_submap = self.fn_decl_table.get(decl.getFileScope(mod)).?;
1027 const symidx_and_submap = self.fn_decl_table.get(decl.getFileScope(mod)).?;
10281028 var submap = symidx_and_submap.functions;
10291029 if (submap.fetchSwapRemove(decl_index)) |removed_entry| {
10301030 self.base.allocator.free(removed_entry.value.code);
......@@ -1204,7 +1204,7 @@ fn updateLazySymbolAtom(self: *Plan9, sym: File.LazySymbol, atom_index: Atom.Ind
12041204 },
12051205 };
12061206 // duped_code is freed when the atom is freed
1207 var duped_code = try self.base.allocator.dupe(u8, code);
1207 const duped_code = try self.base.allocator.dupe(u8, code);
12081208 errdefer self.base.allocator.free(duped_code);
12091209 self.getAtomPtr(atom_index).code = .{
12101210 .code_ptr = duped_code.ptr,
......@@ -1489,7 +1489,7 @@ pub fn lowerAnonDecl(self: *Plan9, decl_val: InternPool.Index, src_loc: Module.S
14891489 // to put it in some location.
14901490 // ...
14911491 const gpa = self.base.allocator;
1492 var gop = try self.anon_decls.getOrPut(gpa, decl_val);
1492 const gop = try self.anon_decls.getOrPut(gpa, decl_val);
14931493 const mod = self.base.options.module.?;
14941494 if (!gop.found_existing) {
14951495 const ty = mod.intern_pool.typeOf(decl_val).toType();
src/link/Wasm.zig+5-5
......@@ -860,7 +860,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void {
860860 // Parse object and and resolve symbols again before we check remaining
861861 // undefined symbols.
862862 const object_file_index = @as(u16, @intCast(wasm.objects.items.len));
863 var object = try archive.parseObject(wasm.base.allocator, offset.items[0]);
863 const object = try archive.parseObject(wasm.base.allocator, offset.items[0]);
864864 try wasm.objects.append(wasm.base.allocator, object);
865865 try wasm.resolveSymbolsInObject(object_file_index);
866866
......@@ -1344,7 +1344,7 @@ pub fn deinit(wasm: *Wasm) void {
13441344/// Will re-use slots when a symbol was freed at an earlier stage.
13451345pub fn allocateSymbol(wasm: *Wasm) !u32 {
13461346 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);
1347 var symbol: Symbol = .{
1347 const symbol: Symbol = .{
13481348 .name = std.math.maxInt(u32), // will be set after updateDecl as well as during atom creation for decls
13491349 .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
13501350 .tag = .undefined, // will be set after updateDecl
......@@ -1655,7 +1655,7 @@ pub fn getGlobalSymbol(wasm: *Wasm, name: []const u8, lib_name: ?[]const u8) !u3
16551655 symbol.setUndefined(true);
16561656
16571657 const sym_index = if (wasm.symbols_free_list.popOrNull()) |index| index else blk: {
1658 var index = @as(u32, @intCast(wasm.symbols.items.len));
1658 const index: u32 = @intCast(wasm.symbols.items.len);
16591659 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);
16601660 wasm.symbols.items.len += 1;
16611661 break :blk index;
......@@ -2632,7 +2632,7 @@ fn setupImports(wasm: *Wasm) !void {
26322632
26332633 // We copy the import to a new import to ensure the names contain references
26342634 // to the internal string table, rather than of the object file.
2635 var new_imp: types.Import = .{
2635 const new_imp: types.Import = .{
26362636 .module_name = try wasm.string_table.put(wasm.base.allocator, object.string_table.get(import.module_name)),
26372637 .name = try wasm.string_table.put(wasm.base.allocator, object.string_table.get(import.name)),
26382638 .kind = import.kind,
......@@ -3800,7 +3800,7 @@ fn writeToFile(
38003800 const table_loc = wasm.findGlobalSymbol("__indirect_function_table").?;
38013801 const table_sym = table_loc.getSymbol(wasm);
38023802
3803 var flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually
3803 const flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually
38043804 try leb.writeULEB128(binary_writer, flags);
38053805 if (flags == 0x02) {
38063806 try leb.writeULEB128(binary_writer, table_sym.index);
src/link/Wasm/Object.zig+3-3
......@@ -252,7 +252,7 @@ fn checkLegacyIndirectFunctionTable(object: *Object) !?Symbol {
252252 return error.MissingTableSymbols;
253253 }
254254
255 var table_import: types.Import = for (object.imports) |imp| {
255 const table_import: types.Import = for (object.imports) |imp| {
256256 if (imp.kind == .table) {
257257 break imp;
258258 }
......@@ -512,7 +512,7 @@ fn Parser(comptime ReaderType: type) type {
512512 try assertEnd(reader);
513513 },
514514 .code => {
515 var start = reader.context.bytes_left;
515 const start = reader.context.bytes_left;
516516 var index: u32 = 0;
517517 const count = try readLeb(u32, reader);
518518 while (index < count) : (index += 1) {
......@@ -532,7 +532,7 @@ fn Parser(comptime ReaderType: type) type {
532532 }
533533 },
534534 .data => {
535 var start = reader.context.bytes_left;
535 const start = reader.context.bytes_left;
536536 var index: u32 = 0;
537537 const count = try readLeb(u32, reader);
538538 while (index < count) : (index += 1) {
src/link/tapi/yaml.zig+1-1
......@@ -491,7 +491,7 @@ pub fn stringify(allocator: Allocator, input: anytype, writer: anytype) !void {
491491 var arena = ArenaAllocator.init(allocator);
492492 defer arena.deinit();
493493
494 var maybe_value = try Value.encode(arena.allocator(), input);
494 const maybe_value = try Value.encode(arena.allocator(), input);
495495
496496 if (maybe_value) |value| {
497497 // TODO should we output as an explicit doc?
src/main.zig+7-7
......@@ -4479,7 +4479,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
44794479 try stdout_writer.writeByte('\n');
44804480 }
44814481
4482 var full_input = full_input: {
4482 const full_input = full_input: {
44834483 if (options.preprocess != .no) {
44844484 if (!build_options.have_llvm) {
44854485 fatal("clang not available: compiler built without LLVM extensions", .{});
......@@ -4526,7 +4526,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
45264526 }
45274527
45284528 if (process.can_spawn) {
4529 var result = std.ChildProcess.run(.{
4529 const result = std.ChildProcess.run(.{
45304530 .allocator = gpa,
45314531 .argv = argv.items,
45324532 .max_output_bytes = std.math.maxInt(u32),
......@@ -4593,7 +4593,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
45934593 var mapping_results = try resinator.source_mapping.parseAndRemoveLineCommands(gpa, full_input, full_input, .{ .initial_filename = options.input_filename });
45944594 defer mapping_results.mappings.deinit(gpa);
45954595
4596 var final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);
4596 const final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);
45974597
45984598 var output_file = std.fs.cwd().createFile(options.output_filename, .{}) catch |err| {
45994599 try resinator.utils.renderErrorMessage(stderr.writer(), stderr_config, .err, "unable to create output file '{s}': {s}", .{ options.output_filename, @errorName(err) });
......@@ -4762,7 +4762,7 @@ pub fn cmdLibC(gpa: Allocator, args: []const []const u8) !void {
47624762
47634763 const libc_installation: ?*LibCInstallation = libc: {
47644764 if (input_file) |libc_file| {
4765 var libc = try arena.create(LibCInstallation);
4765 const libc = try arena.create(LibCInstallation);
47664766 libc.* = LibCInstallation.parse(arena, libc_file, cross_target) catch |err| {
47674767 fatal("unable to parse libc file at path {s}: {s}", .{ libc_file, @errorName(err) });
47684768 };
......@@ -4781,7 +4781,7 @@ pub fn cmdLibC(gpa: Allocator, args: []const []const u8) !void {
47814781 const target = cross_target.toTarget();
47824782 const is_native_abi = cross_target.isNativeAbi();
47834783
4784 var libc_dirs = Compilation.detectLibCIncludeDirs(
4784 const libc_dirs = Compilation.detectLibCIncludeDirs(
47854785 arena,
47864786 zig_lib_directory.path.?,
47874787 target,
......@@ -4960,7 +4960,7 @@ pub const usage_build =
49604960pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
49614961 const work_around_btrfs_bug = builtin.os.tag == .linux and
49624962 EnvVar.ZIG_BTRFS_WORKAROUND.isSet();
4963 var color: Color = .auto;
4963 const color: Color = .auto;
49644964
49654965 // We want to release all the locks before executing the child process, so we make a nice
49664966 // big block here to ensure the cleanup gets run when we extract out our argv.
......@@ -6001,7 +6001,7 @@ const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true,
60016001/// Initialize the arguments from a Response File. "*.rsp"
60026002fn initArgIteratorResponseFile(allocator: Allocator, resp_file_path: []const u8) !ArgIteratorResponseFile {
60036003 const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit
6004 var cmd_line = try fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes);
6004 const cmd_line = try fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes);
60056005 errdefer allocator.free(cmd_line);
60066006
60076007 return ArgIteratorResponseFile.initTakeOwnership(allocator, cmd_line);
src/resinator/bmp.zig+1-1
......@@ -120,7 +120,7 @@ pub fn read(reader: anytype, max_size: u64) ReadError!BitmapInfo {
120120 var dib_header_buf: [@sizeOf(BITMAPCOREHEADER)]u8 align(@alignOf(BITMAPCOREHEADER)) = undefined;
121121 std.mem.writeInt(u32, dib_header_buf[0..4], bitmap_info.dib_header_size, .little);
122122 reader.readNoEof(dib_header_buf[4..]) catch return error.UnexpectedEOF;
123 var dib_header: *BITMAPCOREHEADER = @ptrCast(&dib_header_buf);
123 const dib_header: *BITMAPCOREHEADER = @ptrCast(&dib_header_buf);
124124 structFieldsLittleToNative(BITMAPCOREHEADER, dib_header);
125125
126126 // > The size of the color palette is calculated from the BitsPerPixel value.
src/resinator/cli.zig+5-5
......@@ -163,15 +163,15 @@ pub const Options = struct {
163163 // we shouldn't change anything.
164164 if (val_ptr.* == .undefine) return;
165165 // Otherwise, the new value takes precedence.
166 var duped_value = try self.allocator.dupe(u8, value);
166 const duped_value = try self.allocator.dupe(u8, value);
167167 errdefer self.allocator.free(duped_value);
168168 val_ptr.deinit(self.allocator);
169169 val_ptr.* = .{ .define = duped_value };
170170 return;
171171 }
172 var duped_key = try self.allocator.dupe(u8, identifier);
172 const duped_key = try self.allocator.dupe(u8, identifier);
173173 errdefer self.allocator.free(duped_key);
174 var duped_value = try self.allocator.dupe(u8, value);
174 const duped_value = try self.allocator.dupe(u8, value);
175175 errdefer self.allocator.free(duped_value);
176176 try self.symbols.put(self.allocator, duped_key, .{ .define = duped_value });
177177 }
......@@ -183,7 +183,7 @@ pub const Options = struct {
183183 action.* = .{ .undefine = {} };
184184 return;
185185 }
186 var duped_key = try self.allocator.dupe(u8, identifier);
186 const duped_key = try self.allocator.dupe(u8, identifier);
187187 errdefer self.allocator.free(duped_key);
188188 try self.symbols.put(self.allocator, duped_key, .{ .undefine = {} });
189189 }
......@@ -828,7 +828,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn
828828 }
829829 }
830830
831 var positionals = args[arg_i..];
831 const positionals = args[arg_i..];
832832
833833 if (positionals.len < 1) {
834834 var err_details = Diagnostics.ErrorDetails{ .print_args = false, .arg_index = arg_i };
src/resinator/code_pages.zig+3-3
......@@ -302,8 +302,8 @@ pub const Utf8 = struct {
302302
303303 pub fn decode(bytes: []const u8) Codepoint {
304304 std.debug.assert(bytes.len > 0);
305 var first_byte = bytes[0];
306 var expected_len = sequenceLength(first_byte) orelse {
305 const first_byte = bytes[0];
306 const expected_len = sequenceLength(first_byte) orelse {
307307 return .{ .value = Codepoint.invalid, .byte_len = 1 };
308308 };
309309 if (expected_len == 1) return .{ .value = first_byte, .byte_len = 1 };
......@@ -367,7 +367,7 @@ pub const Utf8 = struct {
367367
368368test "Utf8.WellFormedDecoder" {
369369 const invalid_utf8 = "\xF0\x80";
370 var decoded = Utf8.WellFormedDecoder.decode(invalid_utf8);
370 const decoded = Utf8.WellFormedDecoder.decode(invalid_utf8);
371371 try std.testing.expectEqual(Codepoint.invalid, decoded.value);
372372 try std.testing.expectEqual(@as(usize, 2), decoded.byte_len);
373373}
src/resinator/comments.zig+4-4
......@@ -206,9 +206,9 @@ inline fn handleMultilineCarriageReturn(
206206}
207207
208208pub fn removeCommentsAlloc(allocator: Allocator, source: []const u8, source_mappings: ?*SourceMappings) ![]u8 {
209 var buf = try allocator.alloc(u8, source.len);
209 const buf = try allocator.alloc(u8, source.len);
210210 errdefer allocator.free(buf);
211 var result = removeComments(source, buf, source_mappings);
211 const result = removeComments(source, buf, source_mappings);
212212 return allocator.realloc(buf, result.len);
213213}
214214
......@@ -326,7 +326,7 @@ test "remove comments with mappings" {
326326 try mappings.set(allocator, 3, .{ .start_line = 3, .end_line = 3, .filename_offset = 0 });
327327 defer mappings.deinit(allocator);
328328
329 var result = removeComments(&mut_source, &mut_source, &mappings);
329 const result = removeComments(&mut_source, &mut_source, &mappings);
330330
331331 try std.testing.expectEqualStrings("blahblah", result);
332332 try std.testing.expectEqual(@as(usize, 1), mappings.mapping.items.len);
......@@ -335,6 +335,6 @@ test "remove comments with mappings" {
335335
336336test "in place" {
337337 var mut_source = "blah /* comment */ blah".*;
338 var result = removeComments(&mut_source, &mut_source, null);
338 const result = removeComments(&mut_source, &mut_source, null);
339339 try std.testing.expectEqualStrings("blah blah", result);
340340}
src/resinator/compile.zig+4-4
......@@ -666,7 +666,7 @@ pub const Compiler = struct {
666666 },
667667 },
668668 .dib => {
669 var bitmap_header: *ico.BitmapHeader = @ptrCast(@alignCast(&header_bytes));
669 const bitmap_header: *ico.BitmapHeader = @ptrCast(@alignCast(&header_bytes));
670670 if (native_endian == .big) {
671671 std.mem.byteSwapAllFields(ico.BitmapHeader, bitmap_header);
672672 }
......@@ -1773,13 +1773,13 @@ pub const Compiler = struct {
17731773 }
17741774 try data_writer.writeByteNTimes(0, num_padding);
17751775
1776 var style = if (control.style) |style_expression|
1776 const style = if (control.style) |style_expression|
17771777 // Certain styles are implied by the control type
17781778 evaluateFlagsExpressionWithDefault(res.ControlClass.getImpliedStyle(control_type), style_expression, self.source, self.input_code_pages)
17791779 else
17801780 res.ControlClass.getImpliedStyle(control_type);
17811781
1782 var exstyle = if (control.exstyle) |exstyle_expression|
1782 const exstyle = if (control.exstyle) |exstyle_expression|
17831783 evaluateFlagsExpressionWithDefault(0, exstyle_expression, self.source, self.input_code_pages)
17841784 else
17851785 0;
......@@ -3205,7 +3205,7 @@ pub const StringTable = struct {
32053205 const trimmed_string = trim: {
32063206 // Two NUL characters in a row act as a terminator
32073207 // Note: This is only the case for STRINGTABLE strings
3208 var trimmed = trimToDoubleNUL(u16, utf16_string);
3208 const trimmed = trimToDoubleNUL(u16, utf16_string);
32093209 // We also want to trim any trailing NUL characters
32103210 break :trim std.mem.trimRight(u16, trimmed, &[_]u16{0});
32113211 };
src/resinator/lang.zig+1-1
......@@ -98,7 +98,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId {
9898 var normalized_buf: [longest_known_tag]u8 = undefined;
9999 // To allow e.g. `de-de_phoneb` to get looked up as `de-de`, we need to
100100 // omit the suffix, but only if the tag contains a valid alternate sort order.
101 var tag_to_normalize = if (parsed.isSuffixValidSortOrder()) tag[0 .. tag.len - (parsed.suffix.?.len + 1)] else tag;
101 const tag_to_normalize = if (parsed.isSuffixValidSortOrder()) tag[0 .. tag.len - (parsed.suffix.?.len + 1)] else tag;
102102 const normalized_tag = normalizeTag(tag_to_normalize, &normalized_buf);
103103 return std.meta.stringToEnum(LanguageId, normalized_tag) orelse {
104104 // special case for a tag that has been mapped to the same ID
src/resinator/parse.zig+6-6
......@@ -100,7 +100,7 @@ pub const Parser = struct {
100100 // because it almost always leads to unhelpful error messages
101101 // (usually it will end up with bogus things like 'file
102102 // not found: {')
103 var statement = try self.parseStatement();
103 const statement = try self.parseStatement();
104104 try statements.append(statement);
105105 }
106106 }
......@@ -698,7 +698,7 @@ pub const Parser = struct {
698698 .dlginclude => {
699699 const common_resource_attributes = try self.parseCommonResourceAttributes();
700700
701 var filename_expression = try self.parseExpression(.{
701 const filename_expression = try self.parseExpression(.{
702702 .allowed_types = .{ .string = true },
703703 });
704704
......@@ -756,7 +756,7 @@ pub const Parser = struct {
756756 return &node.base;
757757 }
758758
759 var filename_expression = try self.parseExpression(.{
759 const filename_expression = try self.parseExpression(.{
760760 // Don't tell the user that numbers are accepted since we error on
761761 // number expressions and regular number literals are treated as unquoted
762762 // literals rather than numbers, so from the users perspective
......@@ -934,8 +934,8 @@ pub const Parser = struct {
934934 style = try optional_param_parser.parse(.{ .not_expression_allowed = true });
935935 }
936936
937 var exstyle: ?*Node = try optional_param_parser.parse(.{ .not_expression_allowed = true });
938 var help_id: ?*Node = switch (resource) {
937 const exstyle: ?*Node = try optional_param_parser.parse(.{ .not_expression_allowed = true });
938 const help_id: ?*Node = switch (resource) {
939939 .dialogex => try optional_param_parser.parse(.{}),
940940 else => null,
941941 };
......@@ -1526,7 +1526,7 @@ pub const Parser = struct {
15261526
15271527 pub fn toErrorDetails(options: ParseExpressionOptions, token: Token) ErrorDetails {
15281528 // TODO: expected_types_override interaction with is_known_to_be_number_expression?
1529 var expected_types = options.expected_types_override orelse ErrorDetails.ExpectedTypes{
1529 const expected_types = options.expected_types_override orelse ErrorDetails.ExpectedTypes{
15301530 .number = options.allowed_types.number,
15311531 .number_expression = options.allowed_types.number,
15321532 .string_literal = options.allowed_types.string and !options.is_known_to_be_number_expression,
src/resinator/res.zig+2-2
......@@ -357,7 +357,7 @@ pub const NameOrOrdinal = union(enum) {
357357 /// RC compiler would have allowed them, so that a proper warning/error
358358 /// can be emitted.
359359 pub fn maybeNonAsciiOrdinalFromString(bytes: SourceBytes) ?NameOrOrdinal {
360 var buf = bytes.slice;
360 const buf = bytes.slice;
361361 const radix = 10;
362362 if (buf.len > 2 and buf[0] == '0') {
363363 switch (buf[1]) {
......@@ -514,7 +514,7 @@ test "NameOrOrdinal" {
514514 {
515515 var expected = blk: {
516516 // the input before the 𐐷 character, but uppercased
517 var expected_u8_bytes = "00614982008907933748980730280674788429543776231864944218790698304852300002973622122844631429099469274282385299397783838528QFFL7SHNSIETG0QKLR1UYPBTUV1PMFQRRA0VJDG354GQEDJMUPGPP1W1EXVNTZVEIZ6K3IPQM1AWGEYALMEODYVEZGOD3MFMGEY8FNR4JUETTB1PZDEWSNDRGZUA8SNXP3NGO";
517 const expected_u8_bytes = "00614982008907933748980730280674788429543776231864944218790698304852300002973622122844631429099469274282385299397783838528QFFL7SHNSIETG0QKLR1UYPBTUV1PMFQRRA0VJDG354GQEDJMUPGPP1W1EXVNTZVEIZ6K3IPQM1AWGEYALMEODYVEZGOD3MFMGEY8FNR4JUETTB1PZDEWSNDRGZUA8SNXP3NGO";
518518 var buf: [256:0]u16 = undefined;
519519 for (expected_u8_bytes, 0..) |byte, i| {
520520 buf[i] = std.mem.nativeToLittle(u16, byte);
src/resinator/source_mapping.zig+2-2
......@@ -251,7 +251,7 @@ pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current
251251}
252252
253253pub fn parseAndRemoveLineCommandsAlloc(allocator: Allocator, source: []const u8, options: ParseAndRemoveLineCommandsOptions) !ParseLineCommandsResult {
254 var buf = try allocator.alloc(u8, source.len);
254 const buf = try allocator.alloc(u8, source.len);
255255 errdefer allocator.free(buf);
256256 var result = try parseAndRemoveLineCommands(allocator, source, buf, options);
257257 result.result = try allocator.realloc(buf, result.result.len);
......@@ -440,7 +440,7 @@ pub const SourceMappings = struct {
440440 }
441441
442442 pub fn set(self: *SourceMappings, allocator: Allocator, line_num: usize, span: SourceSpan) !void {
443 var ptr = try self.expandAndGet(allocator, line_num);
443 const ptr = try self.expandAndGet(allocator, line_num);
444444 ptr.* = span;
445445 }
446446
src/translate_c.zig+5-5
......@@ -456,7 +456,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
456456 block_scope.return_type = return_qt;
457457 defer block_scope.deinit();
458458
459 var scope = &block_scope.base;
459 const scope = &block_scope.base;
460460
461461 var param_id: c_uint = 0;
462462 for (proto_node.data.params) |*param| {
......@@ -1363,7 +1363,7 @@ fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransEr
13631363 if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |type_name| {
13641364 const type_node = try Tag.type.create(c.arena, type_name);
13651365
1366 var raw_field_name = try c.str(@as(*const clang.NamedDecl, @ptrCast(field_decl)).getName_bytes_begin());
1366 const raw_field_name = try c.str(@as(*const clang.NamedDecl, @ptrCast(field_decl)).getName_bytes_begin());
13671367 const quoted_field_name = try std.fmt.allocPrint(c.arena, "\"{s}\"", .{raw_field_name});
13681368 const field_name_node = try Tag.string_literal.create(c.arena, quoted_field_name);
13691369
......@@ -1967,7 +1967,7 @@ fn transBoolExpr(
19671967 return Node{ .tag_if_small_enough = @intFromEnum(([2]Tag{ .true_literal, .false_literal })[@intFromBool(is_zero)]) };
19681968 }
19691969
1970 var res = try transExpr(c, scope, expr, used);
1970 const res = try transExpr(c, scope, expr, used);
19711971 if (isBoolRes(res)) {
19721972 return maybeSuppressResult(c, used, res);
19731973 }
......@@ -3477,7 +3477,7 @@ fn cIsFunctionDeclRef(expr: *const clang.Expr) bool {
34773477
34783478fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result_used: ResultUsed) TransError!Node {
34793479 const callee = stmt.getCallee();
3480 var raw_fn_expr = try transExpr(c, scope, callee, .used);
3480 const raw_fn_expr = try transExpr(c, scope, callee, .used);
34813481
34823482 var is_ptr = false;
34833483 const fn_ty = qualTypeGetFnProto(callee.getType(), &is_ptr);
......@@ -5889,7 +5889,7 @@ fn escapeUnprintables(ctx: *Context, m: *MacroCtx) ![]const u8 {
58895889
58905890 const formatter = std.fmt.fmtSliceEscapeLower(zigified);
58915891 const encoded_size = @as(usize, @intCast(std.fmt.count("{s}", .{formatter})));
5892 var output = try ctx.arena.alloc(u8, encoded_size);
5892 const output = try ctx.arena.alloc(u8, encoded_size);
58935893 return std.fmt.bufPrint(output, "{s}", .{formatter}) catch |err| switch (err) {
58945894 error.NoSpaceLeft => unreachable,
58955895 else => |e| return e,
src/value.zig+3-3
......@@ -2136,7 +2136,7 @@ pub const Value = struct {
21362136 lhs_bigint.limbs.len + rhs_bigint.limbs.len,
21372137 );
21382138 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
2139 var limbs_buffer = try arena.alloc(
2139 const limbs_buffer = try arena.alloc(
21402140 std.math.big.Limb,
21412141 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),
21422142 );
......@@ -2249,7 +2249,7 @@ pub const Value = struct {
22492249 ),
22502250 );
22512251 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
2252 var limbs_buffer = try arena.alloc(
2252 const limbs_buffer = try arena.alloc(
22532253 std.math.big.Limb,
22542254 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),
22552255 );
......@@ -2788,7 +2788,7 @@ pub const Value = struct {
27882788 lhs_bigint.limbs.len + rhs_bigint.limbs.len,
27892789 );
27902790 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
2791 var limbs_buffer = try allocator.alloc(
2791 const limbs_buffer = try allocator.alloc(
27922792 std.math.big.Limb,
27932793 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),
27942794 );
src/windows_sdk.zig+9-9
......@@ -69,7 +69,7 @@ fn iterateAndFilterBySemVer(iterator: *std.fs.IterableDir.Iterator, allocator: s
6969 try dirs_filtered_list.append(subfolder_name_allocated);
7070 }
7171
72 var dirs_filtered_slice = try dirs_filtered_list.toOwnedSlice();
72 const dirs_filtered_slice = try dirs_filtered_list.toOwnedSlice();
7373 // Keep in mind that order of these names is not guaranteed by Windows,
7474 // so we cannot just reverse or "while (popOrNull())" this ArrayList.
7575 std.mem.sortUnstable([]const u8, dirs_filtered_slice, {}, struct {
......@@ -129,7 +129,7 @@ const RegistryUtf8 = struct {
129129 const value_utf16le = try registry_utf16le.getString(allocator, subkey_utf16le, value_name_utf16le);
130130 defer allocator.free(value_utf16le);
131131
132 var value_utf8: []u8 = std.unicode.utf16leToUtf8Alloc(allocator, value_utf16le) catch |err| switch (err) {
132 const value_utf8: []u8 = std.unicode.utf16leToUtf8Alloc(allocator, value_utf16le) catch |err| switch (err) {
133133 error.OutOfMemory => return error.OutOfMemory,
134134 else => return error.StringNotFound,
135135 };
......@@ -246,7 +246,7 @@ const RegistryUtf16Le = struct {
246246 else => return error.NotAString,
247247 }
248248
249 var value_utf16le_buf: []u16 = try allocator.alloc(u16, std.math.divCeil(u32, value_utf16le_buf_size, 2) catch unreachable);
249 const value_utf16le_buf: []u16 = try allocator.alloc(u16, std.math.divCeil(u32, value_utf16le_buf_size, 2) catch unreachable);
250250 errdefer allocator.free(value_utf16le_buf);
251251
252252 return_code_int = windows.advapi32.RegGetValueW(
......@@ -354,7 +354,7 @@ pub const Windows10Sdk = struct {
354354 defer v10_key.closeKey();
355355
356356 const path: []const u8 = path10: {
357 var path_maybe_with_trailing_slash = v10_key.getString(allocator, "", "InstallationFolder") catch |err| switch (err) {
357 const path_maybe_with_trailing_slash = v10_key.getString(allocator, "", "InstallationFolder") catch |err| switch (err) {
358358 error.NotAString => return error.Windows10SdkNotFound,
359359 error.ValueNameNotFound => return error.Windows10SdkNotFound,
360360 error.StringNotFound => return error.Windows10SdkNotFound,
......@@ -381,7 +381,7 @@ pub const Windows10Sdk = struct {
381381 const version: []const u8 = version10: {
382382
383383 // note(dimenus): Microsoft doesn't include the .0 in the ProductVersion key....
384 var version_without_0 = v10_key.getString(allocator, "", "ProductVersion") catch |err| switch (err) {
384 const version_without_0 = v10_key.getString(allocator, "", "ProductVersion") catch |err| switch (err) {
385385 error.NotAString => return error.Windows10SdkNotFound,
386386 error.ValueNameNotFound => return error.Windows10SdkNotFound,
387387 error.StringNotFound => return error.Windows10SdkNotFound,
......@@ -445,7 +445,7 @@ pub const Windows81Sdk = struct {
445445 /// After finishing work, call `free(allocator)`.
446446 fn find(allocator: std.mem.Allocator, roots_key: *const RegistryUtf8) error{ OutOfMemory, Windows81SdkNotFound, PathTooLong, VersionTooLong }!Windows81Sdk {
447447 const path: []const u8 = path81: {
448 var path_maybe_with_trailing_slash = roots_key.getString(allocator, "", "KitsRoot81") catch |err| switch (err) {
448 const path_maybe_with_trailing_slash = roots_key.getString(allocator, "", "KitsRoot81") catch |err| switch (err) {
449449 error.NotAString => return error.Windows81SdkNotFound,
450450 error.ValueNameNotFound => return error.Windows81SdkNotFound,
451451 error.StringNotFound => return error.Windows81SdkNotFound,
......@@ -752,7 +752,7 @@ const MsvcLibDir = struct {
752752
753753 const config_subkey = std.fmt.bufPrint(config_subkey_buf[0..], "Software\\Microsoft\\VisualStudio\\{s}_Config", .{vs_version}) catch unreachable;
754754
755 var source_directories_value = visualstudio_registry.getString(allocator, config_subkey, "Source Directories") catch |err| switch (err) {
755 const source_directories_value = visualstudio_registry.getString(allocator, config_subkey, "Source Directories") catch |err| switch (err) {
756756 error.OutOfMemory => return error.OutOfMemory,
757757 else => continue,
758758 };
......@@ -768,7 +768,7 @@ const MsvcLibDir = struct {
768768 var source_directories_splitted = std.mem.splitScalar(u8, source_directories, ';');
769769
770770 const msvc_dir: []const u8 = msvc_dir: {
771 var msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());
771 const msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());
772772
773773 if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {
774774 allocator.free(msvc_include_dir_maybe_with_trailing_slash);
......@@ -833,7 +833,7 @@ const MsvcLibDir = struct {
833833 const vs7_key = RegistryUtf8.openKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7") catch return error.PathNotFound;
834834 defer vs7_key.closeKey();
835835 try_vs7_key: {
836 var path_maybe_with_trailing_slash = vs7_key.getString(allocator, "", "14.0") catch |err| switch (err) {
836 const path_maybe_with_trailing_slash = vs7_key.getString(allocator, "", "14.0") catch |err| switch (err) {
837837 error.OutOfMemory => return error.OutOfMemory,
838838 else => break :try_vs7_key,
839839 };