Fixed build on latest zig nightly

This commit is contained in:
Alexandros Naskos 2020-07-12 22:12:09 +03:00
parent e1bce76c63
commit 6eee43af2f
8 changed files with 41 additions and 42 deletions

View File

@ -102,7 +102,7 @@ pub fn getFunctionSnippet(allocator: *std.mem.Allocator, tree: *ast.Tree, func:
switch (param.param_type) { switch (param.param_type) {
.var_args => try buffer.appendSlice("..."), .var_args => try buffer.appendSlice("..."),
.var_type => try buffer.appendSlice("var"), .any_type => try buffer.appendSlice("anytype"),
.type_expr => |type_expr| { .type_expr => |type_expr| {
var curr_tok = type_expr.firstToken(); var curr_tok = type_expr.firstToken();
var end_tok = type_expr.lastToken(); var end_tok = type_expr.lastToken();
@ -156,7 +156,7 @@ pub fn isTypeFunction(tree: *ast.Tree, func: *ast.Node.FnProto) bool {
pub fn isGenericFunction(tree: *ast.Tree, func: *ast.Node.FnProto) bool { pub fn isGenericFunction(tree: *ast.Tree, func: *ast.Node.FnProto) bool {
for (func.paramsConst()) |param| { for (func.paramsConst()) |param| {
if (param.param_type == .var_type or param.comptime_token != null) { if (param.param_type == .any_type or param.comptime_token != null) {
return true; return true;
} }
} }
@ -1351,7 +1351,7 @@ pub fn documentPositionContext(arena: *std.heap.ArenaAllocator, document: types.
fn addOutlineNodes(allocator: *std.mem.Allocator, tree: *ast.Tree, child: *ast.Node, context: *GetDocumentSymbolsContext) anyerror!void { fn addOutlineNodes(allocator: *std.mem.Allocator, tree: *ast.Tree, child: *ast.Node, context: *GetDocumentSymbolsContext) anyerror!void {
switch (child.id) { switch (child.id) {
.StringLiteral, .IntegerLiteral, .BuiltinCall, .Call, .Identifier, .InfixOp, .PrefixOp, .SuffixOp, .ControlFlowExpression, .ArrayInitializerDot, .SwitchElse, .SwitchCase, .For, .EnumLiteral, .PointerIndexPayload, .StructInitializerDot, .PointerPayload, .While, .Switch, .Else, .BoolLiteral, .NullLiteral, .Defer, .StructInitializer, .FieldInitializer, .If, .MultilineStringLiteral, .UndefinedLiteral, .VarType, .Block, .ErrorSetDecl => return, .StringLiteral, .IntegerLiteral, .BuiltinCall, .Call, .Identifier, .InfixOp, .PrefixOp, .SuffixOp, .ControlFlowExpression, .ArrayInitializerDot, .SwitchElse, .SwitchCase, .For, .EnumLiteral, .PointerIndexPayload, .StructInitializerDot, .PointerPayload, .While, .Switch, .Else, .BoolLiteral, .NullLiteral, .Defer, .StructInitializer, .FieldInitializer, .If, .MultilineStringLiteral, .UndefinedLiteral, .AnyType, .Block, .ErrorSetDecl => return,
.ContainerDecl => { .ContainerDecl => {
const decl = child.cast(ast.Node.ContainerDecl).?; const decl = child.cast(ast.Node.ContainerDecl).?;
@ -1600,8 +1600,8 @@ fn iterateSymbolsContainerInternal(
arena: *std.heap.ArenaAllocator, arena: *std.heap.ArenaAllocator,
container_handle: NodeWithHandle, container_handle: NodeWithHandle,
orig_handle: *DocumentStore.Handle, orig_handle: *DocumentStore.Handle,
comptime callback: var, comptime callback: anytype,
context: var, context: anytype,
instance_access: bool, instance_access: bool,
use_trail: *std.ArrayList(*ast.Node.Use), use_trail: *std.ArrayList(*ast.Node.Use),
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
@ -1651,8 +1651,8 @@ pub fn iterateSymbolsContainer(
arena: *std.heap.ArenaAllocator, arena: *std.heap.ArenaAllocator,
container_handle: NodeWithHandle, container_handle: NodeWithHandle,
orig_handle: *DocumentStore.Handle, orig_handle: *DocumentStore.Handle,
comptime callback: var, comptime callback: anytype,
context: var, context: anytype,
instance_access: bool, instance_access: bool,
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
var use_trail = std.ArrayList(*ast.Node.Use).init(&arena.allocator); var use_trail = std.ArrayList(*ast.Node.Use).init(&arena.allocator);
@ -1662,8 +1662,8 @@ pub fn iterateSymbolsContainer(
pub fn iterateLabels( pub fn iterateLabels(
handle: *DocumentStore.Handle, handle: *DocumentStore.Handle,
source_index: usize, source_index: usize,
comptime callback: var, comptime callback: anytype,
context: var, context: anytype,
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
for (handle.document_scope.scopes) |scope| { for (handle.document_scope.scopes) |scope| {
if (source_index >= scope.range.start and source_index < scope.range.end) { if (source_index >= scope.range.start and source_index < scope.range.end) {
@ -1685,8 +1685,8 @@ fn iterateSymbolsGlobalInternal(
arena: *std.heap.ArenaAllocator, arena: *std.heap.ArenaAllocator,
handle: *DocumentStore.Handle, handle: *DocumentStore.Handle,
source_index: usize, source_index: usize,
comptime callback: var, comptime callback: anytype,
context: var, context: anytype,
use_trail: *std.ArrayList(*ast.Node.Use), use_trail: *std.ArrayList(*ast.Node.Use),
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
for (handle.document_scope.scopes) |scope| { for (handle.document_scope.scopes) |scope| {
@ -1720,8 +1720,8 @@ pub fn iterateSymbolsGlobal(
arena: *std.heap.ArenaAllocator, arena: *std.heap.ArenaAllocator,
handle: *DocumentStore.Handle, handle: *DocumentStore.Handle,
source_index: usize, source_index: usize,
comptime callback: var, comptime callback: anytype,
context: var, context: anytype,
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
var use_trail = std.ArrayList(*ast.Node.Use).init(&arena.allocator); var use_trail = std.ArrayList(*ast.Node.Use).init(&arena.allocator);
return try iterateSymbolsGlobalInternal(store, arena, handle, source_index, callback, context, &use_trail); return try iterateSymbolsGlobalInternal(store, arena, handle, source_index, callback, context, &use_trail);

View File

@ -41,7 +41,7 @@ pub const AllocationInfo = struct {
self: AllocationInfo, self: AllocationInfo,
comptime fmt: []const u8, comptime fmt: []const u8,
options: std.fmt.FormatOptions, options: std.fmt.FormatOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
@setEvalBranchQuota(2000); @setEvalBranchQuota(2000);
@ -174,8 +174,7 @@ pub fn printRemainingStackTraces(self: DebugAllocator) void {
std.debug.print( std.debug.print(
\\{} allocations - stack traces follow \\{} allocations - stack traces follow
\\------------------------------------ \\------------------------------------
, , .{self.allocation_strack_addresses.count()});
.{self.allocation_strack_addresses.count()});
var it = self.allocation_strack_addresses.iterator(); var it = self.allocation_strack_addresses.iterator();
var idx: usize = 1; var idx: usize = 1;
while (it.next()) |entry| : (idx += 1) { while (it.next()) |entry| : (idx += 1) {

View File

@ -12,7 +12,7 @@ const RequestHeader = struct {
} }
}; };
pub fn readRequestHeader(allocator: *mem.Allocator, instream: var) !RequestHeader { pub fn readRequestHeader(allocator: *mem.Allocator, instream: anytype) !RequestHeader {
var r = RequestHeader{ var r = RequestHeader{
.content_length = undefined, .content_length = undefined,
.content_type = null, .content_type = null,
@ -26,8 +26,8 @@ pub fn readRequestHeader(allocator: *mem.Allocator, instream: var) !RequestHeade
if (header.len == 0 or header[header.len - 1] != '\r') return error.MissingCarriageReturn; if (header.len == 0 or header[header.len - 1] != '\r') return error.MissingCarriageReturn;
if (header.len == 1) break; if (header.len == 1) break;
const header_name = header[0..mem.indexOf(u8, header, ": ") orelse return error.MissingColon]; const header_name = header[0 .. mem.indexOf(u8, header, ": ") orelse return error.MissingColon];
const header_value = header[header_name.len + 2..header.len-1]; const header_value = header[header_name.len + 2 .. header.len - 1];
if (mem.eql(u8, header_name, "Content-Length")) { if (mem.eql(u8, header_name, "Content-Length")) {
if (header_value.len == 0) return error.MissingHeaderValue; if (header_value.len == 0) return error.MissingHeaderValue;
r.content_length = std.fmt.parseInt(usize, header_value, 10) catch return error.InvalidContentLength; r.content_length = std.fmt.parseInt(usize, header_value, 10) catch return error.InvalidContentLength;

View File

@ -23,7 +23,7 @@ pub fn log(
comptime message_level: std.log.Level, comptime message_level: std.log.Level,
comptime scope: @Type(.EnumLiteral), comptime scope: @Type(.EnumLiteral),
comptime format: []const u8, comptime format: []const u8,
args: var, args: anytype,
) void { ) void {
var arena = std.heap.ArenaAllocator.init(allocator); var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit(); defer arena.deinit();
@ -119,7 +119,7 @@ const no_semantic_tokens_response =
; ;
/// Sends a request or response /// Sends a request or response
fn send(arena: *std.heap.ArenaAllocator, reqOrRes: var) !void { fn send(arena: *std.heap.ArenaAllocator, reqOrRes: anytype) !void {
var arr = std.ArrayList(u8).init(&arena.allocator); var arr = std.ArrayList(u8).init(&arena.allocator);
try std.json.stringify(reqOrRes, .{}, arr.writer()); try std.json.stringify(reqOrRes, .{}, arr.writer());
@ -1381,7 +1381,7 @@ fn referencesHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
} }
// Needed for the hack seen below. // Needed for the hack seen below.
fn extractErr(val: var) anyerror { fn extractErr(val: anytype) anyerror {
val catch |e| return e; val catch |e| return e;
return error.HackDone; return error.HackDone;
} }

View File

@ -10,8 +10,8 @@ fn tokenReference(
handle: *DocumentStore.Handle, handle: *DocumentStore.Handle,
tok: ast.TokenIndex, tok: ast.TokenIndex,
encoding: offsets.Encoding, encoding: offsets.Encoding,
context: var, context: anytype,
comptime handler: var, comptime handler: anytype,
) !void { ) !void {
const loc = offsets.tokenRelativeLocation(handle.tree, 0, tok, encoding) catch return; const loc = offsets.tokenRelativeLocation(handle.tree, 0, tok, encoding) catch return;
try handler(context, types.Location{ try handler(context, types.Location{
@ -34,8 +34,8 @@ pub fn labelReferences(
decl: analysis.DeclWithHandle, decl: analysis.DeclWithHandle,
encoding: offsets.Encoding, encoding: offsets.Encoding,
include_decl: bool, include_decl: bool,
context: var, context: anytype,
comptime handler: var, comptime handler: anytype,
) !void { ) !void {
std.debug.assert(decl.decl.* == .label_decl); std.debug.assert(decl.decl.* == .label_decl);
const handle = decl.handle; const handle = decl.handle;
@ -69,8 +69,8 @@ fn symbolReferencesInternal(
node_handle: analysis.NodeWithHandle, node_handle: analysis.NodeWithHandle,
decl: analysis.DeclWithHandle, decl: analysis.DeclWithHandle,
encoding: offsets.Encoding, encoding: offsets.Encoding,
context: var, context: anytype,
comptime handler: var, comptime handler: anytype,
) error{OutOfMemory}!void { ) error{OutOfMemory}!void {
const node = node_handle.node; const node = node_handle.node;
const handle = node_handle.handle; const handle = node_handle.handle;
@ -354,8 +354,8 @@ pub fn symbolReferences(
decl_handle: analysis.DeclWithHandle, decl_handle: analysis.DeclWithHandle,
encoding: offsets.Encoding, encoding: offsets.Encoding,
include_decl: bool, include_decl: bool,
context: var, context: anytype,
comptime handler: var, comptime handler: anytype,
) !void { ) !void {
std.debug.assert(decl_handle.decl.* != .label_decl); std.debug.assert(decl_handle.decl.* != .label_decl);
const curr_handle = decl_handle.handle; const curr_handle = decl_handle.handle;

View File

@ -14,7 +14,7 @@ fn Default(comptime T: type, comptime default_value: T) type {
}; };
} }
fn Transform(comptime Original: type, comptime transform_fn: var) type { fn Transform(comptime Original: type, comptime transform_fn: anytype) type {
return struct { return struct {
pub const original_type = Original; pub const original_type = Original;
pub const transform = transform_fn; pub const transform = transform_fn;
@ -23,7 +23,7 @@ fn Transform(comptime Original: type, comptime transform_fn: var) type {
}; };
} }
inline fn fromDynamicTreeInternal(arena: *std.heap.ArenaAllocator, value: std.json.Value, out: var) error{ MalformedJson, OutOfMemory }!void { inline fn fromDynamicTreeInternal(arena: *std.heap.ArenaAllocator, value: std.json.Value, out: anytype) error{ MalformedJson, OutOfMemory }!void {
const T = comptime std.meta.Child(@TypeOf(out)); const T = comptime std.meta.Child(@TypeOf(out));
if (comptime std.meta.trait.is(.Struct)(T)) { if (comptime std.meta.trait.is(.Struct)(T)) {

View File

@ -198,7 +198,7 @@ fn writeContainerField(
store: *DocumentStore, store: *DocumentStore,
container_field: *ast.Node.ContainerField, container_field: *ast.Node.ContainerField,
field_token_type: ?TokenType, field_token_type: ?TokenType,
child_frame: var, child_frame: anytype,
) !void { ) !void {
if (container_field.doc_comments) |docs| try writeDocComments(builder, builder.handle.tree, docs); if (container_field.doc_comments) |docs| try writeDocComments(builder, builder.handle.tree, docs);
try writeToken(builder, container_field.comptime_token, .keyword); try writeToken(builder, container_field.comptime_token, .keyword);
@ -356,7 +356,7 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D
try writeToken(builder, param_decl.comptime_token, .keyword); try writeToken(builder, param_decl.comptime_token, .keyword);
try writeTokenMod(builder, param_decl.name_token, .parameter, .{ .definition = true }); try writeTokenMod(builder, param_decl.name_token, .parameter, .{ .definition = true });
switch (param_decl.param_type) { switch (param_decl.param_type) {
.var_type => |var_node| try writeToken(builder, var_node.firstToken(), .type), .any_type => |var_node| try writeToken(builder, var_node.firstToken(), .type),
.var_args => |var_args_tok| try writeToken(builder, var_args_tok, .operator), .var_args => |var_args_tok| try writeToken(builder, var_args_tok, .operator),
.type_expr => |type_expr| try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, type_expr }), .type_expr => |type_expr| try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, type_expr }),
} }
@ -708,7 +708,7 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D
try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, asm_expr.template }); try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, asm_expr.template });
// TODO Inputs, outputs. // TODO Inputs, outputs.
}, },
.VarType => { .AnyType => {
try writeToken(builder, node.firstToken(), .type); try writeToken(builder, node.firstToken(), .type);
}, },
.TestDecl => { .TestDecl => {

View File

@ -97,7 +97,7 @@ pub const MessageType = enum(Integer) {
pub fn jsonStringify( pub fn jsonStringify(
value: MessageType, value: MessageType,
options: json.StringifyOptions, options: json.StringifyOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
try json.stringify(@enumToInt(value), options, out_stream); try json.stringify(@enumToInt(value), options, out_stream);
} }
@ -117,7 +117,7 @@ pub const DiagnosticSeverity = enum(Integer) {
pub fn jsonStringify( pub fn jsonStringify(
value: DiagnosticSeverity, value: DiagnosticSeverity,
options: json.StringifyOptions, options: json.StringifyOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
try json.stringify(@enumToInt(value), options, out_stream); try json.stringify(@enumToInt(value), options, out_stream);
} }
@ -149,7 +149,7 @@ pub const WorkspaceEdit = struct {
pub fn jsonStringify( pub fn jsonStringify(
self: WorkspaceEdit, self: WorkspaceEdit,
options: std.json.StringifyOptions, options: std.json.StringifyOptions,
writer: var, writer: anytype,
) @TypeOf(writer).Error!void { ) @TypeOf(writer).Error!void {
try writer.writeByte('{'); try writer.writeByte('{');
if (self.changes) |changes| { if (self.changes) |changes| {
@ -182,7 +182,7 @@ pub const MarkupKind = enum(u1) {
pub fn jsonStringify( pub fn jsonStringify(
value: MarkupKind, value: MarkupKind,
options: json.StringifyOptions, options: json.StringifyOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
const str = switch (value) { const str = switch (value) {
.PlainText => "plaintext", .PlainText => "plaintext",
@ -249,7 +249,7 @@ pub const CompletionItemKind = enum(Integer) {
pub fn jsonStringify( pub fn jsonStringify(
value: CompletionItemKind, value: CompletionItemKind,
options: json.StringifyOptions, options: json.StringifyOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
try json.stringify(@enumToInt(value), options, out_stream); try json.stringify(@enumToInt(value), options, out_stream);
} }
@ -262,7 +262,7 @@ pub const InsertTextFormat = enum(Integer) {
pub fn jsonStringify( pub fn jsonStringify(
value: InsertTextFormat, value: InsertTextFormat,
options: json.StringifyOptions, options: json.StringifyOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
try json.stringify(@enumToInt(value), options, out_stream); try json.stringify(@enumToInt(value), options, out_stream);
} }
@ -311,7 +311,7 @@ const SymbolKind = enum {
pub fn jsonStringify( pub fn jsonStringify(
value: SymbolKind, value: SymbolKind,
options: json.StringifyOptions, options: json.StringifyOptions,
out_stream: var, out_stream: anytype,
) !void { ) !void {
try json.stringify(@enumToInt(value), options, out_stream); try json.stringify(@enumToInt(value), options, out_stream);
} }