authorgravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-06-21 00:40:21+09:00
committergravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-06-21 00:40:21+09:00
log71db8df5480f4d849480267574cd5491066e3868
tree1842ce3024d7254022c66d5a00c5e53488fcbeb8
parent457c0f0a7e424177e7d8d00f4429da292b7c67d5

std: update stdlib to match updated allocator create signature; ref #733


11 files changed, 100 insertions(+), 122 deletions(-)

src-self-hosted/module.zig+11-13
......@@ -110,11 +110,12 @@ pub const Module = struct {
110110 parent: ?*CliPkg,
111111
112112 pub fn init(allocator: *mem.Allocator, name: []const u8, path: []const u8, parent: ?*CliPkg) !*CliPkg {
113 var pkg = try allocator.create(CliPkg);
114 pkg.name = name;
115 pkg.path = path;
116 pkg.children = ArrayList(*CliPkg).init(allocator);
117 pkg.parent = parent;
113 var pkg = try allocator.create(CliPkg{
114 .name = name,
115 .path = path,
116 .children = ArrayList(*CliPkg).init(allocator),
117 .parent = parent
118 });
118119 return pkg;
119120 }
120121
......@@ -139,10 +140,7 @@ pub const Module = struct {
139140 const builder = c.LLVMCreateBuilderInContext(context) orelse return error.OutOfMemory;
140141 errdefer c.LLVMDisposeBuilder(builder);
141142
142 const module_ptr = try allocator.create(Module);
143 errdefer allocator.destroy(module_ptr);
144
145 module_ptr.* = Module{
143 const module_ptr = try allocator.create(Module{
146144 .allocator = allocator,
147145 .name = name_buffer,
148146 .root_src_path = root_src_path,
......@@ -196,7 +194,8 @@ pub const Module = struct {
196194 .test_filters = [][]const u8{},
197195 .test_name_prefix = null,
198196 .emit_file_type = Emit.Binary,
199 };
197 });
198 errdefer allocator.destroy(module_ptr);
200199 return module_ptr;
201200 }
202201
......@@ -279,13 +278,12 @@ pub const Module = struct {
279278 }
280279 }
281280
282 const link_lib = try self.allocator.create(LinkLib);
283 link_lib.* = LinkLib{
281 const link_lib = try self.allocator.create(LinkLib{
284282 .name = name,
285283 .path = null,
286284 .provided_explicitly = provided_explicitly,
287285 .symbols = ArrayList([]u8).init(self.allocator),
288 };
286 });
289287 try self.link_libs_list.append(link_lib);
290288 if (is_libc) {
291289 self.libc_link_lib = link_lib;
std/atomic/queue.zig+4-2
......@@ -114,8 +114,10 @@ fn startPuts(ctx: *Context) u8 {
114114 while (put_count != 0) : (put_count -= 1) {
115115 std.os.time.sleep(0, 1); // let the os scheduler be our fuzz
116116 const x = @bitCast(i32, r.random.scalar(u32));
117 const node = ctx.allocator.create(Queue(i32).Node) catch unreachable;
118 node.data = x;
117 const node = ctx.allocator.create(Queue(i32).Node{
118 .next = null,
119 .data = x
120 }) catch unreachable;
119121 ctx.queue.put(node);
120122 _ = @atomicRmw(isize, &ctx.put_sum, builtin.AtomicRmwOp.Add, x, AtomicOrder.SeqCst);
121123 }
std/atomic/stack.zig+4-2
......@@ -117,8 +117,10 @@ fn startPuts(ctx: *Context) u8 {
117117 while (put_count != 0) : (put_count -= 1) {
118118 std.os.time.sleep(0, 1); // let the os scheduler be our fuzz
119119 const x = @bitCast(i32, r.random.scalar(u32));
120 const node = ctx.allocator.create(Stack(i32).Node) catch unreachable;
121 node.data = x;
120 const node = ctx.allocator.create(Stack(i32).Node{
121 .next = null,
122 .data = x
123 }) catch unreachable;
122124 ctx.stack.push(node);
123125 _ = @atomicRmw(isize, &ctx.put_sum, builtin.AtomicRmwOp.Add, x, AtomicOrder.SeqCst);
124126 }
std/build.zig+20-35
......@@ -158,8 +158,7 @@ pub const Builder = struct {
158158 }
159159
160160 pub fn addTest(self: *Builder, root_src: []const u8) *TestStep {
161 const test_step = self.allocator.create(TestStep) catch unreachable;
162 test_step.* = TestStep.init(self, root_src);
161 const test_step = self.allocator.create(TestStep.init(self, root_src)) catch unreachable;
163162 return test_step;
164163 }
165164
......@@ -191,21 +190,18 @@ pub const Builder = struct {
191190 }
192191
193192 pub fn addWriteFile(self: *Builder, file_path: []const u8, data: []const u8) *WriteFileStep {
194 const write_file_step = self.allocator.create(WriteFileStep) catch unreachable;
195 write_file_step.* = WriteFileStep.init(self, file_path, data);
193 const write_file_step = self.allocator.create(WriteFileStep.init(self, file_path, data)) catch unreachable;
196194 return write_file_step;
197195 }
198196
199197 pub fn addLog(self: *Builder, comptime format: []const u8, args: ...) *LogStep {
200198 const data = self.fmt(format, args);
201 const log_step = self.allocator.create(LogStep) catch unreachable;
202 log_step.* = LogStep.init(self, data);
199 const log_step = self.allocator.create(LogStep.init(self, data)) catch unreachable;
203200 return log_step;
204201 }
205202
206203 pub fn addRemoveDirTree(self: *Builder, dir_path: []const u8) *RemoveDirStep {
207 const remove_dir_step = self.allocator.create(RemoveDirStep) catch unreachable;
208 remove_dir_step.* = RemoveDirStep.init(self, dir_path);
204 const remove_dir_step = self.allocator.create(RemoveDirStep.init(self, dir_path)) catch unreachable;
209205 return remove_dir_step;
210206 }
211207
......@@ -404,11 +400,10 @@ pub const Builder = struct {
404400 }
405401
406402 pub fn step(self: *Builder, name: []const u8, description: []const u8) *Step {
407 const step_info = self.allocator.create(TopLevelStep) catch unreachable;
408 step_info.* = TopLevelStep{
403 const step_info = self.allocator.create(TopLevelStep{
409404 .step = Step.initNoOp(name, self.allocator),
410405 .description = description,
411 };
406 }) catch unreachable;
412407 self.top_level_steps.append(step_info) catch unreachable;
413408 return &step_info.step;
414409 }
......@@ -598,8 +593,7 @@ pub const Builder = struct {
598593 const full_dest_path = os.path.resolve(self.allocator, self.prefix, dest_rel_path) catch unreachable;
599594 self.pushInstalledFile(full_dest_path);
600595
601 const install_step = self.allocator.create(InstallFileStep) catch unreachable;
602 install_step.* = InstallFileStep.init(self, src_path, full_dest_path);
596 const install_step = self.allocator.create(InstallFileStep.init(self, src_path, full_dest_path)) catch unreachable;
603597 return install_step;
604598 }
605599
......@@ -837,51 +831,43 @@ pub const LibExeObjStep = struct {
837831 };
838832
839833 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?[]const u8, ver: *const Version) *LibExeObjStep {
840 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
841 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, false, ver);
834 const self = builder.allocator.create(initExtraArgs(builder, name, root_src, Kind.Lib, false, ver)) catch unreachable;
842835 return self;
843836 }
844837
845838 pub fn createCSharedLibrary(builder: *Builder, name: []const u8, version: *const Version) *LibExeObjStep {
846 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
847 self.* = initC(builder, name, Kind.Lib, version, false);
839 const self = builder.allocator.create(initC(builder, name, Kind.Lib, version, false)) catch unreachable;
848840 return self;
849841 }
850842
851843 pub fn createStaticLibrary(builder: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
852 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
853 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, true, builder.version(0, 0, 0));
844 const self = builder.allocator.create(initExtraArgs(builder, name, root_src, Kind.Lib, true, builder.version(0, 0, 0))) catch unreachable;
854845 return self;
855846 }
856847
857848 pub fn createCStaticLibrary(builder: *Builder, name: []const u8) *LibExeObjStep {
858 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
859 self.* = initC(builder, name, Kind.Lib, builder.version(0, 0, 0), true);
849 const self = builder.allocator.create(initC(builder, name, Kind.Lib, builder.version(0, 0, 0), true)) catch unreachable;
860850 return self;
861851 }
862852
863853 pub fn createObject(builder: *Builder, name: []const u8, root_src: []const u8) *LibExeObjStep {
864 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
865 self.* = initExtraArgs(builder, name, root_src, Kind.Obj, false, builder.version(0, 0, 0));
854 const self = builder.allocator.create(initExtraArgs(builder, name, root_src, Kind.Obj, false, builder.version(0, 0, 0))) catch unreachable;
866855 return self;
867856 }
868857
869858 pub fn createCObject(builder: *Builder, name: []const u8, src: []const u8) *LibExeObjStep {
870 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
871 self.* = initC(builder, name, Kind.Obj, builder.version(0, 0, 0), false);
859 const self = builder.allocator.create(initC(builder, name, Kind.Obj, builder.version(0, 0, 0), false)) catch unreachable;
872860 self.object_src = src;
873861 return self;
874862 }
875863
876864 pub fn createExecutable(builder: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
877 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
878 self.* = initExtraArgs(builder, name, root_src, Kind.Exe, false, builder.version(0, 0, 0));
865 const self = builder.allocator.create(initExtraArgs(builder, name, root_src, Kind.Exe, false, builder.version(0, 0, 0))) catch unreachable;
879866 return self;
880867 }
881868
882869 pub fn createCExecutable(builder: *Builder, name: []const u8) *LibExeObjStep {
883 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
884 self.* = initC(builder, name, Kind.Exe, builder.version(0, 0, 0), false);
870 const self = builder.allocator.create(initC(builder, name, Kind.Exe, builder.version(0, 0, 0), false)) catch unreachable;
885871 return self;
886872 }
887873
......@@ -1748,14 +1734,14 @@ pub const CommandStep = struct {
17481734
17491735 /// ::argv is copied.
17501736 pub fn create(builder: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) *CommandStep {
1751 const self = builder.allocator.create(CommandStep) catch unreachable;
1752 self.* = CommandStep{
1737 const self = builder.allocator.create(CommandStep{
17531738 .builder = builder,
17541739 .step = Step.init(argv[0], builder.allocator, make),
17551740 .argv = builder.allocator.alloc([]u8, argv.len) catch unreachable,
17561741 .cwd = cwd,
17571742 .env_map = env_map,
1758 };
1743 }) catch unreachable;
1744
17591745 mem.copy([]const u8, self.argv, argv);
17601746 self.step.name = self.argv[0];
17611747 return self;
......@@ -1778,18 +1764,17 @@ const InstallArtifactStep = struct {
17781764 const Self = this;
17791765
17801766 pub fn create(builder: *Builder, artifact: *LibExeObjStep) *Self {
1781 const self = builder.allocator.create(Self) catch unreachable;
17821767 const dest_dir = switch (artifact.kind) {
17831768 LibExeObjStep.Kind.Obj => unreachable,
17841769 LibExeObjStep.Kind.Exe => builder.exe_dir,
17851770 LibExeObjStep.Kind.Lib => builder.lib_dir,
17861771 };
1787 self.* = Self{
1772 const self = builder.allocator.create(Self{
17881773 .builder = builder,
17891774 .step = Step.init(builder.fmt("install {}", artifact.step.name), builder.allocator, make),
17901775 .artifact = artifact,
17911776 .dest_file = os.path.join(builder.allocator, dest_dir, artifact.out_filename) catch unreachable,
1792 };
1777 }) catch unreachable;
17931778 self.step.dependOn(&artifact.step);
17941779 builder.pushInstalledFile(self.dest_file);
17951780 if (self.artifact.kind == LibExeObjStep.Kind.Lib and !self.artifact.static) {
std/debug/index.zig+7-10
......@@ -249,9 +249,7 @@ fn printSourceAtAddress(debug_info: *ElfStackTrace, out_stream: var, address: us
249249pub fn openSelfDebugInfo(allocator: *mem.Allocator) !*ElfStackTrace {
250250 switch (builtin.object_format) {
251251 builtin.ObjectFormat.elf => {
252 const st = try allocator.create(ElfStackTrace);
253 errdefer allocator.destroy(st);
254 st.* = ElfStackTrace{
252 const st = try allocator.create(ElfStackTrace{
255253 .self_exe_file = undefined,
256254 .elf = undefined,
257255 .debug_info = undefined,
......@@ -261,7 +259,8 @@ pub fn openSelfDebugInfo(allocator: *mem.Allocator) !*ElfStackTrace {
261259 .debug_ranges = null,
262260 .abbrev_table_list = ArrayList(AbbrevTableHeader).init(allocator),
263261 .compile_unit_list = ArrayList(CompileUnit).init(allocator),
264 };
262 });
263 errdefer allocator.destroy(st);
265264 st.self_exe_file = try os.openSelfExe();
266265 errdefer st.self_exe_file.close();
267266
......@@ -280,11 +279,10 @@ pub fn openSelfDebugInfo(allocator: *mem.Allocator) !*ElfStackTrace {
280279 var exe_file = try os.openSelfExe();
281280 defer exe_file.close();
282281
283 const st = try allocator.create(ElfStackTrace);
282 const st = try allocator.create(ElfStackTrace{
283 .symbol_table = try macho.loadSymbols(allocator, &io.FileInStream.init(&exe_file))
284 });
284285 errdefer allocator.destroy(st);
285
286 st.* = ElfStackTrace{ .symbol_table = try macho.loadSymbols(allocator, &io.FileInStream.init(&exe_file)) };
287
288286 return st;
289287 },
290288 builtin.ObjectFormat.coff => {
......@@ -974,8 +972,7 @@ fn scanAllCompileUnits(st: *ElfStackTrace) !void {
974972
975973 try st.self_exe_file.seekTo(compile_unit_pos);
976974
977 const compile_unit_die = try st.allocator().create(Die);
978 compile_unit_die.* = try parseDie(st, abbrev_table, is_64);
975 const compile_unit_die = try st.allocator().create( try parseDie(st, abbrev_table, is_64) );
979976
980977 if (compile_unit_die.tag_id != DW.TAG_compile_unit) return error.InvalidDebugInfo;
981978
std/heap.zig+1-1
......@@ -407,7 +407,7 @@ fn testAllocator(allocator: *mem.Allocator) !void {
407407 var slice = try allocator.alloc(*i32, 100);
408408
409409 for (slice) |*item, i| {
410 item.* = try allocator.create(i32);
410 item.* = try allocator.create(i32(0));
411411 item.*.* = @intCast(i32, i);
412412 }
413413
std/io.zig+3-5
......@@ -414,14 +414,12 @@ pub const BufferedAtomicFile = struct {
414414
415415 pub fn create(allocator: *mem.Allocator, dest_path: []const u8) !*BufferedAtomicFile {
416416 // TODO with well defined copy elision we don't need this allocation
417 var self = try allocator.create(BufferedAtomicFile);
418 errdefer allocator.destroy(self);
419
420 self.* = BufferedAtomicFile{
417 var self = try allocator.create(BufferedAtomicFile{
421418 .atomic_file = undefined,
422419 .file_stream = undefined,
423420 .buffered_stream = undefined,
424 };
421 });
422 errdefer allocator.destroy(self);
425423
426424 self.atomic_file = try os.AtomicFile.init(allocator, dest_path, os.default_file_mode);
427425 errdefer self.atomic_file.deinit();
std/linked_list.zig+5-1
......@@ -193,7 +193,11 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
193193 /// A pointer to the new node.
194194 pub fn allocateNode(list: *Self, allocator: *Allocator) !*Node {
195195 comptime assert(!isIntrusive());
196 return allocator.create(Node);
196 return allocator.create(Node{
197 .prev = null,
198 .next = null,
199 .data = undefined
200 });
197201 }
198202
199203 /// Deallocate a node.
std/os/child_process.zig+3-6
......@@ -85,10 +85,7 @@ pub const ChildProcess = struct {
8585 /// First argument in argv is the executable.
8686 /// On success must call deinit.
8787 pub fn init(argv: []const []const u8, allocator: *mem.Allocator) !*ChildProcess {
88 const child = try allocator.create(ChildProcess);
89 errdefer allocator.destroy(child);
90
91 child.* = ChildProcess{
88 const child = try allocator.create(ChildProcess{
9289 .allocator = allocator,
9390 .argv = argv,
9491 .pid = undefined,
......@@ -109,8 +106,8 @@ pub const ChildProcess = struct {
109106 .stdin_behavior = StdIo.Inherit,
110107 .stdout_behavior = StdIo.Inherit,
111108 .stderr_behavior = StdIo.Inherit,
112 };
113
109 });
110 errdefer allocator.destroy(child);
114111 return child;
115112 }
116113
std/os/index.zig+5-2
......@@ -2582,8 +2582,11 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!*Thread
25822582 const bytes_ptr = windows.HeapAlloc(heap_handle, 0, byte_count) orelse return SpawnThreadError.OutOfMemory;
25832583 errdefer assert(windows.HeapFree(heap_handle, 0, bytes_ptr) != 0);
25842584 const bytes = @ptrCast([*]u8, bytes_ptr)[0..byte_count];
2585 const outer_context = std.heap.FixedBufferAllocator.init(bytes).allocator.create(WinThread.OuterContext) catch unreachable;
2586 outer_context.inner = context;
2585 const outer_context = std.heap.FixedBufferAllocator.init(bytes).allocator.create(WinThread.OuterContext{
2586 .thread = undefined,
2587 .inner = context
2588 }) catch unreachable;
2589
25872590 outer_context.thread.data.heap_handle = heap_handle;
25882591 outer_context.thread.data.alloc_start = bytes_ptr;
25892592
test/tests.zig+37-45
......@@ -48,13 +48,12 @@ const test_targets = []TestTarget{
4848const max_stdout_size = 1 * 1024 * 1024; // 1 MB
4949
5050pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
51 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
52 cases.* = CompareOutputContext{
51 const cases = b.allocator.create(CompareOutputContext{
5352 .b = b,
5453 .step = b.step("test-compare-output", "Run the compare output tests"),
5554 .test_index = 0,
5655 .test_filter = test_filter,
57 };
56 }) catch unreachable;
5857
5958 compare_output.addCases(cases);
6059
......@@ -62,13 +61,12 @@ pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8) *build
6261}
6362
6463pub fn addRuntimeSafetyTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
65 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
66 cases.* = CompareOutputContext{
64 const cases = b.allocator.create(CompareOutputContext{
6765 .b = b,
6866 .step = b.step("test-runtime-safety", "Run the runtime safety tests"),
6967 .test_index = 0,
7068 .test_filter = test_filter,
71 };
69 }) catch unreachable;
7270
7371 runtime_safety.addCases(cases);
7472
......@@ -76,13 +74,12 @@ pub fn addRuntimeSafetyTests(b: *build.Builder, test_filter: ?[]const u8) *build
7674}
7775
7876pub fn addCompileErrorTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
79 const cases = b.allocator.create(CompileErrorContext) catch unreachable;
80 cases.* = CompileErrorContext{
77 const cases = b.allocator.create(CompileErrorContext{
8178 .b = b,
8279 .step = b.step("test-compile-errors", "Run the compile error tests"),
8380 .test_index = 0,
8481 .test_filter = test_filter,
85 };
82 }) catch unreachable;
8683
8784 compile_errors.addCases(cases);
8885
......@@ -90,13 +87,12 @@ pub fn addCompileErrorTests(b: *build.Builder, test_filter: ?[]const u8) *build.
9087}
9188
9289pub fn addBuildExampleTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
93 const cases = b.allocator.create(BuildExamplesContext) catch unreachable;
94 cases.* = BuildExamplesContext{
90 const cases = b.allocator.create(BuildExamplesContext{
9591 .b = b,
9692 .step = b.step("test-build-examples", "Build the examples"),
9793 .test_index = 0,
9894 .test_filter = test_filter,
99 };
95 }) catch unreachable;
10096
10197 build_examples.addCases(cases);
10298
......@@ -104,13 +100,12 @@ pub fn addBuildExampleTests(b: *build.Builder, test_filter: ?[]const u8) *build.
104100}
105101
106102pub fn addAssembleAndLinkTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
107 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
108 cases.* = CompareOutputContext{
103 const cases = b.allocator.create(CompareOutputContext{
109104 .b = b,
110105 .step = b.step("test-asm-link", "Run the assemble and link tests"),
111106 .test_index = 0,
112107 .test_filter = test_filter,
113 };
108 }) catch unreachable;
114109
115110 assemble_and_link.addCases(cases);
116111
......@@ -118,13 +113,12 @@ pub fn addAssembleAndLinkTests(b: *build.Builder, test_filter: ?[]const u8) *bui
118113}
119114
120115pub fn addTranslateCTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
121 const cases = b.allocator.create(TranslateCContext) catch unreachable;
122 cases.* = TranslateCContext{
116 const cases = b.allocator.create(TranslateCContext{
123117 .b = b,
124118 .step = b.step("test-translate-c", "Run the C transation tests"),
125119 .test_index = 0,
126120 .test_filter = test_filter,
127 };
121 }) catch unreachable;
128122
129123 translate_c.addCases(cases);
130124
......@@ -132,13 +126,12 @@ pub fn addTranslateCTests(b: *build.Builder, test_filter: ?[]const u8) *build.St
132126}
133127
134128pub fn addGenHTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
135 const cases = b.allocator.create(GenHContext) catch unreachable;
136 cases.* = GenHContext{
129 const cases = b.allocator.create(GenHContext{
137130 .b = b,
138131 .step = b.step("test-gen-h", "Run the C header file generation tests"),
139132 .test_index = 0,
140133 .test_filter = test_filter,
141 };
134 }) catch unreachable;
142135
143136 gen_h.addCases(cases);
144137
......@@ -240,8 +233,7 @@ pub const CompareOutputContext = struct {
240233
241234 pub fn create(context: *CompareOutputContext, exe_path: []const u8, name: []const u8, expected_output: []const u8, cli_args: []const []const u8) *RunCompareOutputStep {
242235 const allocator = context.b.allocator;
243 const ptr = allocator.create(RunCompareOutputStep) catch unreachable;
244 ptr.* = RunCompareOutputStep{
236 const ptr = allocator.create(RunCompareOutputStep{
245237 .context = context,
246238 .exe_path = exe_path,
247239 .name = name,
......@@ -249,7 +241,7 @@ pub const CompareOutputContext = struct {
249241 .test_index = context.test_index,
250242 .step = build.Step.init("RunCompareOutput", allocator, make),
251243 .cli_args = cli_args,
252 };
244 }) catch unreachable;
253245 context.test_index += 1;
254246 return ptr;
255247 }
......@@ -328,14 +320,14 @@ pub const CompareOutputContext = struct {
328320
329321 pub fn create(context: *CompareOutputContext, exe_path: []const u8, name: []const u8) *RuntimeSafetyRunStep {
330322 const allocator = context.b.allocator;
331 const ptr = allocator.create(RuntimeSafetyRunStep) catch unreachable;
332 ptr.* = RuntimeSafetyRunStep{
323 const ptr = allocator.create(RuntimeSafetyRunStep{
333324 .context = context,
334325 .exe_path = exe_path,
335326 .name = name,
336327 .test_index = context.test_index,
337328 .step = build.Step.init("RuntimeSafetyRun", allocator, make),
338 };
329 }) catch unreachable;
330
339331 context.test_index += 1;
340332 return ptr;
341333 }
......@@ -543,15 +535,15 @@ pub const CompileErrorContext = struct {
543535
544536 pub fn create(context: *CompileErrorContext, name: []const u8, case: *const TestCase, build_mode: Mode) *CompileCmpOutputStep {
545537 const allocator = context.b.allocator;
546 const ptr = allocator.create(CompileCmpOutputStep) catch unreachable;
547 ptr.* = CompileCmpOutputStep{
538 const ptr = allocator.create(CompileCmpOutputStep{
548539 .step = build.Step.init("CompileCmpOutput", allocator, make),
549540 .context = context,
550541 .name = name,
551542 .test_index = context.test_index,
552543 .case = case,
553544 .build_mode = build_mode,
554 };
545 }) catch unreachable;
546
555547 context.test_index += 1;
556548 return ptr;
557549 }
......@@ -662,14 +654,14 @@ pub const CompileErrorContext = struct {
662654 }
663655
664656 pub fn create(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
665 const tc = self.b.allocator.create(TestCase) catch unreachable;
666 tc.* = TestCase{
657 const tc = self.b.allocator.create(TestCase{
667658 .name = name,
668659 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
669660 .expected_errors = ArrayList([]const u8).init(self.b.allocator),
670661 .link_libc = false,
671662 .is_exe = false,
672 };
663 }) catch unreachable;
664
673665 tc.addSourceFile(".tmp_source.zig", source);
674666 comptime var arg_i = 0;
675667 inline while (arg_i < expected_lines.len) : (arg_i += 1) {
......@@ -829,14 +821,14 @@ pub const TranslateCContext = struct {
829821
830822 pub fn create(context: *TranslateCContext, name: []const u8, case: *const TestCase) *TranslateCCmpOutputStep {
831823 const allocator = context.b.allocator;
832 const ptr = allocator.create(TranslateCCmpOutputStep) catch unreachable;
833 ptr.* = TranslateCCmpOutputStep{
824 const ptr = allocator.create(TranslateCCmpOutputStep{
834825 .step = build.Step.init("ParseCCmpOutput", allocator, make),
835826 .context = context,
836827 .name = name,
837828 .test_index = context.test_index,
838829 .case = case,
839 };
830 }) catch unreachable;
831
840832 context.test_index += 1;
841833 return ptr;
842834 }
......@@ -936,13 +928,13 @@ pub const TranslateCContext = struct {
936928 }
937929
938930 pub fn create(self: *TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
939 const tc = self.b.allocator.create(TestCase) catch unreachable;
940 tc.* = TestCase{
931 const tc = self.b.allocator.create(TestCase{
941932 .name = name,
942933 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
943934 .expected_lines = ArrayList([]const u8).init(self.b.allocator),
944935 .allow_warnings = allow_warnings,
945 };
936 }) catch unreachable;
937
946938 tc.addSourceFile(filename, source);
947939 comptime var arg_i = 0;
948940 inline while (arg_i < expected_lines.len) : (arg_i += 1) {
......@@ -1023,15 +1015,15 @@ pub const GenHContext = struct {
10231015
10241016 pub fn create(context: *GenHContext, h_path: []const u8, name: []const u8, case: *const TestCase) *GenHCmpOutputStep {
10251017 const allocator = context.b.allocator;
1026 const ptr = allocator.create(GenHCmpOutputStep) catch unreachable;
1027 ptr.* = GenHCmpOutputStep{
1018 const ptr = allocator.create(GenHCmpOutputStep{
10281019 .step = build.Step.init("ParseCCmpOutput", allocator, make),
10291020 .context = context,
10301021 .h_path = h_path,
10311022 .name = name,
10321023 .test_index = context.test_index,
10331024 .case = case,
1034 };
1025 }) catch unreachable;
1026
10351027 context.test_index += 1;
10361028 return ptr;
10371029 }
......@@ -1070,12 +1062,12 @@ pub const GenHContext = struct {
10701062 }
10711063
10721064 pub fn create(self: *GenHContext, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
1073 const tc = self.b.allocator.create(TestCase) catch unreachable;
1074 tc.* = TestCase{
1065 const tc = self.b.allocator.create(TestCase{
10751066 .name = name,
10761067 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
10771068 .expected_lines = ArrayList([]const u8).init(self.b.allocator),
1078 };
1069 }) catch unreachable;
1070
10791071 tc.addSourceFile(filename, source);
10801072 comptime var arg_i = 0;
10811073 inline while (arg_i < expected_lines.len) : (arg_i += 1) {