Skip to content

Commit 460e8d6

Browse files
committed
Fix breaking zig change to @fieldParentPtr parameters
See ziglang/zig#19470
1 parent a2ea86e commit 460e8d6

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

build.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ const ZiglingStep = struct {
247247
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
248248
// NOTE: Using exit code 2 will prevent the Zig compiler to print the message:
249249
// "error: the following build command failed with exit code 1:..."
250-
const self = @fieldParentPtr(ZiglingStep, "step", step);
250+
const self: *ZiglingStep = @alignCast(@fieldParentPtr("step", step));
251251

252252
if (self.exercise.skip) {
253253
print("Skipping {s}\n\n", .{self.exercise.main_file});
@@ -495,8 +495,7 @@ const PrintStep = struct {
495495
}
496496

497497
fn make(step: *Step, _: *std.Progress.Node) !void {
498-
const self = @fieldParentPtr(PrintStep, "step", step);
499-
498+
const self: *PrintStep = @alignCast(@fieldParentPtr("step", step));
500499
print("{s}", .{self.message});
501500
}
502501
};

test/tests.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const CheckNamedStep = struct {
152152

153153
fn make(step: *Step, _: *std.Progress.Node) !void {
154154
const b = step.owner;
155-
const self = @fieldParentPtr(CheckNamedStep, "step", step);
155+
const self: *CheckNamedStep = @alignCast(@fieldParentPtr("step", step));
156156
const ex = self.exercise;
157157

158158
const stderr_file = try fs.cwd().openFile(
@@ -204,7 +204,7 @@ const CheckStep = struct {
204204

205205
fn make(step: *Step, _: *std.Progress.Node) !void {
206206
const b = step.owner;
207-
const self = @fieldParentPtr(CheckStep, "step", step);
207+
const self: *CheckStep = @alignCast(@fieldParentPtr("step", step));
208208
const exercises = self.exercises;
209209

210210
const stderr_file = try fs.cwd().openFile(
@@ -327,7 +327,7 @@ const FailStep = struct {
327327

328328
fn make(step: *Step, _: *std.Progress.Node) !void {
329329
const b = step.owner;
330-
const self = @fieldParentPtr(FailStep, "step", step);
330+
const self: *FailStep = @alignCast(@fieldParentPtr("step", step));
331331

332332
try step.result_error_msgs.append(b.allocator, self.error_msg);
333333
return error.MakeFailed;
@@ -370,7 +370,7 @@ const HealStep = struct {
370370

371371
fn make(step: *Step, _: *std.Progress.Node) !void {
372372
const b = step.owner;
373-
const self = @fieldParentPtr(HealStep, "step", step);
373+
const self: *HealStep = @alignCast(@fieldParentPtr("step", step));
374374

375375
return heal(b.allocator, self.exercises, self.work_path);
376376
}

0 commit comments

Comments
 (0)