From 3c165eabcd33c86a274a2185eb0436fd848c8b91 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Tue, 21 Mar 2023 17:28:52 +0100 Subject: [PATCH] remove boxed null boilerplate --- tests/language_features/comptime_interpreter.zig | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/language_features/comptime_interpreter.zig b/tests/language_features/comptime_interpreter.zig index fb4c5cd..38bdfb8 100644 --- a/tests/language_features/comptime_interpreter.zig +++ b/tests/language_features/comptime_interpreter.zig @@ -296,14 +296,7 @@ const Context = struct { document_store: *zls.DocumentStore, interpreter: *ComptimeInterpreter, - // this is very annoying and ugly - boxed_null: *const ?ZigVersionWrapper, - pub fn init(source: []const u8) !Context { - var boxed_null = try allocator.create(?ZigVersionWrapper); - errdefer allocator.destroy(boxed_null); - boxed_null.* = null; - var config = try allocator.create(zls.Config); errdefer allocator.destroy(config); @@ -317,7 +310,7 @@ const Context = struct { document_store.* = .{ .allocator = allocator, .config = config, - .runtime_zig_version = boxed_null, + .runtime_zig_version = &@as(?ZigVersionWrapper, null), }; errdefer document_store.deinit(); @@ -345,8 +338,6 @@ const Context = struct { .config = config, .document_store = document_store, .interpreter = interpreter, - - .boxed_null = boxed_null, }; } @@ -357,7 +348,6 @@ const Context = struct { allocator.destroy(self.config); allocator.destroy(self.document_store); allocator.destroy(self.interpreter); - allocator.destroy(self.boxed_null); } pub fn call(self: *Context, func_node: Ast.Node.Index, arguments: []const KV) !KV {