mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
Prefer <err> => |e| return e over <err> => return <err>
Avoids the potential for a typo on the `return <err>` side of the prong
This commit is contained in:
Vendored
+2
-4
@@ -102,14 +102,12 @@ pub fn genIr(tree: *const Tree) Compilation.Error!Ir {
|
||||
.function => |function| {
|
||||
if (function.body == null) continue;
|
||||
c.genFn(function) catch |err| switch (err) {
|
||||
error.FatalError => return error.FatalError,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FatalError, error.OutOfMemory => |e| return e,
|
||||
};
|
||||
},
|
||||
|
||||
.variable => |variable| c.genVar(variable) catch |err| switch (err) {
|
||||
error.FatalError => return error.FatalError,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FatalError, error.OutOfMemory => |e| return e,
|
||||
},
|
||||
.global_asm => {
|
||||
return c.fail("TODO global assembly", .{});
|
||||
|
||||
Vendored
+2
-2
@@ -2085,7 +2085,7 @@ pub fn findEmbed(
|
||||
if (opt_dep_file) |dep_file| try dep_file.addDependencyDupe(comp.gpa, comp.arena, filename);
|
||||
return some;
|
||||
} else |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => {},
|
||||
}
|
||||
},
|
||||
@@ -2100,7 +2100,7 @@ pub fn findEmbed(
|
||||
if (opt_dep_file) |dep_file| try dep_file.addDependencyDupe(comp.gpa, comp.arena, filename);
|
||||
return some;
|
||||
} else |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5
-7
@@ -1182,8 +1182,7 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_
|
||||
var stdout = std.Io.File.stdout().writer(d.comp.io, &stdout_buf);
|
||||
if (parseArgs(d, &stdout.interface, ¯o_buf, args) catch |er| switch (er) {
|
||||
error.WriteFailed => return d.fatal("failed to write to stdout: {s}", .{errorDescription(er)}),
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FatalError => return error.FatalError,
|
||||
error.OutOfMemory, error.FatalError => |e| return e,
|
||||
}) return;
|
||||
if (macro_buf.items.len > std.math.maxInt(u32)) {
|
||||
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_
|
||||
};
|
||||
|
||||
tc.discover() catch |er| switch (er) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.TooManyMultilibs => return d.fatal("found more than one multilib with the same priority", .{}),
|
||||
};
|
||||
tc.defineSystemIncludes() catch |er| switch (er) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FatalError => return error.FatalError,
|
||||
error.OutOfMemory, error.FatalError => |e| return e,
|
||||
};
|
||||
try d.comp.initSearchPath(d.includes.items, d.verbose_search_path);
|
||||
|
||||
@@ -1525,8 +1523,8 @@ fn processSource(
|
||||
render_errors.deinit(gpa);
|
||||
}
|
||||
|
||||
var obj = ir.render(gpa, d.comp.target.toZigTarget(), &render_errors) catch |e| switch (e) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
var obj = ir.render(gpa, d.comp.target.toZigTarget(), &render_errors) catch |er| switch (er) {
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.LowerFail => {
|
||||
return d.fatal(
|
||||
"unable to render Ir to machine code: {s}",
|
||||
|
||||
Vendored
+2
-3
@@ -5725,9 +5725,8 @@ fn returnStmt(p: *Parser) Error!?Node.Index {
|
||||
// ====== expressions ======
|
||||
|
||||
pub fn macroExpr(p: *Parser) Compilation.Error!bool {
|
||||
const res = p.expect(condExpr) catch |e| switch (e) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FatalError => return error.FatalError,
|
||||
const res = p.expect(condExpr) catch |er| switch (er) {
|
||||
error.OutOfMemory, error.FatalError => |e| return e,
|
||||
error.ParsingFailed => return false,
|
||||
};
|
||||
return res.val.toBool(p.comp);
|
||||
|
||||
+1
-2
@@ -150,8 +150,7 @@ pub fn genAsm(tree: *const Tree) Error!Assembly {
|
||||
|
||||
codegen.genDecls() catch |err| switch (err) {
|
||||
error.WriteFailed => return error.OutOfMemory,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FatalError => return error.FatalError,
|
||||
error.OutOfMemory, error.FatalError => |e| return e,
|
||||
};
|
||||
|
||||
const text_slice = try text.toOwnedSlice();
|
||||
|
||||
@@ -488,7 +488,7 @@ var fuzz_runner: if (builtin.fuzz) struct {
|
||||
fn inputPoller() Io.Cancelable!void {
|
||||
@disableInstrumentation();
|
||||
switch (inputPollerInner()) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
error.ReadFailed => {
|
||||
if (stdin_reader.err.? == error.Canceled) return error.Canceled;
|
||||
panic("failed to read from stdin: {t}", .{stdin_reader.err.?});
|
||||
|
||||
+2
-2
@@ -1297,7 +1297,7 @@ fn transType(t: *Translator, scope: *Scope, qt: QualType, source_loc: TokenIndex
|
||||
error.SelfReferential => {},
|
||||
error.UnsupportedTranslation => {},
|
||||
error.UnsupportedType => {},
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
}
|
||||
}
|
||||
continue :loop typeof_ty.base.type(t.comp);
|
||||
@@ -4099,7 +4099,7 @@ fn createIntNode(t: *Translator, int: aro.Value) !ZigNode {
|
||||
big.positive = true;
|
||||
|
||||
const str = big.toStringAlloc(t.arena, 10, .lower) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
const res = try ZigTag.integer_literal.create(t.arena, str);
|
||||
if (is_negative) return ZigTag.negate.create(t.arena, res);
|
||||
|
||||
Vendored
+1
-1
@@ -225,7 +225,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
|
||||
const source = d.inputs.items[0];
|
||||
|
||||
tc.discover() catch |er| switch (er) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.TooManyMultilibs => return d.fatal("found more than one multilib with the same priority", .{}),
|
||||
};
|
||||
try tc.defineSystemIncludes();
|
||||
|
||||
@@ -562,14 +562,14 @@ pub const Manifest = struct {
|
||||
self.diagnostic = .{ .manifest_create = error.FileNotFound };
|
||||
return error.CacheCheckFailed;
|
||||
},
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => |e| {
|
||||
self.diagnostic = .{ .manifest_create = e };
|
||||
return error.CacheCheckFailed;
|
||||
},
|
||||
}
|
||||
},
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => |e| {
|
||||
self.diagnostic = .{ .manifest_create = e };
|
||||
return error.CacheCheckFailed;
|
||||
@@ -675,7 +675,7 @@ pub const Manifest = struct {
|
||||
var manifest_reader = self.manifest_file.?.reader(io, &tiny_buffer); // Reads positionally from zero.
|
||||
const limit: std.Io.Limit = .limited(manifest_file_size_max);
|
||||
const file_contents = manifest_reader.interface.allocRemaining(gpa, limit) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.StreamTooLong => return error.OutOfMemory,
|
||||
error.ReadFailed => {
|
||||
self.diagnostic = .{ .manifest_read = manifest_reader.err.? };
|
||||
@@ -767,7 +767,7 @@ pub const Manifest = struct {
|
||||
// Every digest before this one has been populated successfully.
|
||||
return .{ .miss = .{ .file_digests_populated = idx } };
|
||||
},
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => |e| {
|
||||
self.diagnostic = .{ .file_open = .{
|
||||
.file_index = idx,
|
||||
@@ -880,14 +880,14 @@ pub const Manifest = struct {
|
||||
.read = true,
|
||||
.truncate = true,
|
||||
}) catch |err| switch (err) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => return true,
|
||||
};
|
||||
defer file.close(io);
|
||||
|
||||
// Save locally and also save globally (we still hold the global lock).
|
||||
const stat = file.stat(io) catch |err| switch (err) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => return true,
|
||||
};
|
||||
man.recent_problematic_timestamp = stat.mtime;
|
||||
|
||||
@@ -282,8 +282,7 @@ pub fn make(s: *Step, options: MakeOptions) error{ MakeFailed, MakeSkipped }!voi
|
||||
}
|
||||
|
||||
make_result catch |err| switch (err) {
|
||||
error.MakeFailed => return error.MakeFailed,
|
||||
error.MakeSkipped => return error.MakeSkipped,
|
||||
error.MakeFailed, error.MakeSkipped => |e| return e,
|
||||
else => {
|
||||
s.result_error_msgs.append(arena, @errorName(err)) catch @panic("OOM");
|
||||
return error.MakeFailed;
|
||||
@@ -845,8 +844,7 @@ fn failWithCacheError(
|
||||
});
|
||||
},
|
||||
},
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Canceled => return error.Canceled,
|
||||
error.OutOfMemory, error.Canceled => |e| return e,
|
||||
error.InvalidFormat => return s.fail("failed to check cache: invalid manifest file format", .{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2704,7 +2704,7 @@ fn evalGeneric(run: *Run, spawn_options: process.SpawnOptions) !EvalGenericResul
|
||||
} else {
|
||||
var stdout_reader = stdout.readerStreaming(io, &.{});
|
||||
stdout_bytes = stdout_reader.interface.allocRemaining(arena, run.stdio_limit) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ReadFailed => return stdout_reader.err.?,
|
||||
error.StreamTooLong => return error.StdoutStreamTooLong,
|
||||
};
|
||||
@@ -2712,7 +2712,7 @@ fn evalGeneric(run: *Run, spawn_options: process.SpawnOptions) !EvalGenericResul
|
||||
} else if (child.stderr) |stderr| {
|
||||
var stderr_reader = stderr.readerStreaming(io, &.{});
|
||||
stderr_bytes = stderr_reader.interface.allocRemaining(arena, run.stdio_limit) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ReadFailed => return stderr_reader.err.?,
|
||||
error.StreamTooLong => return error.StderrStreamTooLong,
|
||||
};
|
||||
|
||||
@@ -622,8 +622,8 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
|
||||
defer body_buffer.deinit(gpa);
|
||||
|
||||
while (true) {
|
||||
const header = stdout.takeStruct(Header, .little) catch |e| switch (e) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
const header = stdout.takeStruct(Header, .little) catch |err| switch (err) {
|
||||
error.ReadFailed => |e| return e,
|
||||
error.EndOfStream => break,
|
||||
};
|
||||
body_buffer.clearRetainingCapacity();
|
||||
|
||||
@@ -162,9 +162,10 @@ fn sendFilePositional(w: *Writer, file_reader: *Io.File.Reader, limit: Io.Limit)
|
||||
w.err = error.Canceled;
|
||||
return error.WriteFailed;
|
||||
},
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.Unimplemented => return error.Unimplemented,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.EndOfStream,
|
||||
error.Unimplemented,
|
||||
error.ReadFailed,
|
||||
=> |e| return e,
|
||||
else => |e| {
|
||||
w.write_file_err = e;
|
||||
return error.WriteFailed;
|
||||
@@ -182,9 +183,10 @@ fn sendFileStreaming(w: *Writer, file_reader: *Io.File.Reader, limit: Io.Limit)
|
||||
w.err = error.Canceled;
|
||||
return error.WriteFailed;
|
||||
},
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.Unimplemented => return error.Unimplemented,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.EndOfStream,
|
||||
error.Unimplemented,
|
||||
error.ReadFailed,
|
||||
=> |e| return e,
|
||||
else => |e| {
|
||||
w.write_file_err = e;
|
||||
return error.WriteFailed;
|
||||
|
||||
@@ -200,8 +200,7 @@ pub fn defaultDiscard(r: *Reader, limit: Limit) Error!usize {
|
||||
var d: Writer.Discarding = .init(r.buffer);
|
||||
var n = r.stream(&d.writer, limit) catch |err| switch (err) {
|
||||
error.WriteFailed => unreachable,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.ReadFailed, error.EndOfStream => |e| return e,
|
||||
};
|
||||
// If `stream` wrote to `r.buffer` without going through the writer,
|
||||
// we need to discard as much of the buffered data as possible.
|
||||
@@ -379,7 +378,7 @@ pub fn appendRemainingAligned(
|
||||
const n = stream(r, &a.writer, remaining) catch |err| switch (err) {
|
||||
error.EndOfStream => return,
|
||||
error.WriteFailed => return error.OutOfMemory,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
remaining = remaining.subtract(n).?;
|
||||
}
|
||||
@@ -400,7 +399,7 @@ pub fn appendRemainingUnlimited(r: *Reader, gpa: Allocator, list: *ArrayList(u8)
|
||||
}
|
||||
_ = streamRemaining(r, &a.writer) catch |err| switch (err) {
|
||||
error.WriteFailed => return error.OutOfMemory,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -428,7 +427,7 @@ pub fn readVec(r: *Reader, data: [][]u8) Error!usize {
|
||||
defer data[i] = buf;
|
||||
return n + (r.vtable.readVec(r, data[i..]) catch |err| switch (err) {
|
||||
error.EndOfStream => if (n == 0) return error.EndOfStream else 0,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
});
|
||||
}
|
||||
const n = seek - r.seek;
|
||||
@@ -639,7 +638,7 @@ pub fn discardShort(r: *Reader, n: usize) ShortError!usize {
|
||||
while (true) {
|
||||
const discard_len = r.vtable.discard(r, .limited(remaining)) catch |err| switch (err) {
|
||||
error.EndOfStream => return n - remaining,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
remaining -= discard_len;
|
||||
if (remaining == 0) return n;
|
||||
@@ -687,7 +686,7 @@ pub fn readSliceShort(r: *Reader, buffer: []u8) ShortError!usize {
|
||||
data[0] = buffer[i..];
|
||||
i += readVec(r, &data) catch |err| switch (err) {
|
||||
error.EndOfStream => return i,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
if (buffer.len - i == 0) return buffer.len;
|
||||
}
|
||||
@@ -1009,7 +1008,7 @@ pub fn streamDelimiterLimit(
|
||||
var remaining = @intFromEnum(limit);
|
||||
while (remaining != 0) {
|
||||
const available = Limit.limited(remaining).slice(r.peekGreedy(1) catch |err| switch (err) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
error.EndOfStream => return @intFromEnum(limit) - remaining,
|
||||
});
|
||||
if (std.mem.findScalar(u8, available, delimiter)) |delimiter_index| {
|
||||
@@ -1080,7 +1079,7 @@ pub fn discardDelimiterLimit(r: *Reader, delimiter: u8, limit: Limit) DiscardDel
|
||||
var remaining = @intFromEnum(limit);
|
||||
while (remaining != 0) {
|
||||
const available = Limit.limited(remaining).slice(r.peekGreedy(1) catch |err| switch (err) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
error.EndOfStream => return @intFromEnum(limit) - remaining,
|
||||
});
|
||||
if (std.mem.findScalar(u8, available, delimiter)) |delimiter_index| {
|
||||
|
||||
@@ -61,7 +61,7 @@ pub const Mode = union(enum) {
|
||||
if (file.enableAnsiEscapeCodes(io)) |_| {
|
||||
return .escape_codes;
|
||||
} else |err| switch (err) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
error.NotTerminalDevice, error.Unexpected => {},
|
||||
}
|
||||
|
||||
|
||||
@@ -14589,7 +14589,7 @@ fn lookupDns(
|
||||
}
|
||||
}
|
||||
if (recv_err) |err| switch (err) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
error.Timeout => continue :send,
|
||||
else => continue,
|
||||
};
|
||||
@@ -14726,13 +14726,13 @@ fn lookupHostsReader(
|
||||
const line = reader.takeDelimiterExclusive('\n') catch |err| switch (err) {
|
||||
error.StreamTooLong => {
|
||||
// Skip lines that are too long.
|
||||
_ = reader.discardDelimiterInclusive('\n') catch |e| switch (e) {
|
||||
_ = reader.discardDelimiterInclusive('\n') catch |er| switch (er) {
|
||||
error.EndOfStream => break,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
continue;
|
||||
},
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
error.EndOfStream => break,
|
||||
};
|
||||
reader.toss(@min(1, reader.bufferedLen()));
|
||||
|
||||
@@ -4958,7 +4958,7 @@ fn randomSecure(userdata: ?*anyopaque, buffer: []u8) Io.RandomSecureError!void {
|
||||
var cancel_region: CancelRegion = .init();
|
||||
defer cancel_region.deinit();
|
||||
ev.urandomReadAll(&cancel_region, buffer) catch |err| switch (err) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => return error.EntropyUnavailable,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ fn parseNum(text: []const u8) error{ InvalidVersion, Overflow }!usize {
|
||||
|
||||
return std.fmt.parseUnsigned(usize, text, 10) catch |err| switch (err) {
|
||||
error.InvalidCharacter => return error.InvalidVersion,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.Overflow => |e| return e,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ pub fn parse(args: ParseOptions) !Query {
|
||||
} else if (abi.isAndroid()) {
|
||||
result.android_api_level = std.fmt.parseUnsigned(u32, abi_ver_text, 10) catch |err| switch (err) {
|
||||
error.InvalidCharacter => return error.InvalidVersion,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.Overflow => |e| return e,
|
||||
};
|
||||
} else {
|
||||
return error.InvalidAbiVersion;
|
||||
@@ -346,7 +346,7 @@ pub fn parseVersion(ver: []const u8) error{ InvalidVersion, Overflow }!SemanticV
|
||||
fn parseVersionComponentInner(component: []const u8) error{ InvalidVersion, Overflow }!usize {
|
||||
return std.fmt.parseUnsigned(usize, component, 10) catch |err| switch (err) {
|
||||
error.InvalidCharacter => return error.InvalidVersion,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.Overflow => |e| return e,
|
||||
};
|
||||
}
|
||||
}).parseVersionComponentInner;
|
||||
|
||||
@@ -129,8 +129,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
|
||||
}
|
||||
const n = r.stream(&writer, limit) catch |err| switch (err) {
|
||||
error.WriteFailed => unreachable,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.ReadFailed, error.EndOfStream => |e| return e,
|
||||
};
|
||||
assert(n <= @intFromEnum(limit));
|
||||
return n;
|
||||
@@ -258,7 +257,7 @@ fn streamFallible(d: *Decompress, w: *Writer, limit: std.Io.Limit) Reader.Stream
|
||||
return error.ReadFailed;
|
||||
}
|
||||
},
|
||||
error.WriteFailed => return error.WriteFailed,
|
||||
error.WriteFailed => |e| return e,
|
||||
else => |e| {
|
||||
// In the event of an error, state is unmodified so that it can be
|
||||
// better used to diagnose the failure.
|
||||
|
||||
@@ -173,8 +173,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
|
||||
}
|
||||
const n = r.stream(&writer, limit) catch |err| switch (err) {
|
||||
error.WriteFailed => unreachable,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.ReadFailed, error.EndOfStream => |e| return e,
|
||||
};
|
||||
assert(n <= @intFromEnum(limit));
|
||||
return n;
|
||||
@@ -252,8 +251,7 @@ fn stream(d: *Decompress, w: *Writer, limit: Limit) Reader.StreamError!usize {
|
||||
},
|
||||
.in_frame => |*in_frame| {
|
||||
return readInFrame(d, w, limit, in_frame) catch |err| switch (err) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.WriteFailed => return error.WriteFailed,
|
||||
error.ReadFailed, error.WriteFailed => |e| return e,
|
||||
else => |e| {
|
||||
d.err = e;
|
||||
return error.ReadFailed;
|
||||
|
||||
@@ -47,8 +47,7 @@ pub const hex = struct {
|
||||
}
|
||||
_ = decodeAny(bin, encoded, null) catch |err| {
|
||||
switch (err) {
|
||||
error.InvalidCharacter => return error.InvalidCharacter,
|
||||
error.InvalidPadding => return error.InvalidPadding,
|
||||
error.InvalidCharacter, error.InvalidPadding => |e| return e,
|
||||
else => unreachable,
|
||||
}
|
||||
};
|
||||
@@ -228,8 +227,7 @@ pub const base64 = struct {
|
||||
pub fn decode(bin: []u8, encoded: []const u8, comptime variant: Variant) error{ InvalidCharacter, InvalidPadding }![]const u8 {
|
||||
return decodeAny(bin, encoded, variant, null) catch |err| {
|
||||
switch (err) {
|
||||
error.InvalidCharacter => return error.InvalidCharacter,
|
||||
error.InvalidPadding => return error.InvalidPadding,
|
||||
error.InvalidCharacter, error.InvalidPadding => |e| return e,
|
||||
else => unreachable,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -666,7 +666,7 @@ pub const Decoder = struct {
|
||||
if (request_amt > dest.len) return error.TlsRecordOverflow;
|
||||
stream.readSlice(dest[0..request_amt]) catch |err| switch (err) {
|
||||
error.EndOfStream => return error.TlsConnectionTruncated,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
d.cap += request_amt;
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
||||
if (record_len > tls.max_ciphertext_len) return error.TlsRecordOverflow;
|
||||
const record_buffer = input.take(record_len) catch |err| switch (err) {
|
||||
error.EndOfStream => return error.TlsConnectionTruncated,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
var record_decoder: tls.Decoder = .fromTheirSlice(record_buffer);
|
||||
var ctd, const ct = content: switch (cipher_state) {
|
||||
@@ -1157,7 +1157,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
||||
return failRead(c, error.TlsConnectionTruncated);
|
||||
}
|
||||
},
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
const ct: tls.ContentType = @enumFromInt(record_header[0]);
|
||||
const legacy_version = mem.readInt(u16, record_header[1..][0..2], .big);
|
||||
@@ -1168,7 +1168,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
||||
if (record_end > input.buffered().len) {
|
||||
input.fillMore() catch |err| switch (err) {
|
||||
error.EndOfStream => return failRead(c, error.TlsConnectionTruncated),
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
if (record_end > input.buffered().len) return 0;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ pub fn parseDbiStream(self: *Pdb) !void {
|
||||
if (section_contrib_size != 0) {
|
||||
const version = reader.takeEnum(pdb.SectionContrSubstreamVersion, .little) catch |err| switch (err) {
|
||||
error.InvalidEnumTag, error.EndOfStream => return error.InvalidDebugInfo,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
_ = version;
|
||||
sect_cont_offset += @sizeOf(u32);
|
||||
|
||||
+1
-1
@@ -542,7 +542,7 @@ pub fn parseIntSizeSuffix(buf: []const u8, digit_base: u8) ParseIntError!usize {
|
||||
}
|
||||
const multiplier = math.powi(usize, magnitude_base, orders_of_magnitude) catch |err| switch (err) {
|
||||
error.Underflow => unreachable,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.Overflow => |e| return e,
|
||||
};
|
||||
const number = try std.fmt.parseInt(usize, without_suffix, digit_base);
|
||||
return math.mul(usize, number, multiplier);
|
||||
|
||||
+3
-4
@@ -400,7 +400,7 @@ pub const Reader = struct {
|
||||
0 => return error.HttpConnectionClosing,
|
||||
else => return error.HttpRequestTruncated,
|
||||
},
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
continue;
|
||||
}
|
||||
@@ -543,8 +543,7 @@ pub const Reader = struct {
|
||||
else => unreachable,
|
||||
};
|
||||
return chunkedReadEndless(reader, w, limit, chunk_len_ptr) catch |err| switch (err) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.WriteFailed => return error.WriteFailed,
|
||||
error.ReadFailed, error.WriteFailed => |e| return e,
|
||||
error.EndOfStream => {
|
||||
reader.body_err = error.HttpChunkTruncated;
|
||||
return error.ReadFailed;
|
||||
@@ -613,7 +612,7 @@ pub const Reader = struct {
|
||||
else => unreachable,
|
||||
};
|
||||
return chunkedDiscardEndless(reader, limit, chunk_len_ptr) catch |err| switch (err) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
error.EndOfStream => {
|
||||
reader.body_err = error.HttpChunkTruncated;
|
||||
return error.ReadFailed;
|
||||
|
||||
@@ -953,7 +953,7 @@ test "Server streams both reading and writing" {
|
||||
try response.flush();
|
||||
const buf = br.peekGreedy(1) catch |err| switch (err) {
|
||||
error.EndOfStream => break,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
};
|
||||
br.toss(buf.len);
|
||||
for (buf) |*b| b.* = std.ascii.toUpper(b.*);
|
||||
|
||||
@@ -1401,7 +1401,7 @@ pub fn validate(allocator: Allocator, s: []const u8) Allocator.Error!bool {
|
||||
while (true) {
|
||||
const token = scanner.next() catch |err| switch (err) {
|
||||
error.SyntaxError, error.UnexpectedEndOfInput => return false,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.BufferUnderrun => unreachable,
|
||||
};
|
||||
if (token == .end_of_document) break;
|
||||
@@ -1734,7 +1734,7 @@ pub const Reader = struct {
|
||||
|
||||
fn refillBuffer(self: *@This()) std.Io.Reader.Error!void {
|
||||
const input = self.reader.peekGreedy(1) catch |err| switch (err) {
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
error.ReadFailed => |e| return e,
|
||||
error.EndOfStream => return self.scanner.endInput(),
|
||||
};
|
||||
self.reader.toss(input.len);
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ pub fn posixGetUserInfo(io: Io, name: []const u8) !UserInfo {
|
||||
return posixGetUserInfoPasswdStream(name, &file_reader.interface) catch |err| switch (err) {
|
||||
error.ReadFailed => return file_reader.err.?,
|
||||
error.EndOfStream => return error.UserNotFound,
|
||||
error.CorruptPasswordFile => return error.CorruptPasswordFile,
|
||||
error.CorruptPasswordFile => |e| return e,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -998,8 +998,8 @@ fn rendersMultiline(r: *const Render, node: Ast.Node.Index) error{OutOfMemory}!b
|
||||
.fixups = r.fixups,
|
||||
};
|
||||
|
||||
renderExpression(&sub_r, node, .none) catch |e| return switch (e) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
renderExpression(&sub_r, node, .none) catch |err| return switch (err) {
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.WriteFailed => return true,
|
||||
};
|
||||
if (sub_ais.disabled_offset != null) return true;
|
||||
@@ -1685,7 +1685,7 @@ fn renderBuiltinCall(
|
||||
assert(tree.tokenTag(str_lit_token) == .string_literal);
|
||||
const token_bytes = tree.tokenSlice(str_lit_token);
|
||||
const imported_string = std.zig.string_literal.parseAlloc(r.gpa, token_bytes) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.InvalidLiteral => break :f,
|
||||
};
|
||||
defer r.gpa.free(imported_string);
|
||||
|
||||
@@ -199,7 +199,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
|
||||
assert(struct_decl_ref.toIndex().? == .main_struct_inst);
|
||||
break :fatal false;
|
||||
} else |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.AnalysisFail => break :fatal true, // Handled via compile_errors below.
|
||||
}
|
||||
} else fatal: {
|
||||
@@ -5681,7 +5681,7 @@ fn containerMember(
|
||||
|
||||
const prev_decl_index = wip_decls.index;
|
||||
astgen.fnDecl(gz, scope, wip_decls, member_node, body, full) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.AnalysisFail => {
|
||||
wip_decls.index = prev_decl_index;
|
||||
try addFailedDeclaration(
|
||||
@@ -5704,7 +5704,7 @@ fn containerMember(
|
||||
const full = tree.fullVarDecl(member_node).?;
|
||||
const prev_decl_index = wip_decls.index;
|
||||
astgen.globalVarDecl(gz, scope, wip_decls, member_node, full) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.AnalysisFail => {
|
||||
wip_decls.index = prev_decl_index;
|
||||
try addFailedDeclaration(
|
||||
@@ -5722,7 +5722,7 @@ fn containerMember(
|
||||
.@"comptime" => {
|
||||
const prev_decl_index = wip_decls.index;
|
||||
astgen.comptimeDecl(gz, scope, wip_decls, member_node) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.AnalysisFail => {
|
||||
wip_decls.index = prev_decl_index;
|
||||
try addFailedDeclaration(
|
||||
@@ -5742,7 +5742,7 @@ fn containerMember(
|
||||
// Since it doesn't strictly matter *what* this is, let's save ourselves the trouble
|
||||
// of duplicating the test name logic, and just assume this is an unnamed test.
|
||||
astgen.testDecl(gz, scope, wip_decls, member_node) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.AnalysisFail => {
|
||||
wip_decls.index = prev_decl_index;
|
||||
try addFailedDeclaration(
|
||||
@@ -8563,7 +8563,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
|
||||
big_int.setString(@intFromEnum(base), bytes[prefix_offset..]) catch |err| switch (err) {
|
||||
error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
|
||||
error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
|
||||
const limbs = big_int.limbs[0..big_int.len()];
|
||||
|
||||
@@ -196,7 +196,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
|
||||
const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.environ_map) catch |err| switch (err) {
|
||||
error.NotFound => return error.WindowsSdkNotFound,
|
||||
error.PathTooLong => return error.WindowsSdkNotFound,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
defer sdk.free(gpa);
|
||||
|
||||
@@ -278,7 +278,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
|
||||
// So we use the expandArg0 variant of ChildProcess to give them a helping hand.
|
||||
.expand_arg0 = .expand,
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => {
|
||||
printVerboseInvocation(argv.items, null, args.verbose, null);
|
||||
return error.UnableToSpawnCCompiler;
|
||||
@@ -596,7 +596,7 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
|
||||
// So we use the expandArg0 variant of ChildProcess to give them a helping hand.
|
||||
.expand_arg0 = .expand,
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => return error.UnableToSpawnCCompiler,
|
||||
};
|
||||
defer {
|
||||
|
||||
@@ -278,7 +278,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
|
||||
}
|
||||
const comptime_token = p.nextToken();
|
||||
const opt_block = p.parseBlock() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => blk: {
|
||||
p.findNextContainerMember();
|
||||
break :blk null;
|
||||
@@ -301,7 +301,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
|
||||
const identifier = p.tok_i;
|
||||
defer last_field = identifier;
|
||||
const container_field = p.expectContainerField() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => {
|
||||
p.findNextContainerMember();
|
||||
continue;
|
||||
@@ -398,7 +398,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
|
||||
},
|
||||
else => {
|
||||
const c_container = p.parseCStyleContainer() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => false,
|
||||
};
|
||||
if (c_container) continue;
|
||||
@@ -406,7 +406,7 @@ fn parseContainerMembers(p: *Parse) Allocator.Error!Members {
|
||||
const identifier = p.tok_i;
|
||||
defer last_field = identifier;
|
||||
const container_field = p.expectContainerField() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => {
|
||||
p.findNextContainerMember();
|
||||
continue;
|
||||
@@ -589,7 +589,7 @@ fn expectTestDeclRecoverable(p: *Parse) error{OutOfMemory}!?Node.Index {
|
||||
if (p.expectTestDecl()) |node| {
|
||||
return node;
|
||||
} else |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => {
|
||||
p.findNextContainerMember();
|
||||
return null;
|
||||
@@ -668,7 +668,7 @@ fn expectTopLevelDecl(p: *Parse) !?Node.Index {
|
||||
|
||||
fn expectTopLevelDeclRecoverable(p: *Parse) error{OutOfMemory}!?Node.Index {
|
||||
return p.expectTopLevelDecl() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => {
|
||||
p.findNextContainerMember();
|
||||
return null;
|
||||
@@ -1145,7 +1145,7 @@ fn expectVarDeclExprStatement(p: *Parse, comptime_token: ?TokenIndex) !Node.Inde
|
||||
fn expectStatementRecoverable(p: *Parse) Error!?Node.Index {
|
||||
while (true) {
|
||||
return p.expectStatement(true) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ParseError => {
|
||||
p.findNextStmt(); // Try to skip to the next statement.
|
||||
switch (p.tokenTag(p.tok_i)) {
|
||||
|
||||
+13
-13
@@ -47,7 +47,7 @@ pub fn find(
|
||||
error.InstallationNotFound => null,
|
||||
error.PathTooLong => null,
|
||||
error.VersionTooLong => null,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
errdefer if (windows10sdk) |*w| w.free(gpa);
|
||||
|
||||
@@ -55,13 +55,13 @@ pub fn find(
|
||||
error.InstallationNotFound => null,
|
||||
error.PathTooLong => null,
|
||||
error.VersionTooLong => null,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
errdefer if (windows81sdk) |*w| w.free(gpa);
|
||||
|
||||
const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, ®istry, arch, environ_map) catch |err| switch (err) {
|
||||
error.MsvcLibDirNotFound => null,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
errdefer gpa.free(msvc_lib_dir);
|
||||
|
||||
@@ -498,7 +498,7 @@ pub const Installation = struct {
|
||||
error.StringNotFound,
|
||||
=> return error.InstallationNotFound,
|
||||
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
defer gpa.free(path_w_maybe_with_trailing_slash);
|
||||
|
||||
@@ -572,7 +572,7 @@ pub const Installation = struct {
|
||||
error.StringNotFound,
|
||||
=> return error.InstallationNotFound,
|
||||
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
defer gpa.free(path_w_maybe_with_trailing_slash);
|
||||
|
||||
@@ -593,7 +593,7 @@ pub const Installation = struct {
|
||||
error.StringNotFound,
|
||||
=> return error.InstallationNotFound,
|
||||
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
defer gpa.free(version_without_0);
|
||||
|
||||
@@ -664,7 +664,7 @@ const MsvcLibDir = struct {
|
||||
error.StringNotFound,
|
||||
=> return error.PathNotFound,
|
||||
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
defer gpa.free(packages_path);
|
||||
|
||||
@@ -708,7 +708,7 @@ const MsvcLibDir = struct {
|
||||
error.StringNotFound,
|
||||
=> return error.PathNotFound,
|
||||
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
defer gpa.free(dll_path);
|
||||
|
||||
@@ -1042,7 +1042,7 @@ const MsvcLibDir = struct {
|
||||
const config_key = root_key.open(config_path) catch continue;
|
||||
|
||||
const source_directories_value = config_key.getString(gpa, .{ .name = L("Source Directories") }, .wtf8) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => continue,
|
||||
};
|
||||
|
||||
@@ -1118,7 +1118,7 @@ const MsvcLibDir = struct {
|
||||
defer vs7_key.close();
|
||||
try_vs7_key: {
|
||||
const path_maybe_with_trailing_slash = vs7_key.getString(gpa, .{ .name = L("14.0") }, .wtf8) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => break :try_vs7_key,
|
||||
};
|
||||
|
||||
@@ -1178,11 +1178,11 @@ const MsvcLibDir = struct {
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, MsvcLibDirNotFound }![]const u8 {
|
||||
const full_path = MsvcLibDir.findViaCOM(gpa, io, registry, arch, environ_map) catch |err1| switch (err1) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, environ_map) catch |err2| switch (err2) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, registry, arch, environ_map) catch |err3| switch (err3) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.PathNotFound => return error.MsvcLibDirNotFound,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -668,7 +668,7 @@ fn numberLiteral(zg: *ZonGen, num_node: Ast.Node.Index, src_node: Ast.Node.Index
|
||||
big_int.setString(@intFromEnum(base), num_without_prefix) catch |err| switch (err) {
|
||||
error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
|
||||
error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
switch (sign) {
|
||||
.positive => {},
|
||||
|
||||
+5
-5
@@ -143,7 +143,7 @@ pub const EndRecord = extern struct {
|
||||
const read_buf: []u8 = buf[buf.len - new_loaded_len ..][0..read_len];
|
||||
fr.interface.readSliceAll(read_buf) catch |err| switch (err) {
|
||||
error.ReadFailed => return fr.err.?,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.EndOfStream => |e| return e,
|
||||
};
|
||||
loaded_len = new_loaded_len;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ pub const Iterator = struct {
|
||||
try input.seekTo(stream_len - locator_end_offset);
|
||||
const locator = input.interface.takeStruct(EndLocator64, .little) catch |err| switch (err) {
|
||||
error.ReadFailed => return input.err.?,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.EndOfStream => |e| return e,
|
||||
};
|
||||
if (!std.mem.eql(u8, &locator.signature, &end_locator64_sig))
|
||||
return error.ZipBadLocatorSig;
|
||||
@@ -323,7 +323,7 @@ pub const Iterator = struct {
|
||||
|
||||
const record64 = input.interface.takeStruct(EndRecord64, .little) catch |err| switch (err) {
|
||||
error.ReadFailed => return input.err.?,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.EndOfStream => |e| return e,
|
||||
};
|
||||
|
||||
if (!std.mem.eql(u8, &record64.signature, &end_record64_sig))
|
||||
@@ -379,7 +379,7 @@ pub const Iterator = struct {
|
||||
try input.seekTo(header_zip_offset);
|
||||
const header = input.interface.takeStruct(CentralDirectoryFileHeader, .little) catch |err| switch (err) {
|
||||
error.ReadFailed => return input.err.?,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.EndOfStream => |e| return e,
|
||||
};
|
||||
if (!std.mem.eql(u8, &header.signature, ¢ral_file_header_sig))
|
||||
return error.ZipBadCdOffset;
|
||||
@@ -410,7 +410,7 @@ pub const Iterator = struct {
|
||||
try input.seekTo(header_zip_offset + @sizeOf(CentralDirectoryFileHeader) + header.filename_len);
|
||||
input.interface.readSliceAll(extra) catch |err| switch (err) {
|
||||
error.ReadFailed => return input.err.?,
|
||||
error.EndOfStream => return error.EndOfStream,
|
||||
error.EndOfStream => |e| return e,
|
||||
};
|
||||
|
||||
var extra_offset: usize = 0;
|
||||
|
||||
+4
-5
@@ -2184,7 +2184,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
|
||||
.global = options.config,
|
||||
.parent = options.root_mod,
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
// None of these are possible because the configuration matches the root module
|
||||
// which already passed these checks.
|
||||
error.ValgrindUnsupportedOnTarget => unreachable,
|
||||
@@ -2948,8 +2948,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
|
||||
);
|
||||
},
|
||||
},
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Canceled => return error.Canceled,
|
||||
error.OutOfMemory, error.Canceled => |e| return e,
|
||||
error.InvalidFormat => return comp.setMiscFailure(
|
||||
.check_whole_cache,
|
||||
"failed to check cache: invalid manifest file format",
|
||||
@@ -3368,7 +3367,7 @@ fn flush(comp: *Compilation, arena: Allocator, tid: Zcu.PerThread.Id) (Io.Cancel
|
||||
.lto = comp.config.lto,
|
||||
}) catch |err| switch (err) {
|
||||
error.LinkFailure => {}, // Already reported.
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7236,7 +7235,7 @@ pub fn dumpArgv(io: Io, argv: []const []const u8) Io.Cancelable!void {
|
||||
const w = &stderr.file_writer.interface;
|
||||
return dumpArgvWriter(w, argv) catch |err| switch (err) {
|
||||
error.WriteFailed => switch (stderr.file_writer.err.?) {
|
||||
error.Canceled => return error.Canceled,
|
||||
error.Canceled => |e| return e,
|
||||
else => return,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1422,8 +1422,7 @@ fn unpackResource(
|
||||
return try unpackTarball(f, tmp_directory.handle, &decompress.reader);
|
||||
},
|
||||
.git_pack => return unpackGitPack(f, tmp_directory.handle, &resource.git) catch |err| switch (err) {
|
||||
error.FetchFailed => return error.FetchFailed,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.FetchFailed, error.OutOfMemory => |e| return e,
|
||||
else => |e| return f.fail(f.location_tok, try eb.printString("unable to unpack git files: {t}", .{e})),
|
||||
},
|
||||
.zip => return unzip(f, tmp_directory.handle, resource.reader()) catch |err| switch (err) {
|
||||
|
||||
+1
-1
@@ -22339,7 +22339,7 @@ fn checkAtomicPtrOperand(
|
||||
try sema.ensureLayoutResolved(elem_ty, elem_ty_src, .ptr_access);
|
||||
var diag: Zcu.AtomicPtrAlignmentDiagnostics = .{};
|
||||
const alignment = zcu.atomicPtrAlignment(elem_ty, &diag) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.FloatTooBig => return sema.fail(
|
||||
block,
|
||||
elem_ty_src,
|
||||
|
||||
+1
-1
@@ -1611,7 +1611,7 @@ pub fn hasRepeatedByteRepr(val: Value, zcu: *const Zcu) !?u8 {
|
||||
defer zcu.gpa.free(byte_buffer);
|
||||
|
||||
writeToMemory(val, zcu, byte_buffer) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ReinterpretDeclRef => return null,
|
||||
// TODO: The writeToMemory function was originally created for the purpose
|
||||
// of comptime pointer casting. However, it is now additionally being used
|
||||
|
||||
+1
-1
@@ -3922,7 +3922,7 @@ pub fn handleUpdateExports(
|
||||
) Allocator.Error!void {
|
||||
const gpa = zcu.gpa;
|
||||
result catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.AnalysisFail => {
|
||||
const export_idx = export_indices[0];
|
||||
const new_export = export_idx.ptr(zcu);
|
||||
|
||||
@@ -4582,7 +4582,7 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e
|
||||
defer verify.deinit();
|
||||
|
||||
verify.verify() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => return zcu.codegenFail(nav, "invalid liveness: {t}", .{err}),
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -760,7 +760,7 @@ fn lowerUavRef(
|
||||
.offset = w.end,
|
||||
.addend = @intCast(offset),
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| std.debug.panic("TODO rework lowerUav. internal error: {t}", .{e}),
|
||||
};
|
||||
const endian = target.cpu.arch.endian();
|
||||
@@ -903,7 +903,7 @@ pub fn genNavRef(
|
||||
}
|
||||
} else if (lf.cast(.elf2)) |elf| {
|
||||
return .{ .sym_index = @intFromEnum(elf.navSymbol(zcu, nav_index) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return .{ .fail = try ErrorMsg.create(
|
||||
zcu.gpa,
|
||||
src_loc,
|
||||
|
||||
@@ -11363,7 +11363,7 @@ fn writeToMemory(isel: *Select, constant: Constant, buffer: []u8) error{OutOfMem
|
||||
const ip = &zcu.intern_pool;
|
||||
if (try isel.writeKeyToMemory(ip.indexToKey(constant.toIntern()), buffer)) return true;
|
||||
constant.writeToMemory(zcu, buffer) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.ReinterpretDeclRef, error.Unimplemented, error.IllDefinedMemoryLayout => return false,
|
||||
};
|
||||
return true;
|
||||
|
||||
@@ -812,7 +812,7 @@ pub fn generate(
|
||||
|
||||
const fn_info = zcu.typeToFunc(fn_type).?;
|
||||
var call_info = function.resolveCallingConventionValues(fn_info, &.{}) catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
else => |e| return e,
|
||||
};
|
||||
|
||||
@@ -841,7 +841,7 @@ pub fn generate(
|
||||
}));
|
||||
|
||||
function.gen() catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
|
||||
else => |e| return e,
|
||||
};
|
||||
@@ -893,7 +893,7 @@ pub fn generateLazy(
|
||||
defer function.mir_instructions.deinit(gpa);
|
||||
|
||||
function.genLazy(lazy_sym) catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
|
||||
else => |e| return e,
|
||||
};
|
||||
|
||||
@@ -308,7 +308,7 @@ pub fn generate(
|
||||
defer function.exitlude_jump_relocs.deinit(gpa);
|
||||
|
||||
var call_info = function.resolveCallingConventionValues(func_ty, .callee) catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
else => |e| return e,
|
||||
};
|
||||
defer call_info.deinit(&function);
|
||||
@@ -319,7 +319,7 @@ pub fn generate(
|
||||
function.max_end_stack = call_info.stack_byte_count;
|
||||
|
||||
function.gen() catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
|
||||
else => |e| return e,
|
||||
};
|
||||
|
||||
@@ -938,7 +938,7 @@ pub fn generate(
|
||||
|
||||
const fn_info = zcu.typeToFunc(fn_type).?;
|
||||
var call_info = function.resolveCallingConventionValues(fn_info, &.{}, .args_frame) catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
else => |e| return e,
|
||||
};
|
||||
defer call_info.deinit(&function);
|
||||
@@ -983,7 +983,7 @@ pub fn generate(
|
||||
}
|
||||
|
||||
function.gen(&file.zir.?, func_zir.inst, func.comptime_args, call_info.air_arg_count) catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
|
||||
else => |e| return e,
|
||||
};
|
||||
@@ -1071,7 +1071,7 @@ pub fn generateLazy(
|
||||
}
|
||||
|
||||
function.genLazy(lazy_sym) catch |err| switch (err) {
|
||||
error.CodegenFail => return error.CodegenFail,
|
||||
error.CodegenFail => |e| return e,
|
||||
error.OutOfRegisters => return function.fail("ran out of registers (Zig compiler bug)", .{}),
|
||||
else => |e| return e,
|
||||
};
|
||||
|
||||
+2
-2
@@ -285,7 +285,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
|
||||
error.AlreadyReported => return error.AlreadyReported,
|
||||
error.AlreadyReported => |e| return e,
|
||||
else => |e| {
|
||||
comp.lockAndSetMiscFailure(misc_task, "unable to build libc++: compilation failed: {t}", .{e});
|
||||
return error.AlreadyReported;
|
||||
@@ -478,7 +478,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
|
||||
error.AlreadyReported => return error.AlreadyReported,
|
||||
error.AlreadyReported => |e| return e,
|
||||
else => |e| {
|
||||
comp.lockAndSetMiscFailure(
|
||||
.libcxxabi,
|
||||
|
||||
@@ -313,7 +313,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
|
||||
error.AlreadyReported => return error.AlreadyReported,
|
||||
error.AlreadyReported => |e| return e,
|
||||
else => |e| {
|
||||
comp.lockAndSetMiscFailure(misc_task, "unable to build {t}: compilation failed: {s}", .{ misc_task, @errorName(e) });
|
||||
return error.AlreadyReported;
|
||||
|
||||
@@ -171,7 +171,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
comp.updateSubCompilation(sub_compilation, misc_task, prog_node) catch |err| switch (err) {
|
||||
error.AlreadyReported => return error.AlreadyReported,
|
||||
error.AlreadyReported => |e| return e,
|
||||
else => |e| {
|
||||
comp.lockAndSetMiscFailure(misc_task, "unable to build {t}: compilation failed: {s}", .{ misc_task, @errorName(e) });
|
||||
return error.AlreadyReported;
|
||||
|
||||
+4
-4
@@ -1716,7 +1716,7 @@ pub fn updateErrorData(coff: *Coff, pt: Zcu.PerThread) !void {
|
||||
.kind = .const_data,
|
||||
.index = @intCast(coff.lazy.getPtr(.const_data).map.getIndex(.anyerror_type) orelse return),
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.CodegenFail => return error.LinkFailure,
|
||||
else => |e| return coff.base.comp.link_diags.fail("updateErrorData failed {t}", .{e}),
|
||||
};
|
||||
@@ -1765,7 +1765,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
|
||||
pending_uav.value.alignment,
|
||||
pending_uav.value.src_loc,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return comp.link_diags.fail(
|
||||
"linker failed to lower constant: {t}",
|
||||
.{e},
|
||||
@@ -1783,7 +1783,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
|
||||
);
|
||||
defer sub_prog_node.end();
|
||||
coff.flushGlobal(pt, gmi) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return comp.link_diags.fail(
|
||||
"linker failed to lower constant: {t}",
|
||||
.{e},
|
||||
@@ -1810,7 +1810,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
|
||||
);
|
||||
defer sub_prog_node.end();
|
||||
coff.flushLazy(pt, lmr) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return comp.link_diags.fail(
|
||||
"linker failed to lower lazy {s}: {t}",
|
||||
.{ kind, e },
|
||||
|
||||
+2
-3
@@ -757,8 +757,7 @@ pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std
|
||||
defer sub_prog_node.end();
|
||||
|
||||
return flushInner(self, arena, tid) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("ELF flush failed: {t}", .{e}),
|
||||
};
|
||||
}
|
||||
@@ -1717,7 +1716,7 @@ pub fn updateContainerType(
|
||||
@panic("Attempted to compile for object format that was disabled by build configuration");
|
||||
}
|
||||
return self.zigObjectPtr().?.updateContainerType(pt, ty, success) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1042,7 +1042,7 @@ pub fn lowerUav(
|
||||
osec,
|
||||
src_loc,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
|
||||
gpa,
|
||||
src_loc,
|
||||
@@ -1659,8 +1659,7 @@ pub fn updateNav(
|
||||
var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index);
|
||||
defer debug_wip_nav.deinit();
|
||||
dwarf.finishWipNav(pt, nav_index, &debug_wip_nav) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory, error.Overflow => |e| return e,
|
||||
else => |e| return elf_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
@@ -1703,8 +1702,7 @@ pub fn updateNav(
|
||||
try self.updateNavCode(elf_file, pt, nav_index, sym_index, shndx, code, elf.STT_OBJECT);
|
||||
|
||||
if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNav(pt, nav_index, wip_nav) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory, error.Overflow => |e| return e,
|
||||
else => |e| return elf_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
|
||||
};
|
||||
} 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
|
||||
const comp = dwarf.bin_file.comp;
|
||||
const diags = &comp.link_diags;
|
||||
dwarf.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow, error.OutOfMemory => |e| return e,
|
||||
else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
|
||||
+5
-5
@@ -2399,7 +2399,7 @@ fn loadDsoExact(elf: *Elf, name: []const u8) !void {
|
||||
pub fn prelink(elf: *Elf, prog_node: std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
elf.prelinkInner() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return elf.base.comp.link_diags.fail("prelink failed: {t}", .{e}),
|
||||
};
|
||||
}
|
||||
@@ -2934,7 +2934,7 @@ pub fn lowerUav(
|
||||
|
||||
try elf.pending_uavs.ensureUnusedCapacity(gpa, 1);
|
||||
const umi = elf.uavMapIndex(uav_val) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
|
||||
gpa,
|
||||
src_loc,
|
||||
@@ -3057,7 +3057,7 @@ pub fn updateErrorData(elf: *Elf, pt: Zcu.PerThread) !void {
|
||||
.kind = .const_data,
|
||||
.index = @intCast(elf.lazy.getPtr(.const_data).map.getIndex(.anyerror_type) orelse return),
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
error.CodegenFail => return error.LinkFailure,
|
||||
else => |e| return elf.base.comp.link_diags.fail("updateErrorData failed: {t}", .{e}),
|
||||
};
|
||||
@@ -3091,7 +3091,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) !bool {
|
||||
pending_uav.value.alignment,
|
||||
pending_uav.value.src_loc,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return comp.link_diags.fail(
|
||||
"linker failed to lower constant: {t}",
|
||||
.{e},
|
||||
@@ -3118,7 +3118,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) !bool {
|
||||
);
|
||||
defer sub_prog_node.end();
|
||||
elf.flushLazy(pt, lmr) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return comp.link_diags.fail(
|
||||
"linker failed to lower lazy {s}: {t}",
|
||||
.{ kind, e },
|
||||
|
||||
+7
-11
@@ -504,7 +504,7 @@ pub fn flush(
|
||||
try self.resolveSymbols();
|
||||
try self.convertTentativeDefsAndResolveSpecialSymbols();
|
||||
self.dedupLiterals() catch |err| switch (err) {
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to deduplicate literals: {s}", .{@errorName(e)}),
|
||||
};
|
||||
|
||||
@@ -542,7 +542,7 @@ pub fn flush(
|
||||
|
||||
try self.initSegments();
|
||||
self.allocateSections() catch |err| switch (err) {
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to allocate sections: {s}", .{@errorName(e)}),
|
||||
};
|
||||
self.allocateSegments();
|
||||
@@ -567,8 +567,7 @@ pub fn flush(
|
||||
try self.writeSectionsToFile();
|
||||
try self.allocateLinkeditSegment();
|
||||
self.writeLinkeditSectionsToFile() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to write linkedit sections to file: {t}", .{e}),
|
||||
};
|
||||
|
||||
@@ -595,25 +594,22 @@ pub fn flush(
|
||||
|
||||
const ncmds, const sizeofcmds, const uuid_cmd_offset = self.writeLoadCommands() catch |err| switch (err) {
|
||||
error.WriteFailed => unreachable,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
};
|
||||
try self.writeHeader(ncmds, sizeofcmds);
|
||||
self.writeUuid(uuid_cmd_offset, self.requiresCodeSig()) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to calculate and write uuid: {s}", .{@errorName(e)}),
|
||||
};
|
||||
if (self.getDebugSymbols()) |dsym| dsym.flush(self) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return diags.fail("failed to get debug symbols: {s}", .{@errorName(e)}),
|
||||
};
|
||||
|
||||
// Code signing always comes last.
|
||||
if (codesig) |*csig| {
|
||||
self.writeCodeSignature(csig) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to write code signature: {s}", .{@errorName(e)}),
|
||||
};
|
||||
const emit = self.base.emit;
|
||||
|
||||
@@ -571,8 +571,7 @@ pub fn flush(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) link.F
|
||||
.{ .kind = .code, .ty = .anyerror_type },
|
||||
metadata.text_symbol_index,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to update lazy symbol: {s}", .{@errorName(e)}),
|
||||
};
|
||||
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
|
||||
.{ .kind = .const_data, .ty = .anyerror_type },
|
||||
metadata.const_symbol_index,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to update lazy symbol: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
@@ -595,7 +593,7 @@ pub fn flush(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) link.F
|
||||
const pt: Zcu.PerThread = .activate(macho_file.base.comp.zcu.?, tid);
|
||||
defer pt.deactivate();
|
||||
dwarf.flush(pt) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return diags.fail("failed to flush dwarf module: {s}", .{@errorName(e)}),
|
||||
};
|
||||
|
||||
@@ -735,7 +733,7 @@ pub fn lowerUav(
|
||||
macho_file.zig_const_sect_index.?,
|
||||
src_loc,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| return .{ .fail = try Zcu.ErrorMsg.create(
|
||||
gpa,
|
||||
src_loc,
|
||||
@@ -889,8 +887,7 @@ pub fn updateNav(
|
||||
var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index);
|
||||
defer debug_wip_nav.deinit();
|
||||
dwarf.finishWipNav(pt, nav_index, &debug_wip_nav) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory, error.Overflow => |e| return e,
|
||||
else => |e| return macho_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
@@ -928,8 +925,7 @@ pub fn updateNav(
|
||||
try self.updateNavCode(macho_file, pt, nav_index, sym_index, sect_index, code);
|
||||
|
||||
if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNav(pt, nav_index, wip_nav) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory, error.Overflow => |e| return e,
|
||||
else => |e| return macho_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
|
||||
};
|
||||
} 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
|
||||
const comp = dwarf.bin_file.comp;
|
||||
const diags = &comp.link_diags;
|
||||
dwarf.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow, error.OutOfMemory => |e| return e,
|
||||
else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ pub fn flushObject(macho_file: *MachO, comp: *Compilation, module_obj_path: ?Pat
|
||||
|
||||
try macho_file.resolveSymbols();
|
||||
macho_file.dedupLiterals() catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to update ar size: {s}", .{@errorName(e)}),
|
||||
};
|
||||
markExports(macho_file);
|
||||
@@ -55,7 +54,7 @@ pub fn flushObject(macho_file: *MachO, comp: *Compilation, module_obj_path: ?Pat
|
||||
|
||||
try createSegment(macho_file);
|
||||
allocateSections(macho_file) catch |err| switch (err) {
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to allocate sections: {s}", .{@errorName(e)}),
|
||||
};
|
||||
allocateSegment(macho_file);
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ pub fn flush(
|
||||
errdefer arena.free(module);
|
||||
|
||||
const linked_module = linkModule(arena, module, sub_prog_node) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |other| return diags.fail("error while linking: {s}", .{@errorName(other)}),
|
||||
};
|
||||
|
||||
|
||||
+2
-4
@@ -3345,8 +3345,7 @@ pub fn updateLineNumber(wasm: *Wasm, pt: Zcu.PerThread, ti_id: InternPool.Tracke
|
||||
const diags = &comp.link_diags;
|
||||
if (wasm.dwarf) |*dw| {
|
||||
dw.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
|
||||
error.Overflow => return error.Overflow,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.Overflow, error.OutOfMemory => |e| return e,
|
||||
else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
@@ -3873,8 +3872,7 @@ pub fn flush(
|
||||
try wasm.flush_buffer.data_imports.reinit(gpa, wasm.data_imports.keys(), wasm.data_imports.values());
|
||||
|
||||
return wasm.flush_buffer.finish(wasm) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.LinkFailure => return error.LinkFailure,
|
||||
error.OutOfMemory, error.LinkFailure => |e| return e,
|
||||
else => |e| return diags.fail("failed to flush wasm: {s}", .{@errorName(e)}),
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -4205,7 +4205,7 @@ fn createModule(
|
||||
error.StackCheckUnsupportedByTarget => fatal("unable to create module '{s}': the selected target does not support stack checking", .{name}),
|
||||
error.StackProtectorUnsupportedByTarget => fatal("unable to create module '{s}': the selected target does not support stack protection", .{name}),
|
||||
error.StackProtectorUnavailableWithoutLibC => fatal("unable to create module '{s}': enabling stack protection requires libc", .{name}),
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
};
|
||||
cli_mod.resolved = mod;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn cmdTargets(
|
||||
allocator,
|
||||
.limited(glibc.abilists_max_size),
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => fatal("unable to read " ++ glibc.abilists_path ++ ": {t}", .{err}),
|
||||
};
|
||||
defer allocator.free(abilists_contents);
|
||||
|
||||
Reference in New Issue
Block a user