aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/CheckObjectStep.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-01-31 14:02:32 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-01-31 15:09:35 -0700
commit90e48d4b3469fb4f8dd2f3b52e05453029d45fdc (patch)
treec213ee58f8a39ce6275456f5d37a59de4a58cf68 /lib/std/Build/CheckObjectStep.zig
parent13a96165405af33fa6ef43a3ce2c1d8aea846287 (diff)
downloadzig-90e48d4b3469fb4f8dd2f3b52e05453029d45fdc.tar.gz
zig-90e48d4b3469fb4f8dd2f3b52e05453029d45fdc.zip
std.Build: avoid use of catch unreachable
Usage of `catch unreachable` in build scripts is completely harmless because build scripts are always run in Debug mode, however, it sets a poor example for beginners to learn from.
Diffstat (limited to 'lib/std/Build/CheckObjectStep.zig')
-rw-r--r--lib/std/Build/CheckObjectStep.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/Build/CheckObjectStep.zig b/lib/std/Build/CheckObjectStep.zig
index bfa5338927..5cb096581f 100644
--- a/lib/std/Build/CheckObjectStep.zig
+++ b/lib/std/Build/CheckObjectStep.zig
@@ -24,7 +24,7 @@ obj_format: std.Target.ObjectFormat,
pub fn create(builder: *std.Build, source: std.Build.FileSource, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
const gpa = builder.allocator;
- const self = gpa.create(CheckObjectStep) catch unreachable;
+ const self = gpa.create(CheckObjectStep) catch @panic("OOM");
self.* = .{
.builder = builder,
.step = Step.init(.check_file, "CheckObject", gpa, make),
@@ -228,14 +228,14 @@ const Check = struct {
self.actions.append(.{
.tag = .match,
.phrase = self.builder.dupe(phrase),
- }) catch unreachable;
+ }) catch @panic("OOM");
}
fn notPresent(self: *Check, phrase: []const u8) void {
self.actions.append(.{
.tag = .not_present,
.phrase = self.builder.dupe(phrase),
- }) catch unreachable;
+ }) catch @panic("OOM");
}
fn computeCmp(self: *Check, phrase: []const u8, expected: ComputeCompareExpected) void {
@@ -243,7 +243,7 @@ const Check = struct {
.tag = .compute_cmp,
.phrase = self.builder.dupe(phrase),
.expected = expected,
- }) catch unreachable;
+ }) catch @panic("OOM");
}
};
@@ -251,7 +251,7 @@ const Check = struct {
pub fn checkStart(self: *CheckObjectStep, phrase: []const u8) void {
var new_check = Check.create(self.builder);
new_check.match(phrase);
- self.checks.append(new_check) catch unreachable;
+ self.checks.append(new_check) catch @panic("OOM");
}
/// Adds another searched phrase to the latest created Check with `CheckObjectStep.checkStart(...)`.
@@ -293,7 +293,7 @@ pub fn checkComputeCompare(
) void {
var new_check = Check.create(self.builder);
new_check.computeCmp(program, expected);
- self.checks.append(new_check) catch unreachable;
+ self.checks.append(new_check) catch @panic("OOM");
}
fn make(step: *Step) !void {