Commit b403ca0aab

snoire <snoire@qq.com>
2023-10-20 14:31:32
std.Build: use create() instead of init() for Step.RemoveDir
1 parent 809e7aa
Changed files (2)
lib
std
lib/std/Build/Step/RemoveDir.zig
@@ -8,8 +8,9 @@ pub const base_id = .remove_dir;
 step: Step,
 dir_path: []const u8,
 
-pub fn init(owner: *std.Build, dir_path: []const u8) RemoveDir {
-    return RemoveDir{
+pub fn create(owner: *std.Build, dir_path: []const u8) *RemoveDir {
+    const self = owner.allocator.create(RemoveDir) catch @panic("OOM");
+    self.* = .{
         .step = Step.init(.{
             .id = .remove_dir,
             .name = owner.fmt("RemoveDir {s}", .{dir_path}),
@@ -18,6 +19,7 @@ pub fn init(owner: *std.Build, dir_path: []const u8) RemoveDir {
         }),
         .dir_path = owner.dupePath(dir_path),
     };
+    return self;
 }
 
 fn make(step: *Step, prog_node: *std.Progress.Node) !void {
lib/std/Build.zig
@@ -971,9 +971,7 @@ pub fn addWriteFiles(b: *Build) *Step.WriteFile {
 }
 
 pub fn addRemoveDirTree(self: *Build, dir_path: []const u8) *Step.RemoveDir {
-    const remove_dir_step = self.allocator.create(Step.RemoveDir) catch @panic("OOM");
-    remove_dir_step.* = Step.RemoveDir.init(self, dir_path);
-    return remove_dir_step;
+    return Step.RemoveDir.create(self, dir_path);
 }
 
 pub fn addFmt(b: *Build, options: Step.Fmt.Options) *Step.Fmt {