authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-04-20 18:01:44-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-04-20 18:03:14-07:00
log3252a0553175690ff8a2f0aa8a5697c8344ec59c
tree99ce0923f0da10ac4bd31c0f5ce622ef8fa3604c
parent98cc059622cd5cad3eef1bbc851437358d259033

Prefer `<err> => |e| return e` over `<err> => return <err>`

Avoids the potential for a typo on the `return <err>` side of the prong

62 files changed, 170 insertions(+), 201 deletions(-)

lib/compiler/aro/aro/CodeGen.zig+2-4
......@@ -102,14 +102,12 @@ pub fn genIr(tree: *const Tree) Compilation.Error!Ir {
102102 .function => |function| {
103103 if (function.body == null) continue;
104104 c.genFn(function) catch |err| switch (err) {
105 error.FatalError => return error.FatalError,
106 error.OutOfMemory => return error.OutOfMemory,
105 error.FatalError, error.OutOfMemory => |e| return e,
107106 };
108107 },
109108
110109 .variable => |variable| c.genVar(variable) catch |err| switch (err) {
111 error.FatalError => return error.FatalError,
112 error.OutOfMemory => return error.OutOfMemory,
110 error.FatalError, error.OutOfMemory => |e| return e,
113111 },
114112 .global_asm => {
115113 return c.fail("TODO global assembly", .{});
lib/compiler/aro/aro/Compilation.zig+2-2
......@@ -2085,7 +2085,7 @@ pub fn findEmbed(
20852085 if (opt_dep_file) |dep_file| try dep_file.addDependencyDupe(comp.gpa, comp.arena, filename);
20862086 return some;
20872087 } else |err| switch (err) {
2088 error.OutOfMemory => return error.OutOfMemory,
2088 error.OutOfMemory => |e| return e,
20892089 else => {},
20902090 }
20912091 },
......@@ -2100,7 +2100,7 @@ pub fn findEmbed(
21002100 if (opt_dep_file) |dep_file| try dep_file.addDependencyDupe(comp.gpa, comp.arena, filename);
21012101 return some;
21022102 } else |err| switch (err) {
2103 error.OutOfMemory => return error.OutOfMemory,
2103 error.OutOfMemory => |e| return e,
21042104 else => {},
21052105 }
21062106 }
lib/compiler/aro/aro/Driver.zig+5-7
......@@ -1182,8 +1182,7 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_
11821182 var stdout = std.Io.File.stdout().writer(d.comp.io, &stdout_buf);
11831183 if (parseArgs(d, &stdout.interface, &macro_buf, args) catch |er| switch (er) {
11841184 error.WriteFailed => return d.fatal("failed to write to stdout: {s}", .{errorDescription(er)}),
1185 error.OutOfMemory => return error.OutOfMemory,
1186 error.FatalError => return error.FatalError,
1185 error.OutOfMemory, error.FatalError => |e| return e,
11871186 }) return;
11881187 if (macro_buf.items.len > std.math.maxInt(u32)) {
11891188 return d.fatal("user provided macro source exceeded max size", .{});
......@@ -1207,12 +1206,11 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_
12071206 };
12081207
12091208 tc.discover() catch |er| switch (er) {
1210 error.OutOfMemory => return error.OutOfMemory,
1209 error.OutOfMemory => |e| return e,
12111210 error.TooManyMultilibs => return d.fatal("found more than one multilib with the same priority", .{}),
12121211 };
12131212 tc.defineSystemIncludes() catch |er| switch (er) {
1214 error.OutOfMemory => return error.OutOfMemory,
1215 error.FatalError => return error.FatalError,
1213 error.OutOfMemory, error.FatalError => |e| return e,
12161214 };
12171215 try d.comp.initSearchPath(d.includes.items, d.verbose_search_path);
12181216
......@@ -1525,8 +1523,8 @@ fn processSource(
15251523 render_errors.deinit(gpa);
15261524 }
15271525
1528 var obj = ir.render(gpa, d.comp.target.toZigTarget(), &render_errors) catch |e| switch (e) {
1529 error.OutOfMemory => return error.OutOfMemory,
1526 var obj = ir.render(gpa, d.comp.target.toZigTarget(), &render_errors) catch |er| switch (er) {
1527 error.OutOfMemory => |e| return e,
15301528 error.LowerFail => {
15311529 return d.fatal(
15321530 "unable to render Ir to machine code: {s}",
lib/compiler/aro/aro/Parser.zig+2-3
......@@ -5725,9 +5725,8 @@ fn returnStmt(p: *Parser) Error!?Node.Index {
57255725// ====== expressions ======
57265726
57275727pub fn macroExpr(p: *Parser) Compilation.Error!bool {
5728 const res = p.expect(condExpr) catch |e| switch (e) {
5729 error.OutOfMemory => return error.OutOfMemory,
5730 error.FatalError => return error.FatalError,
5728 const res = p.expect(condExpr) catch |er| switch (er) {
5729 error.OutOfMemory, error.FatalError => |e| return e,
57315730 error.ParsingFailed => return false,
57325731 };
57335732 return res.val.toBool(p.comp);
lib/compiler/aro/assembly_backend/x86_64.zig+1-2
......@@ -150,8 +150,7 @@ pub fn genAsm(tree: *const Tree) Error!Assembly {
150150
151151 codegen.genDecls() catch |err| switch (err) {
152152 error.WriteFailed => return error.OutOfMemory,
153 error.OutOfMemory => return error.OutOfMemory,
154 error.FatalError => return error.FatalError,
153 error.OutOfMemory, error.FatalError => |e| return e,
155154 };
156155
157156 const text_slice = try text.toOwnedSlice();
lib/compiler/test_runner.zig+1-1
......@@ -488,7 +488,7 @@ var fuzz_runner: if (builtin.fuzz) struct {
488488 fn inputPoller() Io.Cancelable!void {
489489 @disableInstrumentation();
490490 switch (inputPollerInner()) {
491 error.Canceled => return error.Canceled,
491 error.Canceled => |e| return e,
492492 error.ReadFailed => {
493493 if (stdin_reader.err.? == error.Canceled) return error.Canceled;
494494 panic("failed to read from stdin: {t}", .{stdin_reader.err.?});
lib/compiler/translate-c/Translator.zig+2-2
......@@ -1297,7 +1297,7 @@ fn transType(t: *Translator, scope: *Scope, qt: QualType, source_loc: TokenIndex
12971297 error.SelfReferential => {},
12981298 error.UnsupportedTranslation => {},
12991299 error.UnsupportedType => {},
1300 error.OutOfMemory => return error.OutOfMemory,
1300 error.OutOfMemory => |e| return e,
13011301 }
13021302 }
13031303 continue :loop typeof_ty.base.type(t.comp);
......@@ -4099,7 +4099,7 @@ fn createIntNode(t: *Translator, int: aro.Value) !ZigNode {
40994099 big.positive = true;
41004100
41014101 const str = big.toStringAlloc(t.arena, 10, .lower) catch |err| switch (err) {
4102 error.OutOfMemory => return error.OutOfMemory,
4102 error.OutOfMemory => |e| return e,
41034103 };
41044104 const res = try ZigTag.integer_literal.create(t.arena, str);
41054105 if (is_negative) return ZigTag.negate.create(t.arena, res);
lib/compiler/translate-c/main.zig+1-1
......@@ -225,7 +225,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
225225 const source = d.inputs.items[0];
226226
227227 tc.discover() catch |er| switch (er) {
228 error.OutOfMemory => return error.OutOfMemory,
228 error.OutOfMemory => |e| return e,
229229 error.TooManyMultilibs => return d.fatal("found more than one multilib with the same priority", .{}),
230230 };
231231 try tc.defineSystemIncludes();
lib/std/Build/Cache.zig+6-6
......@@ -562,14 +562,14 @@ pub const Manifest = struct {
562562 self.diagnostic = .{ .manifest_create = error.FileNotFound };
563563 return error.CacheCheckFailed;
564564 },
565 error.Canceled => return error.Canceled,
565 error.Canceled => |e| return e,
566566 else => |e| {
567567 self.diagnostic = .{ .manifest_create = e };
568568 return error.CacheCheckFailed;
569569 },
570570 }
571571 },
572 error.Canceled => return error.Canceled,
572 error.Canceled => |e| return e,
573573 else => |e| {
574574 self.diagnostic = .{ .manifest_create = e };
575575 return error.CacheCheckFailed;
......@@ -675,7 +675,7 @@ pub const Manifest = struct {
675675 var manifest_reader = self.manifest_file.?.reader(io, &tiny_buffer); // Reads positionally from zero.
676676 const limit: std.Io.Limit = .limited(manifest_file_size_max);
677677 const file_contents = manifest_reader.interface.allocRemaining(gpa, limit) catch |err| switch (err) {
678 error.OutOfMemory => return error.OutOfMemory,
678 error.OutOfMemory => |e| return e,
679679 error.StreamTooLong => return error.OutOfMemory,
680680 error.ReadFailed => {
681681 self.diagnostic = .{ .manifest_read = manifest_reader.err.? };
......@@ -767,7 +767,7 @@ pub const Manifest = struct {
767767 // Every digest before this one has been populated successfully.
768768 return .{ .miss = .{ .file_digests_populated = idx } };
769769 },
770 error.Canceled => return error.Canceled,
770 error.Canceled => |e| return e,
771771 else => |e| {
772772 self.diagnostic = .{ .file_open = .{
773773 .file_index = idx,
......@@ -880,14 +880,14 @@ pub const Manifest = struct {
880880 .read = true,
881881 .truncate = true,
882882 }) catch |err| switch (err) {
883 error.Canceled => return error.Canceled,
883 error.Canceled => |e| return e,
884884 else => return true,
885885 };
886886 defer file.close(io);
887887
888888 // Save locally and also save globally (we still hold the global lock).
889889 const stat = file.stat(io) catch |err| switch (err) {
890 error.Canceled => return error.Canceled,
890 error.Canceled => |e| return e,
891891 else => return true,
892892 };
893893 man.recent_problematic_timestamp = stat.mtime;
lib/std/Build/Step.zig+2-4
......@@ -282,8 +282,7 @@ pub fn make(s: *Step, options: MakeOptions) error{ MakeFailed, MakeSkipped }!voi
282282 }
283283
284284 make_result catch |err| switch (err) {
285 error.MakeFailed => return error.MakeFailed,
286 error.MakeSkipped => return error.MakeSkipped,
285 error.MakeFailed, error.MakeSkipped => |e| return e,
287286 else => {
288287 s.result_error_msgs.append(arena, @errorName(err)) catch @panic("OOM");
289288 return error.MakeFailed;
......@@ -845,8 +844,7 @@ fn failWithCacheError(
845844 });
846845 },
847846 },
848 error.OutOfMemory => return error.OutOfMemory,
849 error.Canceled => return error.Canceled,
847 error.OutOfMemory, error.Canceled => |e| return e,
850848 error.InvalidFormat => return s.fail("failed to check cache: invalid manifest file format", .{}),
851849 }
852850}
lib/std/Build/Step/Run.zig+2-2
......@@ -2704,7 +2704,7 @@ fn evalGeneric(run: *Run, spawn_options: process.SpawnOptions) !EvalGenericResul
27042704 } else {
27052705 var stdout_reader = stdout.readerStreaming(io, &.{});
27062706 stdout_bytes = stdout_reader.interface.allocRemaining(arena, run.stdio_limit) catch |err| switch (err) {
2707 error.OutOfMemory => return error.OutOfMemory,
2707 error.OutOfMemory => |e| return e,
27082708 error.ReadFailed => return stdout_reader.err.?,
27092709 error.StreamTooLong => return error.StdoutStreamTooLong,
27102710 };
......@@ -2712,7 +2712,7 @@ fn evalGeneric(run: *Run, spawn_options: process.SpawnOptions) !EvalGenericResul
27122712 } else if (child.stderr) |stderr| {
27132713 var stderr_reader = stderr.readerStreaming(io, &.{});
27142714 stderr_bytes = stderr_reader.interface.allocRemaining(arena, run.stdio_limit) catch |err| switch (err) {
2715 error.OutOfMemory => return error.OutOfMemory,
2715 error.OutOfMemory => |e| return e,
27162716 error.ReadFailed => return stderr_reader.err.?,
27172717 error.StreamTooLong => return error.StderrStreamTooLong,
27182718 };
lib/std/Build/WebServer.zig+2-2
......@@ -622,8 +622,8 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
622622 defer body_buffer.deinit(gpa);
623623
624624 while (true) {
625 const header = stdout.takeStruct(Header, .little) catch |e| switch (e) {
626 error.ReadFailed => return error.ReadFailed,
625 const header = stdout.takeStruct(Header, .little) catch |err| switch (err) {
626 error.ReadFailed => |e| return e,
627627 error.EndOfStream => break,
628628 };
629629 body_buffer.clearRetainingCapacity();
lib/std/Io/File/Writer.zig+8-6
......@@ -162,9 +162,10 @@ fn sendFilePositional(w: *Writer, file_reader: *Io.File.Reader, limit: Io.Limit)
162162 w.err = error.Canceled;
163163 return error.WriteFailed;
164164 },
165 error.EndOfStream => return error.EndOfStream,
166 error.Unimplemented => return error.Unimplemented,
167 error.ReadFailed => return error.ReadFailed,
165 error.EndOfStream,
166 error.Unimplemented,
167 error.ReadFailed,
168 => |e| return e,
168169 else => |e| {
169170 w.write_file_err = e;
170171 return error.WriteFailed;
......@@ -182,9 +183,10 @@ fn sendFileStreaming(w: *Writer, file_reader: *Io.File.Reader, limit: Io.Limit)
182183 w.err = error.Canceled;
183184 return error.WriteFailed;
184185 },
185 error.EndOfStream => return error.EndOfStream,
186 error.Unimplemented => return error.Unimplemented,
187 error.ReadFailed => return error.ReadFailed,
186 error.EndOfStream,
187 error.Unimplemented,
188 error.ReadFailed,
189 => |e| return e,
188190 else => |e| {
189191 w.write_file_err = e;
190192 return error.WriteFailed;
lib/std/Io/Reader.zig+8-9
......@@ -200,8 +200,7 @@ pub fn defaultDiscard(r: *Reader, limit: Limit) Error!usize {
200200 var d: Writer.Discarding = .init(r.buffer);
201201 var n = r.stream(&d.writer, limit) catch |err| switch (err) {
202202 error.WriteFailed => unreachable,
203 error.ReadFailed => return error.ReadFailed,
204 error.EndOfStream => return error.EndOfStream,
203 error.ReadFailed, error.EndOfStream => |e| return e,
205204 };
206205 // If `stream` wrote to `r.buffer` without going through the writer,
207206 // we need to discard as much of the buffered data as possible.
......@@ -379,7 +378,7 @@ pub fn appendRemainingAligned(
379378 const n = stream(r, &a.writer, remaining) catch |err| switch (err) {
380379 error.EndOfStream => return,
381380 error.WriteFailed => return error.OutOfMemory,
382 error.ReadFailed => return error.ReadFailed,
381 error.ReadFailed => |e| return e,
383382 };
384383 remaining = remaining.subtract(n).?;
385384 }
......@@ -400,7 +399,7 @@ pub fn appendRemainingUnlimited(r: *Reader, gpa: Allocator, list: *ArrayList(u8)
400399 }
401400 _ = streamRemaining(r, &a.writer) catch |err| switch (err) {
402401 error.WriteFailed => return error.OutOfMemory,
403 error.ReadFailed => return error.ReadFailed,
402 error.ReadFailed => |e| return e,
404403 };
405404}
406405
......@@ -428,7 +427,7 @@ pub fn readVec(r: *Reader, data: [][]u8) Error!usize {
428427 defer data[i] = buf;
429428 return n + (r.vtable.readVec(r, data[i..]) catch |err| switch (err) {
430429 error.EndOfStream => if (n == 0) return error.EndOfStream else 0,
431 error.ReadFailed => return error.ReadFailed,
430 error.ReadFailed => |e| return e,
432431 });
433432 }
434433 const n = seek - r.seek;
......@@ -639,7 +638,7 @@ pub fn discardShort(r: *Reader, n: usize) ShortError!usize {
639638 while (true) {
640639 const discard_len = r.vtable.discard(r, .limited(remaining)) catch |err| switch (err) {
641640 error.EndOfStream => return n - remaining,
642 error.ReadFailed => return error.ReadFailed,
641 error.ReadFailed => |e| return e,
643642 };
644643 remaining -= discard_len;
645644 if (remaining == 0) return n;
......@@ -687,7 +686,7 @@ pub fn readSliceShort(r: *Reader, buffer: []u8) ShortError!usize {
687686 data[0] = buffer[i..];
688687 i += readVec(r, &data) catch |err| switch (err) {
689688 error.EndOfStream => return i,
690 error.ReadFailed => return error.ReadFailed,
689 error.ReadFailed => |e| return e,
691690 };
692691 if (buffer.len - i == 0) return buffer.len;
693692 }
......@@ -1009,7 +1008,7 @@ pub fn streamDelimiterLimit(
10091008 var remaining = @intFromEnum(limit);
10101009 while (remaining != 0) {
10111010 const available = Limit.limited(remaining).slice(r.peekGreedy(1) catch |err| switch (err) {
1012 error.ReadFailed => return error.ReadFailed,
1011 error.ReadFailed => |e| return e,
10131012 error.EndOfStream => return @intFromEnum(limit) - remaining,
10141013 });
10151014 if (std.mem.findScalar(u8, available, delimiter)) |delimiter_index| {
......@@ -1080,7 +1079,7 @@ pub fn discardDelimiterLimit(r: *Reader, delimiter: u8, limit: Limit) DiscardDel
10801079 var remaining = @intFromEnum(limit);
10811080 while (remaining != 0) {
10821081 const available = Limit.limited(remaining).slice(r.peekGreedy(1) catch |err| switch (err) {
1083 error.ReadFailed => return error.ReadFailed,
1082 error.ReadFailed => |e| return e,
10841083 error.EndOfStream => return @intFromEnum(limit) - remaining,
10851084 });
10861085 if (std.mem.findScalar(u8, available, delimiter)) |delimiter_index| {
lib/std/Io/Terminal.zig+1-1
......@@ -61,7 +61,7 @@ pub const Mode = union(enum) {
6161 if (file.enableAnsiEscapeCodes(io)) |_| {
6262 return .escape_codes;
6363 } else |err| switch (err) {
64 error.Canceled => return error.Canceled,
64 error.Canceled => |e| return e,
6565 error.NotTerminalDevice, error.Unexpected => {},
6666 }
6767
lib/std/Io/Threaded.zig+4-4
......@@ -14589,7 +14589,7 @@ fn lookupDns(
1458914589 }
1459014590 }
1459114591 if (recv_err) |err| switch (err) {
14592 error.Canceled => return error.Canceled,
14592 error.Canceled => |e| return e,
1459314593 error.Timeout => continue :send,
1459414594 else => continue,
1459514595 };
......@@ -14726,13 +14726,13 @@ fn lookupHostsReader(
1472614726 const line = reader.takeDelimiterExclusive('\n') catch |err| switch (err) {
1472714727 error.StreamTooLong => {
1472814728 // Skip lines that are too long.
14729 _ = reader.discardDelimiterInclusive('\n') catch |e| switch (e) {
14729 _ = reader.discardDelimiterInclusive('\n') catch |er| switch (er) {
1473014730 error.EndOfStream => break,
14731 error.ReadFailed => return error.ReadFailed,
14731 error.ReadFailed => |e| return e,
1473214732 };
1473314733 continue;
1473414734 },
14735 error.ReadFailed => return error.ReadFailed,
14735 error.ReadFailed => |e| return e,
1473614736 error.EndOfStream => break,
1473714737 };
1473814738 reader.toss(@min(1, reader.bufferedLen()));
lib/std/Io/Uring.zig+1-1
......@@ -4958,7 +4958,7 @@ fn randomSecure(userdata: ?*anyopaque, buffer: []u8) Io.RandomSecureError!void {
49584958 var cancel_region: CancelRegion = .init();
49594959 defer cancel_region.deinit();
49604960 ev.urandomReadAll(&cancel_region, buffer) catch |err| switch (err) {
4961 error.Canceled => return error.Canceled,
4961 error.Canceled => |e| return e,
49624962 else => return error.EntropyUnavailable,
49634963 };
49644964}
lib/std/SemanticVersion.zig+1-1
......@@ -146,7 +146,7 @@ fn parseNum(text: []const u8) error{ InvalidVersion, Overflow }!usize {
146146
147147 return std.fmt.parseUnsigned(usize, text, 10) catch |err| switch (err) {
148148 error.InvalidCharacter => return error.InvalidVersion,
149 error.Overflow => return error.Overflow,
149 error.Overflow => |e| return e,
150150 };
151151}
152152
lib/std/Target/Query.zig+2-2
......@@ -253,7 +253,7 @@ pub fn parse(args: ParseOptions) !Query {
253253 } else if (abi.isAndroid()) {
254254 result.android_api_level = std.fmt.parseUnsigned(u32, abi_ver_text, 10) catch |err| switch (err) {
255255 error.InvalidCharacter => return error.InvalidVersion,
256 error.Overflow => return error.Overflow,
256 error.Overflow => |e| return e,
257257 };
258258 } else {
259259 return error.InvalidAbiVersion;
......@@ -346,7 +346,7 @@ pub fn parseVersion(ver: []const u8) error{ InvalidVersion, Overflow }!SemanticV
346346 fn parseVersionComponentInner(component: []const u8) error{ InvalidVersion, Overflow }!usize {
347347 return std.fmt.parseUnsigned(usize, component, 10) catch |err| switch (err) {
348348 error.InvalidCharacter => return error.InvalidVersion,
349 error.Overflow => return error.Overflow,
349 error.Overflow => |e| return e,
350350 };
351351 }
352352 }).parseVersionComponentInner;
lib/std/compress/flate/Decompress.zig+2-3
......@@ -129,8 +129,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
129129 }
130130 const n = r.stream(&writer, limit) catch |err| switch (err) {
131131 error.WriteFailed => unreachable,
132 error.ReadFailed => return error.ReadFailed,
133 error.EndOfStream => return error.EndOfStream,
132 error.ReadFailed, error.EndOfStream => |e| return e,
134133 };
135134 assert(n <= @intFromEnum(limit));
136135 return n;
......@@ -258,7 +257,7 @@ fn streamFallible(d: *Decompress, w: *Writer, limit: std.Io.Limit) Reader.Stream
258257 return error.ReadFailed;
259258 }
260259 },
261 error.WriteFailed => return error.WriteFailed,
260 error.WriteFailed => |e| return e,
262261 else => |e| {
263262 // In the event of an error, state is unmodified so that it can be
264263 // better used to diagnose the failure.
lib/std/compress/zstd/Decompress.zig+2-4
......@@ -173,8 +173,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
173173 }
174174 const n = r.stream(&writer, limit) catch |err| switch (err) {
175175 error.WriteFailed => unreachable,
176 error.ReadFailed => return error.ReadFailed,
177 error.EndOfStream => return error.EndOfStream,
176 error.ReadFailed, error.EndOfStream => |e| return e,
178177 };
179178 assert(n <= @intFromEnum(limit));
180179 return n;
......@@ -252,8 +251,7 @@ fn stream(d: *Decompress, w: *Writer, limit: Limit) Reader.StreamError!usize {
252251 },
253252 .in_frame => |*in_frame| {
254253 return readInFrame(d, w, limit, in_frame) catch |err| switch (err) {
255 error.ReadFailed => return error.ReadFailed,
256 error.WriteFailed => return error.WriteFailed,
254 error.ReadFailed, error.WriteFailed => |e| return e,
257255 else => |e| {
258256 d.err = e;
259257 return error.ReadFailed;
lib/std/crypto/codecs/base64_hex_ct.zig+2-4
......@@ -47,8 +47,7 @@ pub const hex = struct {
4747 }
4848 _ = decodeAny(bin, encoded, null) catch |err| {
4949 switch (err) {
50 error.InvalidCharacter => return error.InvalidCharacter,
51 error.InvalidPadding => return error.InvalidPadding,
50 error.InvalidCharacter, error.InvalidPadding => |e| return e,
5251 else => unreachable,
5352 }
5453 };
......@@ -228,8 +227,7 @@ pub const base64 = struct {
228227 pub fn decode(bin: []u8, encoded: []const u8, comptime variant: Variant) error{ InvalidCharacter, InvalidPadding }![]const u8 {
229228 return decodeAny(bin, encoded, variant, null) catch |err| {
230229 switch (err) {
231 error.InvalidCharacter => return error.InvalidCharacter,
232 error.InvalidPadding => return error.InvalidPadding,
230 error.InvalidCharacter, error.InvalidPadding => |e| return e,
233231 else => unreachable,
234232 }
235233 };
lib/std/crypto/tls.zig+1-1
......@@ -666,7 +666,7 @@ pub const Decoder = struct {
666666 if (request_amt > dest.len) return error.TlsRecordOverflow;
667667 stream.readSlice(dest[0..request_amt]) catch |err| switch (err) {
668668 error.EndOfStream => return error.TlsConnectionTruncated,
669 error.ReadFailed => return error.ReadFailed,
669 error.ReadFailed => |e| return e,
670670 };
671671 d.cap += request_amt;
672672 }
lib/std/crypto/tls/Client.zig+3-3
......@@ -353,7 +353,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
353353 if (record_len > tls.max_ciphertext_len) return error.TlsRecordOverflow;
354354 const record_buffer = input.take(record_len) catch |err| switch (err) {
355355 error.EndOfStream => return error.TlsConnectionTruncated,
356 error.ReadFailed => return error.ReadFailed,
356 error.ReadFailed => |e| return e,
357357 };
358358 var record_decoder: tls.Decoder = .fromTheirSlice(record_buffer);
359359 var ctd, const ct = content: switch (cipher_state) {
......@@ -1157,7 +1157,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
11571157 return failRead(c, error.TlsConnectionTruncated);
11581158 }
11591159 },
1160 error.ReadFailed => return error.ReadFailed,
1160 error.ReadFailed => |e| return e,
11611161 };
11621162 const ct: tls.ContentType = @enumFromInt(record_header[0]);
11631163 const legacy_version = mem.readInt(u16, record_header[1..][0..2], .big);
......@@ -1168,7 +1168,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
11681168 if (record_end > input.buffered().len) {
11691169 input.fillMore() catch |err| switch (err) {
11701170 error.EndOfStream => return failRead(c, error.TlsConnectionTruncated),
1171 error.ReadFailed => return error.ReadFailed,
1171 error.ReadFailed => |e| return e,
11721172 };
11731173 if (record_end > input.buffered().len) return 0;
11741174 }
lib/std/debug/Pdb.zig+1-1
......@@ -138,7 +138,7 @@ pub fn parseDbiStream(self: *Pdb) !void {
138138 if (section_contrib_size != 0) {
139139 const version = reader.takeEnum(pdb.SectionContrSubstreamVersion, .little) catch |err| switch (err) {
140140 error.InvalidEnumTag, error.EndOfStream => return error.InvalidDebugInfo,
141 error.ReadFailed => return error.ReadFailed,
141 error.ReadFailed => |e| return e,
142142 };
143143 _ = version;
144144 sect_cont_offset += @sizeOf(u32);
lib/std/fmt.zig+1-1
......@@ -542,7 +542,7 @@ pub fn parseIntSizeSuffix(buf: []const u8, digit_base: u8) ParseIntError!usize {
542542 }
543543 const multiplier = math.powi(usize, magnitude_base, orders_of_magnitude) catch |err| switch (err) {
544544 error.Underflow => unreachable,
545 error.Overflow => return error.Overflow,
545 error.Overflow => |e| return e,
546546 };
547547 const number = try std.fmt.parseInt(usize, without_suffix, digit_base);
548548 return math.mul(usize, number, multiplier);
lib/std/http.zig+3-4
......@@ -400,7 +400,7 @@ pub const Reader = struct {
400400 0 => return error.HttpConnectionClosing,
401401 else => return error.HttpRequestTruncated,
402402 },
403 error.ReadFailed => return error.ReadFailed,
403 error.ReadFailed => |e| return e,
404404 };
405405 continue;
406406 }
......@@ -543,8 +543,7 @@ pub const Reader = struct {
543543 else => unreachable,
544544 };
545545 return chunkedReadEndless(reader, w, limit, chunk_len_ptr) catch |err| switch (err) {
546 error.ReadFailed => return error.ReadFailed,
547 error.WriteFailed => return error.WriteFailed,
546 error.ReadFailed, error.WriteFailed => |e| return e,
548547 error.EndOfStream => {
549548 reader.body_err = error.HttpChunkTruncated;
550549 return error.ReadFailed;
......@@ -613,7 +612,7 @@ pub const Reader = struct {
613612 else => unreachable,
614613 };
615614 return chunkedDiscardEndless(reader, limit, chunk_len_ptr) catch |err| switch (err) {
616 error.ReadFailed => return error.ReadFailed,
615 error.ReadFailed => |e| return e,
617616 error.EndOfStream => {
618617 reader.body_err = error.HttpChunkTruncated;
619618 return error.ReadFailed;
lib/std/http/test.zig+1-1
......@@ -953,7 +953,7 @@ test "Server streams both reading and writing" {
953953 try response.flush();
954954 const buf = br.peekGreedy(1) catch |err| switch (err) {
955955 error.EndOfStream => break,
956 error.ReadFailed => return error.ReadFailed,
956 error.ReadFailed => |e| return e,
957957 };
958958 br.toss(buf.len);
959959 for (buf) |*b| b.* = std.ascii.toUpper(b.*);
lib/std/json/Scanner.zig+2-2
......@@ -1401,7 +1401,7 @@ pub fn validate(allocator: Allocator, s: []const u8) Allocator.Error!bool {
14011401 while (true) {
14021402 const token = scanner.next() catch |err| switch (err) {
14031403 error.SyntaxError, error.UnexpectedEndOfInput => return false,
1404 error.OutOfMemory => return error.OutOfMemory,
1404 error.OutOfMemory => |e| return e,
14051405 error.BufferUnderrun => unreachable,
14061406 };
14071407 if (token == .end_of_document) break;
......@@ -1734,7 +1734,7 @@ pub const Reader = struct {
17341734
17351735 fn refillBuffer(self: *@This()) std.Io.Reader.Error!void {
17361736 const input = self.reader.peekGreedy(1) catch |err| switch (err) {
1737 error.ReadFailed => return error.ReadFailed,
1737 error.ReadFailed => |e| return e,
17381738 error.EndOfStream => return self.scanner.endInput(),
17391739 };
17401740 self.reader.toss(input.len);
lib/std/process.zig+1-1
......@@ -130,7 +130,7 @@ pub fn posixGetUserInfo(io: Io, name: []const u8) !UserInfo {
130130 return posixGetUserInfoPasswdStream(name, &file_reader.interface) catch |err| switch (err) {
131131 error.ReadFailed => return file_reader.err.?,
132132 error.EndOfStream => return error.UserNotFound,
133 error.CorruptPasswordFile => return error.CorruptPasswordFile,
133 error.CorruptPasswordFile => |e| return e,
134134 };
135135}
136136
lib/std/zig/Ast/Render.zig+3-3
......@@ -998,8 +998,8 @@ fn rendersMultiline(r: *const Render, node: Ast.Node.Index) error{OutOfMemory}!b
998998 .fixups = r.fixups,
999999 };
10001000
1001 renderExpression(&sub_r, node, .none) catch |e| return switch (e) {
1002 error.OutOfMemory => return error.OutOfMemory,
1001 renderExpression(&sub_r, node, .none) catch |err| return switch (err) {
1002 error.OutOfMemory => |e| return e,
10031003 error.WriteFailed => return true,
10041004 };
10051005 if (sub_ais.disabled_offset != null) return true;
......@@ -1685,7 +1685,7 @@ fn renderBuiltinCall(
16851685 assert(tree.tokenTag(str_lit_token) == .string_literal);
16861686 const token_bytes = tree.tokenSlice(str_lit_token);
16871687 const imported_string = std.zig.string_literal.parseAlloc(r.gpa, token_bytes) catch |err| switch (err) {
1688 error.OutOfMemory => return error.OutOfMemory,
1688 error.OutOfMemory => |e| return e,
16891689 error.InvalidLiteral => break :f,
16901690 };
16911691 defer r.gpa.free(imported_string);
lib/std/zig/AstGen.zig+6-6
......@@ -199,7 +199,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
199199 assert(struct_decl_ref.toIndex().? == .main_struct_inst);
200200 break :fatal false;
201201 } else |err| switch (err) {
202 error.OutOfMemory => return error.OutOfMemory,
202 error.OutOfMemory => |e| return e,
203203 error.AnalysisFail => break :fatal true, // Handled via compile_errors below.
204204 }
205205 } else fatal: {
......@@ -5681,7 +5681,7 @@ fn containerMember(
56815681
56825682 const prev_decl_index = wip_decls.index;
56835683 astgen.fnDecl(gz, scope, wip_decls, member_node, body, full) catch |err| switch (err) {
5684 error.OutOfMemory => return error.OutOfMemory,
5684 error.OutOfMemory => |e| return e,
56855685 error.AnalysisFail => {
56865686 wip_decls.index = prev_decl_index;
56875687 try addFailedDeclaration(
......@@ -5704,7 +5704,7 @@ fn containerMember(
57045704 const full = tree.fullVarDecl(member_node).?;
57055705 const prev_decl_index = wip_decls.index;
57065706 astgen.globalVarDecl(gz, scope, wip_decls, member_node, full) catch |err| switch (err) {
5707 error.OutOfMemory => return error.OutOfMemory,
5707 error.OutOfMemory => |e| return e,
57085708 error.AnalysisFail => {
57095709 wip_decls.index = prev_decl_index;
57105710 try addFailedDeclaration(
......@@ -5722,7 +5722,7 @@ fn containerMember(
57225722 .@"comptime" => {
57235723 const prev_decl_index = wip_decls.index;
57245724 astgen.comptimeDecl(gz, scope, wip_decls, member_node) catch |err| switch (err) {
5725 error.OutOfMemory => return error.OutOfMemory,
5725 error.OutOfMemory => |e| return e,
57265726 error.AnalysisFail => {
57275727 wip_decls.index = prev_decl_index;
57285728 try addFailedDeclaration(
......@@ -5742,7 +5742,7 @@ fn containerMember(
57425742 // Since it doesn't strictly matter *what* this is, let's save ourselves the trouble
57435743 // of duplicating the test name logic, and just assume this is an unnamed test.
57445744 astgen.testDecl(gz, scope, wip_decls, member_node) catch |err| switch (err) {
5745 error.OutOfMemory => return error.OutOfMemory,
5745 error.OutOfMemory => |e| return e,
57465746 error.AnalysisFail => {
57475747 wip_decls.index = prev_decl_index;
57485748 try addFailedDeclaration(
......@@ -8563,7 +8563,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
85638563 big_int.setString(@intFromEnum(base), bytes[prefix_offset..]) catch |err| switch (err) {
85648564 error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
85658565 error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
8566 error.OutOfMemory => return error.OutOfMemory,
8566 error.OutOfMemory => |e| return e,
85678567 };
85688568
85698569 const limbs = big_int.limbs[0..big_int.len()];
lib/std/zig/LibCInstallation.zig+3-3
......@@ -196,7 +196,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
196196 const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.environ_map) catch |err| switch (err) {
197197 error.NotFound => return error.WindowsSdkNotFound,
198198 error.PathTooLong => return error.WindowsSdkNotFound,
199 error.OutOfMemory => return error.OutOfMemory,
199 error.OutOfMemory => |e| return e,
200200 };
201201 defer sdk.free(gpa);
202202
......@@ -278,7 +278,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
278278 // So we use the expandArg0 variant of ChildProcess to give them a helping hand.
279279 .expand_arg0 = .expand,
280280 }) catch |err| switch (err) {
281 error.OutOfMemory => return error.OutOfMemory,
281 error.OutOfMemory => |e| return e,
282282 else => {
283283 printVerboseInvocation(argv.items, null, args.verbose, null);
284284 return error.UnableToSpawnCCompiler;
......@@ -596,7 +596,7 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
596596 // So we use the expandArg0 variant of ChildProcess to give them a helping hand.
597597 .expand_arg0 = .expand,
598598 }) catch |err| switch (err) {
599 error.OutOfMemory => return error.OutOfMemory,
599 error.OutOfMemory => |e| return e,
600600 else => return error.UnableToSpawnCCompiler,
601601 };
602602 defer {
lib/std/zig/Parse.zig+7-7
......@@ -278,7 +278,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
278278 }
279279 const comptime_token = p.nextToken();
280280 const opt_block = p.parseBlock() catch |err| switch (err) {
281 error.OutOfMemory => return error.OutOfMemory,
281 error.OutOfMemory => |e| return e,
282282 error.ParseError => blk: {
283283 p.findNextContainerMember();
284284 break :blk null;
......@@ -301,7 +301,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
301301 const identifier = p.tok_i;
302302 defer last_field = identifier;
303303 const container_field = p.expectContainerField() catch |err| switch (err) {
304 error.OutOfMemory => return error.OutOfMemory,
304 error.OutOfMemory => |e| return e,
305305 error.ParseError => {
306306 p.findNextContainerMember();
307307 continue;
......@@ -398,7 +398,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
398398 },
399399 else => {
400400 const c_container = p.parseCStyleContainer() catch |err| switch (err) {
401 error.OutOfMemory => return error.OutOfMemory,
401 error.OutOfMemory => |e| return e,
402402 error.ParseError => false,
403403 };
404404 if (c_container) continue;
......@@ -406,7 +406,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
406406 const identifier = p.tok_i;
407407 defer last_field = identifier;
408408 const container_field = p.expectContainerField() catch |err| switch (err) {
409 error.OutOfMemory => return error.OutOfMemory,
409 error.OutOfMemory => |e| return e,
410410 error.ParseError => {
411411 p.findNextContainerMember();
412412 continue;
......@@ -589,7 +589,7 @@ fn expectTestDeclRecoverable(p: *Parse) error{OutOfMemory}!?Node.Index {
589589 if (p.expectTestDecl()) |node| {
590590 return node;
591591 } else |err| switch (err) {
592 error.OutOfMemory => return error.OutOfMemory,
592 error.OutOfMemory => |e| return e,
593593 error.ParseError => {
594594 p.findNextContainerMember();
595595 return null;
......@@ -668,7 +668,7 @@ fn expectTopLevelDecl(p: *Parse) !?Node.Index {
668668
669669fn expectTopLevelDeclRecoverable(p: *Parse) error{OutOfMemory}!?Node.Index {
670670 return p.expectTopLevelDecl() catch |err| switch (err) {
671 error.OutOfMemory => return error.OutOfMemory,
671 error.OutOfMemory => |e| return e,
672672 error.ParseError => {
673673 p.findNextContainerMember();
674674 return null;
......@@ -1145,7 +1145,7 @@ fn expectVarDeclExprStatement(p: *Parse, comptime_token: ?TokenIndex) !Node.Inde
11451145fn expectStatementRecoverable(p: *Parse) Error!?Node.Index {
11461146 while (true) {
11471147 return p.expectStatement(true) catch |err| switch (err) {
1148 error.OutOfMemory => return error.OutOfMemory,
1148 error.OutOfMemory => |e| return e,
11491149 error.ParseError => {
11501150 p.findNextStmt(); // Try to skip to the next statement.
11511151 switch (p.tokenTag(p.tok_i)) {
lib/std/zig/WindowsSdk.zig+13-13
......@@ -47,7 +47,7 @@ pub fn find(
4747 error.InstallationNotFound => null,
4848 error.PathTooLong => null,
4949 error.VersionTooLong => null,
50 error.OutOfMemory => return error.OutOfMemory,
50 error.OutOfMemory => |e| return e,
5151 };
5252 errdefer if (windows10sdk) |*w| w.free(gpa);
5353
......@@ -55,13 +55,13 @@ pub fn find(
5555 error.InstallationNotFound => null,
5656 error.PathTooLong => null,
5757 error.VersionTooLong => null,
58 error.OutOfMemory => return error.OutOfMemory,
58 error.OutOfMemory => |e| return e,
5959 };
6060 errdefer if (windows81sdk) |*w| w.free(gpa);
6161
6262 const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, &registry, arch, environ_map) catch |err| switch (err) {
6363 error.MsvcLibDirNotFound => null,
64 error.OutOfMemory => return error.OutOfMemory,
64 error.OutOfMemory => |e| return e,
6565 };
6666 errdefer gpa.free(msvc_lib_dir);
6767
......@@ -498,7 +498,7 @@ pub const Installation = struct {
498498 error.StringNotFound,
499499 => return error.InstallationNotFound,
500500
501 error.OutOfMemory => return error.OutOfMemory,
501 error.OutOfMemory => |e| return e,
502502 };
503503 defer gpa.free(path_w_maybe_with_trailing_slash);
504504
......@@ -572,7 +572,7 @@ pub const Installation = struct {
572572 error.StringNotFound,
573573 => return error.InstallationNotFound,
574574
575 error.OutOfMemory => return error.OutOfMemory,
575 error.OutOfMemory => |e| return e,
576576 };
577577 defer gpa.free(path_w_maybe_with_trailing_slash);
578578
......@@ -593,7 +593,7 @@ pub const Installation = struct {
593593 error.StringNotFound,
594594 => return error.InstallationNotFound,
595595
596 error.OutOfMemory => return error.OutOfMemory,
596 error.OutOfMemory => |e| return e,
597597 };
598598 defer gpa.free(version_without_0);
599599
......@@ -664,7 +664,7 @@ const MsvcLibDir = struct {
664664 error.StringNotFound,
665665 => return error.PathNotFound,
666666
667 error.OutOfMemory => return error.OutOfMemory,
667 error.OutOfMemory => |e| return e,
668668 };
669669 defer gpa.free(packages_path);
670670
......@@ -708,7 +708,7 @@ const MsvcLibDir = struct {
708708 error.StringNotFound,
709709 => return error.PathNotFound,
710710
711 error.OutOfMemory => return error.OutOfMemory,
711 error.OutOfMemory => |e| return e,
712712 };
713713 defer gpa.free(dll_path);
714714
......@@ -1042,7 +1042,7 @@ const MsvcLibDir = struct {
10421042 const config_key = root_key.open(config_path) catch continue;
10431043
10441044 const source_directories_value = config_key.getString(gpa, .{ .name = L("Source Directories") }, .wtf8) catch |err| switch (err) {
1045 error.OutOfMemory => return error.OutOfMemory,
1045 error.OutOfMemory => |e| return e,
10461046 else => continue,
10471047 };
10481048
......@@ -1118,7 +1118,7 @@ const MsvcLibDir = struct {
11181118 defer vs7_key.close();
11191119 try_vs7_key: {
11201120 const path_maybe_with_trailing_slash = vs7_key.getString(gpa, .{ .name = L("14.0") }, .wtf8) catch |err| switch (err) {
1121 error.OutOfMemory => return error.OutOfMemory,
1121 error.OutOfMemory => |e| return e,
11221122 else => break :try_vs7_key,
11231123 };
11241124
......@@ -1178,11 +1178,11 @@ const MsvcLibDir = struct {
11781178 environ_map: *const Environ.Map,
11791179 ) error{ OutOfMemory, MsvcLibDirNotFound }![]const u8 {
11801180 const full_path = MsvcLibDir.findViaCOM(gpa, io, registry, arch, environ_map) catch |err1| switch (err1) {
1181 error.OutOfMemory => return error.OutOfMemory,
1181 error.OutOfMemory => |e| return e,
11821182 error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, environ_map) catch |err2| switch (err2) {
1183 error.OutOfMemory => return error.OutOfMemory,
1183 error.OutOfMemory => |e| return e,
11841184 error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, registry, arch, environ_map) catch |err3| switch (err3) {
1185 error.OutOfMemory => return error.OutOfMemory,
1185 error.OutOfMemory => |e| return e,
11861186 error.PathNotFound => return error.MsvcLibDirNotFound,
11871187 },
11881188 },
lib/std/zig/ZonGen.zig+1-1
......@@ -668,7 +668,7 @@ fn numberLiteral(zg: *ZonGen, num_node: Ast.Node.Index, src_node: Ast.Node.Index
668668 big_int.setString(@intFromEnum(base), num_without_prefix) catch |err| switch (err) {
669669 error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
670670 error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
671 error.OutOfMemory => return error.OutOfMemory,
671 error.OutOfMemory => |e| return e,
672672 };
673673 switch (sign) {
674674 .positive => {},
lib/std/zip.zig+5-5
......@@ -143,7 +143,7 @@ pub const EndRecord = extern struct {
143143 const read_buf: []u8 = buf[buf.len - new_loaded_len ..][0..read_len];
144144 fr.interface.readSliceAll(read_buf) catch |err| switch (err) {
145145 error.ReadFailed => return fr.err.?,
146 error.EndOfStream => return error.EndOfStream,
146 error.EndOfStream => |e| return e,
147147 };
148148 loaded_len = new_loaded_len;
149149 }
......@@ -310,7 +310,7 @@ pub const Iterator = struct {
310310 try input.seekTo(stream_len - locator_end_offset);
311311 const locator = input.interface.takeStruct(EndLocator64, .little) catch |err| switch (err) {
312312 error.ReadFailed => return input.err.?,
313 error.EndOfStream => return error.EndOfStream,
313 error.EndOfStream => |e| return e,
314314 };
315315 if (!std.mem.eql(u8, &locator.signature, &end_locator64_sig))
316316 return error.ZipBadLocatorSig;
......@@ -323,7 +323,7 @@ pub const Iterator = struct {
323323
324324 const record64 = input.interface.takeStruct(EndRecord64, .little) catch |err| switch (err) {
325325 error.ReadFailed => return input.err.?,
326 error.EndOfStream => return error.EndOfStream,
326 error.EndOfStream => |e| return e,
327327 };
328328
329329 if (!std.mem.eql(u8, &record64.signature, &end_record64_sig))
......@@ -379,7 +379,7 @@ pub const Iterator = struct {
379379 try input.seekTo(header_zip_offset);
380380 const header = input.interface.takeStruct(CentralDirectoryFileHeader, .little) catch |err| switch (err) {
381381 error.ReadFailed => return input.err.?,
382 error.EndOfStream => return error.EndOfStream,
382 error.EndOfStream => |e| return e,
383383 };
384384 if (!std.mem.eql(u8, &header.signature, &central_file_header_sig))
385385 return error.ZipBadCdOffset;
......@@ -410,7 +410,7 @@ pub const Iterator = struct {
410410 try input.seekTo(header_zip_offset + @sizeOf(CentralDirectoryFileHeader) + header.filename_len);
411411 input.interface.readSliceAll(extra) catch |err| switch (err) {
412412 error.ReadFailed => return input.err.?,
413 error.EndOfStream => return error.EndOfStream,
413 error.EndOfStream => |e| return e,
414414 };
415415
416416 var extra_offset: usize = 0;
src/Compilation.zig+4-5
......@@ -2184,7 +2184,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
21842184 .global = options.config,
21852185 .parent = options.root_mod,
21862186 }) catch |err| switch (err) {
2187 error.OutOfMemory => return error.OutOfMemory,
2187 error.OutOfMemory => |e| return e,
21882188 // None of these are possible because the configuration matches the root module
21892189 // which already passed these checks.
21902190 error.ValgrindUnsupportedOnTarget => unreachable,
......@@ -2948,8 +2948,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
29482948 );
29492949 },
29502950 },
2951 error.OutOfMemory => return error.OutOfMemory,
2952 error.Canceled => return error.Canceled,
2951 error.OutOfMemory, error.Canceled => |e| return e,
29532952 error.InvalidFormat => return comp.setMiscFailure(
29542953 .check_whole_cache,
29552954 "failed to check cache: invalid manifest file format",
......@@ -3368,7 +3367,7 @@ fn flush(comp: *Compilation, arena: Allocator, tid: Zcu.PerThread.Id) (Io.Cancel
33683367 .lto = comp.config.lto,
33693368 }) catch |err| switch (err) {
33703369 error.LinkFailure => {}, // Already reported.
3371 error.OutOfMemory => return error.OutOfMemory,
3370 error.OutOfMemory => |e| return e,
33723371 };
33733372 }
33743373 }
......@@ -7236,7 +7235,7 @@ pub fn dumpArgv(io: Io, argv: []const []const u8) Io.Cancelable!void {
72367235 const w = &stderr.file_writer.interface;
72377236 return dumpArgvWriter(w, argv) catch |err| switch (err) {
72387237 error.WriteFailed => switch (stderr.file_writer.err.?) {
7239 error.Canceled => return error.Canceled,
7238 error.Canceled => |e| return e,
72407239 else => return,
72417240 },
72427241 };
src/Package/Fetch.zig+1-2
......@@ -1422,8 +1422,7 @@ fn unpackResource(
14221422 return try unpackTarball(f, tmp_directory.handle, &decompress.reader);
14231423 },
14241424 .git_pack => return unpackGitPack(f, tmp_directory.handle, &resource.git) catch |err| switch (err) {
1425 error.FetchFailed => return error.FetchFailed,
1426 error.OutOfMemory => return error.OutOfMemory,
1425 error.FetchFailed, error.OutOfMemory => |e| return e,
14271426 else => |e| return f.fail(f.location_tok, try eb.printString("unable to unpack git files: {t}", .{e})),
14281427 },
14291428 .zip => return unzip(f, tmp_directory.handle, resource.reader()) catch |err| switch (err) {
src/Sema.zig+1-1
......@@ -22339,7 +22339,7 @@ fn checkAtomicPtrOperand(
2233922339 try sema.ensureLayoutResolved(elem_ty, elem_ty_src, .ptr_access);
2234022340 var diag: Zcu.AtomicPtrAlignmentDiagnostics = .{};
2234122341 const alignment = zcu.atomicPtrAlignment(elem_ty, &diag) catch |err| switch (err) {
22342 error.OutOfMemory => return error.OutOfMemory,
22342 error.OutOfMemory => |e| return e,
2234322343 error.FloatTooBig => return sema.fail(
2234422344 block,
2234522345 elem_ty_src,
src/Value.zig+1-1
......@@ -1611,7 +1611,7 @@ pub fn hasRepeatedByteRepr(val: Value, zcu: *const Zcu) !?u8 {
16111611 defer zcu.gpa.free(byte_buffer);
16121612
16131613 writeToMemory(val, zcu, byte_buffer) catch |err| switch (err) {
1614 error.OutOfMemory => return error.OutOfMemory,
1614 error.OutOfMemory => |e| return e,
16151615 error.ReinterpretDeclRef => return null,
16161616 // TODO: The writeToMemory function was originally created for the purpose
16171617 // of comptime pointer casting. However, it is now additionally being used
src/Zcu.zig+1-1
......@@ -3922,7 +3922,7 @@ pub fn handleUpdateExports(
39223922) Allocator.Error!void {
39233923 const gpa = zcu.gpa;
39243924 result catch |err| switch (err) {
3925 error.OutOfMemory => return error.OutOfMemory,
3925 error.OutOfMemory => |e| return e,
39263926 error.AnalysisFail => {
39273927 const export_idx = export_indices[0];
39283928 const new_export = export_idx.ptr(zcu);
src/Zcu/PerThread.zig+1-1
......@@ -4582,7 +4582,7 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e
45824582 defer verify.deinit();
45834583
45844584 verify.verify() catch |err| switch (err) {
4585 error.OutOfMemory => return error.OutOfMemory,
4585 error.OutOfMemory => |e| return e,
45864586 else => return zcu.codegenFail(nav, "invalid liveness: {t}", .{err}),
45874587 };
45884588 }
src/codegen.zig+2-2
......@@ -760,7 +760,7 @@ fn lowerUavRef(
760760 .offset = w.end,
761761 .addend = @intCast(offset),
762762 }) catch |err| switch (err) {
763 error.OutOfMemory => return error.OutOfMemory,
763 error.OutOfMemory => |e| return e,
764764 else => |e| std.debug.panic("TODO rework lowerUav. internal error: {t}", .{e}),
765765 };
766766 const endian = target.cpu.arch.endian();
......@@ -903,7 +903,7 @@ pub fn genNavRef(
903903 }
904904 } else if (lf.cast(.elf2)) |elf| {
905905 return .{ .sym_index = @intFromEnum(elf.navSymbol(zcu, nav_index) catch |err| switch (err) {
906 error.OutOfMemory => return error.OutOfMemory,
906 error.OutOfMemory => |e| return e,
907907 else => |e| return .{ .fail = try ErrorMsg.create(
908908 zcu.gpa,
909909 src_loc,
src/codegen/aarch64/Select.zig+1-1
......@@ -11363,7 +11363,7 @@ fn writeToMemory(isel: *Select, constant: Constant, buffer: []u8) error{OutOfMem
1136311363 const ip = &zcu.intern_pool;
1136411364 if (try isel.writeKeyToMemory(ip.indexToKey(constant.toIntern()), buffer)) return true;
1136511365 constant.writeToMemory(zcu, buffer) catch |err| switch (err) {
11366 error.OutOfMemory => return error.OutOfMemory,
11366 error.OutOfMemory => |e| return e,
1136711367 error.ReinterpretDeclRef, error.Unimplemented, error.IllDefinedMemoryLayout => return false,
1136811368 };
1136911369 return true;
src/codegen/riscv64/CodeGen.zig+3-3
......@@ -812,7 +812,7 @@ pub fn generate(
812812
813813 const fn_info = zcu.typeToFunc(fn_type).?;
814814 var call_info = function.resolveCallingConventionValues(fn_info, &.{}) catch |err| switch (err) {
815 error.CodegenFail => return error.CodegenFail,
815 error.CodegenFail => |e| return e,
816816 else => |e| return e,
817817 };
818818
......@@ -841,7 +841,7 @@ pub fn generate(
841841 }));
842842
843843 function.gen() catch |err| switch (err) {
844 error.CodegenFail => return error.CodegenFail,
844 error.CodegenFail => |e| return e,
845845 error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
846846 else => |e| return e,
847847 };
......@@ -893,7 +893,7 @@ pub fn generateLazy(
893893 defer function.mir_instructions.deinit(gpa);
894894
895895 function.genLazy(lazy_sym) catch |err| switch (err) {
896 error.CodegenFail => return error.CodegenFail,
896 error.CodegenFail => |e| return e,
897897 error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
898898 else => |e| return e,
899899 };
src/codegen/sparc64/CodeGen.zig+2-2
......@@ -308,7 +308,7 @@ pub fn generate(
308308 defer function.exitlude_jump_relocs.deinit(gpa);
309309
310310 var call_info = function.resolveCallingConventionValues(func_ty, .callee) catch |err| switch (err) {
311 error.CodegenFail => return error.CodegenFail,
311 error.CodegenFail => |e| return e,
312312 else => |e| return e,
313313 };
314314 defer call_info.deinit(&function);
......@@ -319,7 +319,7 @@ pub fn generate(
319319 function.max_end_stack = call_info.stack_byte_count;
320320
321321 function.gen() catch |err| switch (err) {
322 error.CodegenFail => return error.CodegenFail,
322 error.CodegenFail => |e| return e,
323323 error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
324324 else => |e| return e,
325325 };
src/codegen/x86_64/CodeGen.zig+3-3
......@@ -938,7 +938,7 @@ pub fn generate(
938938
939939 const fn_info = zcu.typeToFunc(fn_type).?;
940940 var call_info = function.resolveCallingConventionValues(fn_info, &.{}, .args_frame) catch |err| switch (err) {
941 error.CodegenFail => return error.CodegenFail,
941 error.CodegenFail => |e| return e,
942942 else => |e| return e,
943943 };
944944 defer call_info.deinit(&function);
......@@ -983,7 +983,7 @@ pub fn generate(
983983 }
984984
985985 function.gen(&file.zir.?, func_zir.inst, func.comptime_args, call_info.air_arg_count) catch |err| switch (err) {
986 error.CodegenFail => return error.CodegenFail,
986 error.CodegenFail => |e| return e,
987987 error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
988988 else => |e| return e,
989989 };
......@@ -1071,7 +1071,7 @@ pub fn generateLazy(
10711071 }
10721072
10731073 function.genLazy(lazy_sym) catch |err| switch (err) {
1074 error.CodegenFail => return error.CodegenFail,
1074 error.CodegenFail => |e| return e,
10751075 error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
10761076 else => |e| return e,
10771077 };
src/libs/libcxx.zig+2-2
......@@ -285,7 +285,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
285285 defer sub_compilation.destroy();
286286
287287 comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
288 error.AlreadyReported => return error.AlreadyReported,
288 error.AlreadyReported => |e| return e,
289289 else => |e| {
290290 comp.lockAndSetMiscFailure(misc_task, "unable to build libc++: compilation failed: {t}", .{e});
291291 return error.AlreadyReported;
......@@ -478,7 +478,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
478478 defer sub_compilation.destroy();
479479
480480 comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
481 error.AlreadyReported => return error.AlreadyReported,
481 error.AlreadyReported => |e| return e,
482482 else => |e| {
483483 comp.lockAndSetMiscFailure(
484484 .libcxxabi,
src/libs/libtsan.zig+1-1
......@@ -313,7 +313,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
313313 defer sub_compilation.destroy();
314314
315315 comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
316 error.AlreadyReported => return error.AlreadyReported,
316 error.AlreadyReported => |e| return e,
317317 else => |e| {
318318 comp.lockAndSetMiscFailure(misc_task, "unable to build {t}: compilation failed: {s}", .{ misc_task, @errorName(e) });
319319 return error.AlreadyReported;
src/libs/libunwind.zig+1-1
......@@ -171,7 +171,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
171171 defer sub_compilation.destroy();
172172
173173 comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
174 error.AlreadyReported => return error.AlreadyReported,
174 error.AlreadyReported => |e| return e,
175175 else => |e| {
176176 comp.lockAndSetMiscFailure(misc_task, "unable to build {t}: compilation failed: {s}", .{ misc_task, @errorName(e) });
177177 return error.AlreadyReported;
src/link/Coff.zig+4-4
......@@ -1716,7 +1716,7 @@ pub fn updateErrorData(coff: *Coff, pt: Zcu.PerThread) !void {
17161716 .kind = .const_data,
17171717 .index = @intCast(coff.lazy.getPtr(.const_data).map.getIndex(.anyerror_type) orelse return),
17181718 }) catch |err| switch (err) {
1719 error.OutOfMemory => return error.OutOfMemory,
1719 error.OutOfMemory => |e| return e,
17201720 error.CodegenFail => return error.LinkFailure,
17211721 else => |e| return coff.base.comp.link_diags.fail("updateErrorData failed {t}", .{e}),
17221722 };
......@@ -1765,7 +1765,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
17651765 pending_uav.value.alignment,
17661766 pending_uav.value.src_loc,
17671767 ) catch |err| switch (err) {
1768 error.OutOfMemory => return error.OutOfMemory,
1768 error.OutOfMemory => |e| return e,
17691769 else => |e| return comp.link_diags.fail(
17701770 "linker failed to lower constant: {t}",
17711771 .{e},
......@@ -1783,7 +1783,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
17831783 );
17841784 defer sub_prog_node.end();
17851785 coff.flushGlobal(pt, gmi) catch |err| switch (err) {
1786 error.OutOfMemory => return error.OutOfMemory,
1786 error.OutOfMemory => |e| return e,
17871787 else => |e| return comp.link_diags.fail(
17881788 "linker failed to lower constant: {t}",
17891789 .{e},
......@@ -1810,7 +1810,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
18101810 );
18111811 defer sub_prog_node.end();
18121812 coff.flushLazy(pt, lmr) catch |err| switch (err) {
1813 error.OutOfMemory => return error.OutOfMemory,
1813 error.OutOfMemory => |e| return e,
18141814 else => |e| return comp.link_diags.fail(
18151815 "linker failed to lower lazy {s}: {t}",
18161816 .{ kind, e },
src/link/Elf.zig+2-3
......@@ -757,8 +757,7 @@ pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std
757757 defer sub_prog_node.end();
758758
759759 return flushInner(self, arena, tid) catch |err| switch (err) {
760 error.OutOfMemory => return error.OutOfMemory,
761 error.LinkFailure => return error.LinkFailure,
760 error.OutOfMemory, error.LinkFailure => |e| return e,
762761 else => |e| return diags.fail("ELF flush failed: {t}", .{e}),
763762 };
764763}
......@@ -1717,7 +1716,7 @@ pub fn updateContainerType(
17171716 @panic("Attempted to compile for object format that was disabled by build configuration");
17181717 }
17191718 return self.zigObjectPtr().?.updateContainerType(pt, ty, success) catch |err| switch (err) {
1720 error.OutOfMemory => return error.OutOfMemory,
1719 error.OutOfMemory => |e| return e,
17211720 };
17221721}
17231722
src/link/Elf/ZigObject.zig+4-7
......@@ -1042,7 +1042,7 @@ pub fn lowerUav(
10421042 osec,
10431043 src_loc,
10441044 ) catch |err| switch (err) {
1045 error.OutOfMemory => return error.OutOfMemory,
1045 error.OutOfMemory => |e| return e,
10461046 else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
10471047 gpa,
10481048 src_loc,
......@@ -1659,8 +1659,7 @@ pub fn updateNav(
16591659 var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index);
16601660 defer debug_wip_nav.deinit();
16611661 dwarf.finishWipNav(pt, nav_index, &debug_wip_nav) catch |err| switch (err) {
1662 error.OutOfMemory => return error.OutOfMemory,
1663 error.Overflow => return error.Overflow,
1662 error.OutOfMemory, error.Overflow => |e| return e,
16641663 else => |e| return elf_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
16651664 };
16661665 }
......@@ -1703,8 +1702,7 @@ pub fn updateNav(
17031702 try self.updateNavCode(elf_file, pt, nav_index, sym_index, shndx, code, elf.STT_OBJECT);
17041703
17051704 if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNav(pt, nav_index, wip_nav) catch |err| switch (err) {
1706 error.OutOfMemory => return error.OutOfMemory,
1707 error.Overflow => return error.Overflow,
1705 error.OutOfMemory, error.Overflow => |e| return e,
17081706 else => |e| return elf_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
17091707 };
17101708 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);
......@@ -1958,8 +1956,7 @@ pub fn updateLineNumber(self: *ZigObject, pt: Zcu.PerThread, ti_id: InternPool.T
19581956 const comp = dwarf.bin_file.comp;
19591957 const diags = &comp.link_diags;
19601958 dwarf.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
1961 error.Overflow => return error.Overflow,
1962 error.OutOfMemory => return error.OutOfMemory,
1959 error.Overflow, error.OutOfMemory => |e| return e,
19631960 else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
19641961 };
19651962 }
src/link/Elf2.zig+5-5
......@@ -2399,7 +2399,7 @@ fn loadDsoExact(elf: *Elf, name: []const u8) !void {
23992399pub fn prelink(elf: *Elf, prog_node: std.Progress.Node) !void {
24002400 _ = prog_node;
24012401 elf.prelinkInner() catch |err| switch (err) {
2402 error.OutOfMemory => return error.OutOfMemory,
2402 error.OutOfMemory => |e| return e,
24032403 else => |e| return elf.base.comp.link_diags.fail("prelink failed: {t}", .{e}),
24042404 };
24052405}
......@@ -2934,7 +2934,7 @@ pub fn lowerUav(
29342934
29352935 try elf.pending_uavs.ensureUnusedCapacity(gpa, 1);
29362936 const umi = elf.uavMapIndex(uav_val) catch |err| switch (err) {
2937 error.OutOfMemory => return error.OutOfMemory,
2937 error.OutOfMemory => |e| return e,
29382938 else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
29392939 gpa,
29402940 src_loc,
......@@ -3057,7 +3057,7 @@ pub fn updateErrorData(elf: *Elf, pt: Zcu.PerThread) !void {
30573057 .kind = .const_data,
30583058 .index = @intCast(elf.lazy.getPtr(.const_data).map.getIndex(.anyerror_type) orelse return),
30593059 }) catch |err| switch (err) {
3060 error.OutOfMemory => return error.OutOfMemory,
3060 error.OutOfMemory => |e| return e,
30613061 error.CodegenFail => return error.LinkFailure,
30623062 else => |e| return elf.base.comp.link_diags.fail("updateErrorData failed: {t}", .{e}),
30633063 };
......@@ -3091,7 +3091,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) !bool {
30913091 pending_uav.value.alignment,
30923092 pending_uav.value.src_loc,
30933093 ) catch |err| switch (err) {
3094 error.OutOfMemory => return error.OutOfMemory,
3094 error.OutOfMemory => |e| return e,
30953095 else => |e| return comp.link_diags.fail(
30963096 "linker failed to lower constant: {t}",
30973097 .{e},
......@@ -3118,7 +3118,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) !bool {
31183118 );
31193119 defer sub_prog_node.end();
31203120 elf.flushLazy(pt, lmr) catch |err| switch (err) {
3121 error.OutOfMemory => return error.OutOfMemory,
3121 error.OutOfMemory => |e| return e,
31223122 else => |e| return comp.link_diags.fail(
31233123 "linker failed to lower lazy {s}: {t}",
31243124 .{ kind, e },
src/link/MachO.zig+7-11
......@@ -504,7 +504,7 @@ pub fn flush(
504504 try self.resolveSymbols();
505505 try self.convertTentativeDefsAndResolveSpecialSymbols();
506506 self.dedupLiterals() catch |err| switch (err) {
507 error.LinkFailure => return error.LinkFailure,
507 error.LinkFailure => |e| return e,
508508 else => |e| return diags.fail("failed to deduplicate literals: {s}", .{@errorName(e)}),
509509 };
510510
......@@ -542,7 +542,7 @@ pub fn flush(
542542
543543 try self.initSegments();
544544 self.allocateSections() catch |err| switch (err) {
545 error.LinkFailure => return error.LinkFailure,
545 error.LinkFailure => |e| return e,
546546 else => |e| return diags.fail("failed to allocate sections: {s}", .{@errorName(e)}),
547547 };
548548 self.allocateSegments();
......@@ -567,8 +567,7 @@ pub fn flush(
567567 try self.writeSectionsToFile();
568568 try self.allocateLinkeditSegment();
569569 self.writeLinkeditSectionsToFile() catch |err| switch (err) {
570 error.OutOfMemory => return error.OutOfMemory,
571 error.LinkFailure => return error.LinkFailure,
570 error.OutOfMemory, error.LinkFailure => |e| return e,
572571 else => |e| return diags.fail("failed to write linkedit sections to file: {t}", .{e}),
573572 };
574573
......@@ -595,25 +594,22 @@ pub fn flush(
595594
596595 const ncmds, const sizeofcmds, const uuid_cmd_offset = self.writeLoadCommands() catch |err| switch (err) {
597596 error.WriteFailed => unreachable,
598 error.OutOfMemory => return error.OutOfMemory,
599 error.LinkFailure => return error.LinkFailure,
597 error.OutOfMemory, error.LinkFailure => |e| return e,
600598 };
601599 try self.writeHeader(ncmds, sizeofcmds);
602600 self.writeUuid(uuid_cmd_offset, self.requiresCodeSig()) catch |err| switch (err) {
603 error.OutOfMemory => return error.OutOfMemory,
604 error.LinkFailure => return error.LinkFailure,
601 error.OutOfMemory, error.LinkFailure => |e| return e,
605602 else => |e| return diags.fail("failed to calculate and write uuid: {s}", .{@errorName(e)}),
606603 };
607604 if (self.getDebugSymbols()) |dsym| dsym.flush(self) catch |err| switch (err) {
608 error.OutOfMemory => return error.OutOfMemory,
605 error.OutOfMemory => |e| return e,
609606 else => |e| return diags.fail("failed to get debug symbols: {s}", .{@errorName(e)}),
610607 };
611608
612609 // Code signing always comes last.
613610 if (codesig) |*csig| {
614611 self.writeCodeSignature(csig) catch |err| switch (err) {
615 error.OutOfMemory => return error.OutOfMemory,
616 error.LinkFailure => return error.LinkFailure,
612 error.OutOfMemory, error.LinkFailure => |e| return e,
617613 else => |e| return diags.fail("failed to write code signature: {s}", .{@errorName(e)}),
618614 };
619615 const emit = self.base.emit;
src/link/MachO/ZigObject.zig+7-12
......@@ -571,8 +571,7 @@ pub fn flush(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) link.F
571571 .{ .kind = .code, .ty = .anyerror_type },
572572 metadata.text_symbol_index,
573573 ) catch |err| switch (err) {
574 error.OutOfMemory => return error.OutOfMemory,
575 error.LinkFailure => return error.LinkFailure,
574 error.OutOfMemory, error.LinkFailure => |e| return e,
576575 else => |e| return diags.fail("failed to update lazy symbol: {s}", .{@errorName(e)}),
577576 };
578577 if (metadata.const_state != .unused) self.updateLazySymbol(
......@@ -581,8 +580,7 @@ pub fn flush(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) link.F
581580 .{ .kind = .const_data, .ty = .anyerror_type },
582581 metadata.const_symbol_index,
583582 ) catch |err| switch (err) {
584 error.OutOfMemory => return error.OutOfMemory,
585 error.LinkFailure => return error.LinkFailure,
583 error.OutOfMemory, error.LinkFailure => |e| return e,
586584 else => |e| return diags.fail("failed to update lazy symbol: {s}", .{@errorName(e)}),
587585 };
588586 }
......@@ -595,7 +593,7 @@ pub fn flush(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) link.F
595593 const pt: Zcu.PerThread = .activate(macho_file.base.comp.zcu.?, tid);
596594 defer pt.deactivate();
597595 dwarf.flush(pt) catch |err| switch (err) {
598 error.OutOfMemory => return error.OutOfMemory,
596 error.OutOfMemory => |e| return e,
599597 else => |e| return diags.fail("failed to flush dwarf module: {s}", .{@errorName(e)}),
600598 };
601599
......@@ -735,7 +733,7 @@ pub fn lowerUav(
735733 macho_file.zig_const_sect_index.?,
736734 src_loc,
737735 ) catch |err| switch (err) {
738 error.OutOfMemory => return error.OutOfMemory,
736 error.OutOfMemory => |e| return e,
739737 else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
740738 gpa,
741739 src_loc,
......@@ -889,8 +887,7 @@ pub fn updateNav(
889887 var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index);
890888 defer debug_wip_nav.deinit();
891889 dwarf.finishWipNav(pt, nav_index, &debug_wip_nav) catch |err| switch (err) {
892 error.OutOfMemory => return error.OutOfMemory,
893 error.Overflow => return error.Overflow,
890 error.OutOfMemory, error.Overflow => |e| return e,
894891 else => |e| return macho_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
895892 };
896893 }
......@@ -928,8 +925,7 @@ pub fn updateNav(
928925 try self.updateNavCode(macho_file, pt, nav_index, sym_index, sect_index, code);
929926
930927 if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNav(pt, nav_index, wip_nav) catch |err| switch (err) {
931 error.OutOfMemory => return error.OutOfMemory,
932 error.Overflow => return error.Overflow,
928 error.OutOfMemory, error.Overflow => |e| return e,
933929 else => |e| return macho_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
934930 };
935931 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);
......@@ -1422,8 +1418,7 @@ pub fn updateLineNumber(self: *ZigObject, pt: Zcu.PerThread, ti_id: InternPool.T
14221418 const comp = dwarf.bin_file.comp;
14231419 const diags = &comp.link_diags;
14241420 dwarf.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
1425 error.Overflow => return error.Overflow,
1426 error.OutOfMemory => return error.OutOfMemory,
1421 error.Overflow, error.OutOfMemory => |e| return e,
14271422 else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
14281423 };
14291424 }
src/link/MachO/relocatable.zig+2-3
......@@ -42,8 +42,7 @@ pub fn flushObject(macho_file: *MachO, comp: *Compilation, module_obj_path: ?Pat
4242
4343 try macho_file.resolveSymbols();
4444 macho_file.dedupLiterals() catch |err| switch (err) {
45 error.OutOfMemory => return error.OutOfMemory,
46 error.LinkFailure => return error.LinkFailure,
45 error.OutOfMemory, error.LinkFailure => |e| return e,
4746 else => |e| return diags.fail("failed to update ar size: {s}", .{@errorName(e)}),
4847 };
4948 markExports(macho_file);
......@@ -55,7 +54,7 @@ pub fn flushObject(macho_file: *MachO, comp: *Compilation, module_obj_path: ?Pat
5554
5655 try createSegment(macho_file);
5756 allocateSections(macho_file) catch |err| switch (err) {
58 error.LinkFailure => return error.LinkFailure,
57 error.LinkFailure => |e| return e,
5958 else => |e| return diags.fail("failed to allocate sections: {s}", .{@errorName(e)}),
6059 };
6160 allocateSegment(macho_file);
src/link/SpirV.zig+1-1
......@@ -283,7 +283,7 @@ pub fn flush(
283283 errdefer arena.free(module);
284284
285285 const linked_module = linkModule(arena, module, sub_prog_node) catch |err| switch (err) {
286 error.OutOfMemory => return error.OutOfMemory,
286 error.OutOfMemory => |e| return e,
287287 else => |other| return diags.fail("error while linking: {s}", .{@errorName(other)}),
288288 };
289289
src/link/Wasm.zig+2-4
......@@ -3345,8 +3345,7 @@ pub fn updateLineNumber(wasm: *Wasm, pt: Zcu.PerThread, ti_id: InternPool.Tracke
33453345 const diags = &comp.link_diags;
33463346 if (wasm.dwarf) |*dw| {
33473347 dw.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
3348 error.Overflow => return error.Overflow,
3349 error.OutOfMemory => return error.OutOfMemory,
3348 error.Overflow, error.OutOfMemory => |e| return e,
33503349 else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
33513350 };
33523351 }
......@@ -3873,8 +3872,7 @@ pub fn flush(
38733872 try wasm.flush_buffer.data_imports.reinit(gpa, wasm.data_imports.keys(), wasm.data_imports.values());
38743873
38753874 return wasm.flush_buffer.finish(wasm) catch |err| switch (err) {
3876 error.OutOfMemory => return error.OutOfMemory,
3877 error.LinkFailure => return error.LinkFailure,
3875 error.OutOfMemory, error.LinkFailure => |e| return e,
38783876 else => |e| return diags.fail("failed to flush wasm: {s}", .{@errorName(e)}),
38793877 };
38803878}
src/main.zig+1-1
......@@ -4205,7 +4205,7 @@ fn createModule(
42054205 error.StackCheckUnsupportedByTarget => fatal("unable to create module '{s}': the selected target does not support stack checking", .{name}),
42064206 error.StackProtectorUnsupportedByTarget => fatal("unable to create module '{s}': the selected target does not support stack protection", .{name}),
42074207 error.StackProtectorUnavailableWithoutLibC => fatal("unable to create module '{s}': enabling stack protection requires libc", .{name}),
4208 error.OutOfMemory => return error.OutOfMemory,
4208 error.OutOfMemory => |e| return e,
42094209 };
42104210 cli_mod.resolved = mod;
42114211
src/print_targets.zig+1-1
......@@ -31,7 +31,7 @@ pub fn cmdTargets(
3131 allocator,
3232 .limited(glibc.abilists_max_size),
3333 ) catch |err| switch (err) {
34 error.OutOfMemory => return error.OutOfMemory,
34 error.OutOfMemory => |e| return e,
3535 else => fatal("unable to read " ++ glibc.abilists_path ++ ": {t}", .{err}),
3636 };
3737 defer allocator.free(abilists_contents);