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) {
.var_args => try buffer.appendSlice("..."),
.var_type => try buffer.appendSlice("var"),
.any_type => try buffer.appendSlice("anytype"),
.type_expr => |type_expr| {
var curr_tok = type_expr.firstToken();
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 {
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;
}
}
@ -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 {
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 => {
const decl = child.cast(ast.Node.ContainerDecl).?;
@ -1600,8 +1600,8 @@ fn iterateSymbolsContainerInternal(
arena: *std.heap.ArenaAllocator,
container_handle: NodeWithHandle,
orig_handle: *DocumentStore.Handle,
comptime callback: var,
context: var,
comptime callback: anytype,
context: anytype,
instance_access: bool,
use_trail: *std.ArrayList(*ast.Node.Use),
) error{OutOfMemory}!void {
@ -1651,8 +1651,8 @@ pub fn iterateSymbolsContainer(
arena: *std.heap.ArenaAllocator,
container_handle: NodeWithHandle,
orig_handle: *DocumentStore.Handle,
comptime callback: var,
context: var,
comptime callback: anytype,
context: anytype,
instance_access: bool,
) error{OutOfMemory}!void {
var use_trail = std.ArrayList(*ast.Node.Use).init(&arena.allocator);
@ -1662,8 +1662,8 @@ pub fn iterateSymbolsContainer(
pub fn iterateLabels(
handle: *DocumentStore.Handle,
source_index: usize,
comptime callback: var,
context: var,
comptime callback: anytype,
context: anytype,
) error{OutOfMemory}!void {
for (handle.document_scope.scopes) |scope| {
if (source_index >= scope.range.start and source_index < scope.range.end) {
@ -1685,8 +1685,8 @@ fn iterateSymbolsGlobalInternal(
arena: *std.heap.ArenaAllocator,
handle: *DocumentStore.Handle,
source_index: usize,
comptime callback: var,
context: var,
comptime callback: anytype,
context: anytype,
use_trail: *std.ArrayList(*ast.Node.Use),
) error{OutOfMemory}!void {
for (handle.document_scope.scopes) |scope| {
@ -1720,8 +1720,8 @@ pub fn iterateSymbolsGlobal(
arena: *std.heap.ArenaAllocator,
handle: *DocumentStore.Handle,
source_index: usize,
comptime callback: var,
context: var,
comptime callback: anytype,
context: anytype,
) error{OutOfMemory}!void {
var use_trail = std.ArrayList(*ast.Node.Use).init(&arena.allocator);
return try iterateSymbolsGlobalInternal(store, arena, handle, source_index, callback, context, &use_trail);

View File

@ -41,7 +41,7 @@ pub const AllocationInfo = struct {
self: AllocationInfo,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
out_stream: var,
out_stream: anytype,
) !void {
@setEvalBranchQuota(2000);
@ -174,8 +174,7 @@ pub fn printRemainingStackTraces(self: DebugAllocator) void {
std.debug.print(
\\{} allocations - stack traces follow
\\------------------------------------
,
.{self.allocation_strack_addresses.count()});
, .{self.allocation_strack_addresses.count()});
var it = self.allocation_strack_addresses.iterator();
var idx: usize = 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{
.content_length = undefined,
.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 == 1) break;
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_name = header[0 .. mem.indexOf(u8, header, ": ") orelse return error.MissingColon];
const header_value = header[header_name.len + 2 .. header.len - 1];
if (mem.eql(u8, header_name, "Content-Length")) {
if (header_value.len == 0) return error.MissingHeaderValue;
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 scope: @Type(.EnumLiteral),
comptime format: []const u8,
args: var,
args: anytype,
) void {
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
@ -119,7 +119,7 @@ const no_semantic_tokens_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);
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.
fn extractErr(val: var) anyerror {
fn extractErr(val: anytype) anyerror {
val catch |e| return e;
return error.HackDone;
}

View File

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

View File

@ -198,7 +198,7 @@ fn writeContainerField(
store: *DocumentStore,
container_field: *ast.Node.ContainerField,
field_token_type: ?TokenType,
child_frame: var,
child_frame: anytype,
) !void {
if (container_field.doc_comments) |docs| try writeDocComments(builder, builder.handle.tree, docs);
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 writeTokenMod(builder, param_decl.name_token, .parameter, .{ .definition = true });
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),
.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 });
// TODO Inputs, outputs.
},
.VarType => {
.AnyType => {
try writeToken(builder, node.firstToken(), .type);
},
.TestDecl => {

View File

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