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.
This commit is contained in:
Andrew Kelley
2023-01-31 14:02:32 -07:00
parent 13a9616540
commit 90e48d4b34
13 changed files with 169 additions and 161 deletions

View File

@@ -28,7 +28,7 @@ pub fn init(builder: *std.Build) WriteFileStep {
}
pub fn add(self: *WriteFileStep, basename: []const u8, bytes: []const u8) void {
const node = self.builder.allocator.create(std.TailQueue(File).Node) catch unreachable;
const node = self.builder.allocator.create(std.TailQueue(File).Node) catch @panic("unhandled error");
node.* = .{
.data = .{
.source = std.Build.GeneratedFile{ .step = &self.step },
@@ -106,10 +106,10 @@ fn make(step: *Step) !void {
});
return err;
};
node.data.source.path = fs.path.join(
node.data.source.path = try fs.path.join(
self.builder.allocator,
&[_][]const u8{ self.output_dir, node.data.basename },
) catch unreachable;
);
}
}
}