Skip to content

Commit

Permalink
embrace RLS even harder
Browse files Browse the repository at this point in the history
  • Loading branch information
xdBronch committed Jan 4, 2025
1 parent 19421e0 commit ff35463
Show file tree
Hide file tree
Showing 26 changed files with 157 additions and 157 deletions.
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ fn getTracyModule(

// On mingw, we need to opt into windows 7+ to get some features required by tracy.
const tracy_c_flags: []const []const u8 = if (options.target.result.isMinGW())
&[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }
&.{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }
else
&[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
&.{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };

tracy_module.addIncludePath(tracy_dependency.path(""));
tracy_module.addCSourceFile(.{
Expand Down
2 changes: 1 addition & 1 deletion src/BuildAssociatedConfig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const BuildOption = struct {
try allocator.dupe(u8, val)
else
null;
return BuildOption{
return .{
.name = copy_name,
.value = copy_value,
};
Expand Down
8 changes: 4 additions & 4 deletions src/DocumentScope.zig
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,10 @@ const ScopeContext = struct {
.loc = loc,
.parent_scope = context.current_scope,
.child_scopes = .{
.small = [_]Scope.OptionalIndex{.none} ** Scope.ChildScopes.small_size,
.small = @splat(.none),
},
.child_declarations = .{
.small = [_]Declaration.OptionalIndex{.none} ** Scope.ChildDeclarations.small_size,
.small = @splat(.none),
},
});
const new_scope_index: Scope.Index = @enumFromInt(context.doc_scope.scopes.len - 1);
Expand Down Expand Up @@ -896,7 +896,7 @@ noinline fn walkContainerDecl(
const gop = try context.doc_scope.global_enum_set.getOrPutContext(
context.allocator,
main_token,
IdentifierTokenContext{ .tree = tree },
.{ .tree = tree },
);
if (!gop.found_existing) {
gop.key_ptr.* = main_token;
Expand Down Expand Up @@ -963,7 +963,7 @@ noinline fn walkErrorSetNode(
const gop = try context.doc_scope.global_error_set.getOrPutContext(
context.allocator,
identifier_token,
IdentifierTokenContext{ .tree = tree },
.{ .tree = tree },
);
if (!gop.found_existing or token_tags[identifier_token - 1] == .doc_comment) {
// a token with a doc comment takes priority.
Expand Down
4 changes: 2 additions & 2 deletions src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ fn loadBuildConfiguration(self: *DocumentStore, build_file_uri: Uri) !std.json.P
errdefer build_config.deinit();

for (build_config.value.packages) |*pkg| {
pkg.path = try std.fs.path.resolve(build_config.arena.allocator(), &[_][]const u8{ build_file_path, "..", pkg.path });
pkg.path = try std.fs.path.resolve(build_config.arena.allocator(), &.{ build_file_path, "..", pkg.path });
}

return build_config;
Expand Down Expand Up @@ -1150,7 +1150,7 @@ fn createBuildFile(self: *DocumentStore, uri: Uri) error{OutOfMemory}!BuildFile
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();

var build_file = BuildFile{
var build_file: BuildFile = .{
.uri = try self.allocator.dupe(u8, uri),
};

Expand Down
14 changes: 7 additions & 7 deletions src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ fn initializeHandler(server: *Server, arena: std.mem.Allocator, request: types.I
.renameProvider = .{ .bool = true },
.completionProvider = .{
.resolveProvider = false,
.triggerCharacters = &[_][]const u8{ ".", ":", "@", "]", "\"", "/" },
.triggerCharacters = &.{ ".", ":", "@", "]", "\"", "/" },
.completionItem = .{ .labelDetailsSupport = true },
},
.documentHighlightProvider = .{ .bool = true },
Expand Down Expand Up @@ -690,7 +690,7 @@ fn registerCapability(server: *Server, method: []const u8) Error!void {
.{ .string = id },
"client/registerCapability",
types.RegistrationParams{ .registrations = &.{
types.Registration{
.{
.id = id,
.method = method,
},
Expand Down Expand Up @@ -1320,7 +1320,7 @@ fn resolveConfiguration(
};
defer allocator.free(cache_dir_path);

config.global_cache_path = try std.fs.path.join(config_arena, &[_][]const u8{ cache_dir_path, "zls" });
config.global_cache_path = try std.fs.path.join(config_arena, &.{ cache_dir_path, "zls" });

std.fs.cwd().makePath(config.global_cache_path.?) catch |err| {
log.warn("failed to create directory '{s}': {}", .{ config.global_cache_path.?, err });
Expand Down Expand Up @@ -1473,7 +1473,7 @@ fn saveDocumentHandler(server: *Server, arena: std.mem.Allocator, notification:
const handle = server.document_store.getHandle(uri) orelse return;
var text_edits = try server.autofix(arena, handle);

var workspace_edit = types.WorkspaceEdit{ .changes = .{} };
var workspace_edit: types.WorkspaceEdit = .{ .changes = .{} };
try workspace_edit.changes.?.map.putNoClobber(arena, uri, try text_edits.toOwnedSlice(arena));

const json_message = try server.sendToClientRequest(
Expand Down Expand Up @@ -1885,12 +1885,12 @@ fn isBlockingMessage(msg: Message) bool {
pub fn create(allocator: std.mem.Allocator) !*Server {
const server = try allocator.create(Server);
errdefer server.destroy();
server.* = Server{
server.* = .{
.allocator = allocator,
.config = .{},
.document_store = .{
.allocator = allocator,
.config = .fromMainConfig(Config{}),
.config = .fromMainConfig(.{}),
.thread_pool = if (zig_builtin.single_threaded) {} else undefined, // set below
.diagnostics_collection = &server.diagnostics_collection,
},
Expand Down Expand Up @@ -2114,7 +2114,7 @@ fn processMessageReportError(server: *Server, message: Message) ?[]const u8 {
}

switch (message) {
.request => |request| return server.sendToClientResponseError(request.id, lsp.JsonRPCMessage.Response.Error{
.request => |request| return server.sendToClientResponseError(request.id, .{
.code = @enumFromInt(switch (err) {
error.OutOfMemory => @intFromEnum(types.ErrorCodes.InternalError),
error.ParseError => @intFromEnum(types.ErrorCodes.ParseError),
Expand Down
62 changes: 31 additions & 31 deletions src/analyser/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ pub const Index = enum(u32) {
start: u32,
len: u32,

pub const empty = Slice{
pub const empty: Slice = .{
.start = std.math.maxInt(u32),
.len = 0,
};
Expand Down Expand Up @@ -713,7 +713,7 @@ pub const StringSlice = struct {
start: u32,
len: u32,

pub const empty = StringSlice{
pub const empty: StringSlice = .{
.start = std.math.maxInt(u32),
.len = 0,
};
Expand Down Expand Up @@ -751,7 +751,7 @@ pub const LimbSlice = struct {
start: u32,
len: u32,

pub const empty = LimbSlice{
pub const empty: LimbSlice = .{
.start = std.math.maxInt(u32),
.len = 0,
};
Expand Down Expand Up @@ -2507,7 +2507,7 @@ fn coerceInMemoryAllowed(
const src_tag = ip.zigTypeTag(src_ty);

if (dest_tag != src_tag) {
return InMemoryCoercionResult{ .no_match = .{
return .{ .no_match = .{
.actual = dest_ty,
.wanted = src_ty,
} };
Expand All @@ -2525,7 +2525,7 @@ fn coerceInMemoryAllowed(
(dest_info.signedness == .signed and (src_info.signedness == .unsigned or dest_info.bits <= src_info.bits)) or
(dest_info.signedness == .unsigned and src_info.signedness == .signed))
{
return InMemoryCoercionResult{ .int_not_coercible = .{
return .{ .int_not_coercible = .{
.actual_signedness = src_info.signedness,
.wanted_signedness = dest_info.signedness,
.actual_bits = src_info.bits,
Expand All @@ -2538,7 +2538,7 @@ fn coerceInMemoryAllowed(
const dest_bits = ip.floatBits(dest_ty, target);
const src_bits = ip.floatBits(src_ty, target);
if (dest_bits == src_bits) return .ok;
return InMemoryCoercionResult{ .no_match = .{
return .{ .no_match = .{
.actual = dest_ty,
.wanted = src_ty,
} };
Expand All @@ -2555,7 +2555,7 @@ fn coerceInMemoryAllowed(
}

if (maybe_dest_ptr_ty != maybe_src_ptr_ty) {
return InMemoryCoercionResult{ .optional_shape = .{
return .{ .optional_shape = .{
.actual = src_ty,
.wanted = dest_ty,
} };
Expand All @@ -2566,7 +2566,7 @@ fn coerceInMemoryAllowed(

const child = try ip.coerceInMemoryAllowed(gpa, arena, dest_child_type, src_child_type, dest_is_const, target);
if (child != .ok) {
return InMemoryCoercionResult{ .optional_child = .{
return .{ .optional_child = .{
.child = try child.dupe(arena),
.actual = src_child_type,
.wanted = dest_child_type,
Expand All @@ -2583,7 +2583,7 @@ fn coerceInMemoryAllowed(
const src_payload = src_key.error_union_type.payload_type;
const child = try ip.coerceInMemoryAllowed(gpa, arena, dest_payload, src_payload, dest_is_const, target);
if (child != .ok) {
return InMemoryCoercionResult{ .error_union_payload = .{
return .{ .error_union_payload = .{
.child = try child.dupe(arena),
.actual = src_payload,
.wanted = dest_payload,
Expand All @@ -2601,15 +2601,15 @@ fn coerceInMemoryAllowed(
const dest_info = dest_key.array_type;
const src_info = src_key.array_type;
if (dest_info.len != src_info.len) {
return InMemoryCoercionResult{ .array_len = .{
return .{ .array_len = .{
.actual = src_info.len,
.wanted = dest_info.len,
} };
}

const child = try ip.coerceInMemoryAllowed(gpa, arena, dest_info.child, src_info.child, dest_is_const, target);
if (child != .ok) {
return InMemoryCoercionResult{ .array_elem = .{
return .{ .array_elem = .{
.child = try child.dupe(arena),
.actual = src_info.child,
.wanted = dest_info.child,
Expand All @@ -2621,7 +2621,7 @@ fn coerceInMemoryAllowed(
dest_info.sentinel == src_info.sentinel // is this enough for a value equality check?
);
if (!ok_sent) {
return InMemoryCoercionResult{ .array_sentinel = .{
return .{ .array_sentinel = .{
.actual = src_info.sentinel,
.wanted = dest_info.sentinel,
.ty = dest_info.child,
Expand All @@ -2634,7 +2634,7 @@ fn coerceInMemoryAllowed(
const src_len = src_key.vector_type.len;

if (dest_len != src_len) {
return InMemoryCoercionResult{ .vector_len = .{
return .{ .vector_len = .{
.actual = src_len,
.wanted = dest_len,
} };
Expand All @@ -2644,7 +2644,7 @@ fn coerceInMemoryAllowed(
const src_elem_ty = src_key.vector_type.child;
const child = try ip.coerceInMemoryAllowed(gpa, arena, dest_elem_ty, src_elem_ty, dest_is_const, target);
if (child != .ok) {
return InMemoryCoercionResult{ .vector_elem = .{
return .{ .vector_elem = .{
.child = try child.dupe(arena),
.actual = src_elem_ty,
.wanted = dest_elem_ty,
Expand All @@ -2654,7 +2654,7 @@ fn coerceInMemoryAllowed(
return .ok;
},
else => {
return InMemoryCoercionResult{ .no_match = .{
return .{ .no_match = .{
.actual = dest_ty,
.wanted = src_ty,
} };
Expand Down Expand Up @@ -2690,7 +2690,7 @@ fn coerceInMemoryAllowedErrorSets(

if (missing_error_buf.items.len == 0) return .ok;

return InMemoryCoercionResult{
return .{
.missing_error = try arena.dupe(String, missing_error_buf.items),
};
}
Expand All @@ -2707,15 +2707,15 @@ fn coerceInMemoryAllowedFns(
const src_info = ip.indexToKey(src_ty).function_type;

if (dest_info.flags.is_var_args != src_info.flags.is_var_args) {
return InMemoryCoercionResult{ .fn_var_args = dest_info.flags.is_var_args };
return .{ .fn_var_args = dest_info.flags.is_var_args };
}

if (dest_info.flags.is_generic != src_info.flags.is_generic) {
return InMemoryCoercionResult{ .fn_generic = dest_info.flags.is_generic };
return .{ .fn_generic = dest_info.flags.is_generic };
}

if (dest_info.flags.calling_convention != src_info.flags.calling_convention) {
return InMemoryCoercionResult{ .fn_cc = .{
return .{ .fn_cc = .{
.actual = src_info.flags.calling_convention,
.wanted = dest_info.flags.calling_convention,
} };
Expand All @@ -2724,7 +2724,7 @@ fn coerceInMemoryAllowedFns(
if (src_info.return_type != Index.noreturn_type) {
const rt = try ip.coerceInMemoryAllowed(gpa, arena, dest_info.return_type, src_info.return_type, true, target);
if (rt != .ok) {
return InMemoryCoercionResult{ .fn_return_type = .{
return .{ .fn_return_type = .{
.child = try rt.dupe(arena),
.actual = src_info.return_type,
.wanted = dest_info.return_type,
Expand All @@ -2733,22 +2733,22 @@ fn coerceInMemoryAllowedFns(
}

if (dest_info.args.len != src_info.args.len) {
return InMemoryCoercionResult{ .fn_param_count = .{
return .{ .fn_param_count = .{
.actual = src_info.args.len,
.wanted = dest_info.args.len,
} };
}

if (!dest_info.args_is_noalias.eql(src_info.args_is_noalias)) {
return InMemoryCoercionResult{ .fn_param_noalias = .{
return .{ .fn_param_noalias = .{
.actual = src_info.args_is_noalias.mask,
.wanted = dest_info.args_is_noalias.mask,
} };
}

if (!dest_info.args_is_comptime.eql(src_info.args_is_comptime)) {
const index = dest_info.args_is_comptime.xorWith(src_info.args_is_comptime).findFirstSet().?;
return InMemoryCoercionResult{ .fn_param_comptime = .{
return .{ .fn_param_comptime = .{
.index = index,
.wanted = dest_info.args_is_comptime.isSet(index),
} };
Expand All @@ -2764,7 +2764,7 @@ fn coerceInMemoryAllowedFns(
// Note: Cast direction is reversed here.
const param = try ip.coerceInMemoryAllowed(gpa, arena, src_arg_ty, dest_arg_ty, true, target);
if (param != .ok) {
return InMemoryCoercionResult{ .fn_param = .{
return .{ .fn_param = .{
.child = try param.dupe(arena),
.actual = src_arg_ty,
.wanted = dest_arg_ty,
Expand Down Expand Up @@ -2799,7 +2799,7 @@ fn coerceInMemoryAllowedPtrs(
const ok_ptr_size = src_info.flags.size == dest_info.flags.size or
src_info.flags.size == .C or dest_info.flags.size == .C;
if (!ok_ptr_size) {
return InMemoryCoercionResult{ .ptr_size = .{
return .{ .ptr_size = .{
.actual = src_info.flags.size,
.wanted = dest_info.flags.size,
} };
Expand All @@ -2810,7 +2810,7 @@ fn coerceInMemoryAllowedPtrs(
(!src_info.flags.is_volatile or dest_info.flags.is_volatile);

if (!ok_cv_qualifiers) {
return InMemoryCoercionResult{ .ptr_qualifiers = .{
return .{ .ptr_qualifiers = .{
.actual_const = src_info.flags.is_const,
.wanted_const = dest_info.flags.is_const,
.actual_volatile = src_info.flags.is_volatile,
Expand All @@ -2819,15 +2819,15 @@ fn coerceInMemoryAllowedPtrs(
}

if (dest_info.flags.address_space != src_info.flags.address_space) {
return InMemoryCoercionResult{ .ptr_addrspace = .{
return .{ .ptr_addrspace = .{
.actual = src_info.flags.address_space,
.wanted = dest_info.flags.address_space,
} };
}

const child = try ip.coerceInMemoryAllowed(gpa, arena, dest_info.elem_type, src_info.elem_type, dest_info.flags.is_const, target);
if (child != .ok) {
return InMemoryCoercionResult{ .ptr_child = .{
return .{ .ptr_child = .{
.child = try child.dupe(arena),
.actual = src_info.elem_type,
.wanted = dest_info.elem_type,
Expand All @@ -2839,7 +2839,7 @@ fn coerceInMemoryAllowedPtrs(

const ok_allows_zero = (dest_allow_zero and (src_allow_zero or dest_is_const)) or (!dest_allow_zero and !src_allow_zero);
if (!ok_allows_zero) {
return InMemoryCoercionResult{ .ptr_allowzero = .{
return .{ .ptr_allowzero = .{
.actual = src_ty,
.wanted = dest_ty,
} };
Expand All @@ -2848,7 +2848,7 @@ fn coerceInMemoryAllowedPtrs(
if (src_info.packed_offset.host_size != dest_info.packed_offset.host_size or
src_info.packed_offset.bit_offset != dest_info.packed_offset.bit_offset)
{
return InMemoryCoercionResult{ .ptr_bit_range = .{
return .{ .ptr_bit_range = .{
.actual_host = src_info.packed_offset.host_size,
.wanted_host = dest_info.packed_offset.host_size,
.actual_offset = src_info.packed_offset.bit_offset,
Expand All @@ -2858,7 +2858,7 @@ fn coerceInMemoryAllowedPtrs(

const ok_sent = dest_info.sentinel == .none or src_info.flags.size == .C or dest_info.sentinel == src_info.sentinel; // is this enough for a value equality check?
if (!ok_sent) {
return InMemoryCoercionResult{ .ptr_sentinel = .{
return .{ .ptr_sentinel = .{
.actual = src_info.sentinel,
.wanted = dest_info.sentinel,
.ty = dest_info.elem_type,
Expand Down
Loading

0 comments on commit ff35463

Please sign in to comment.