Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Zig master @branchHint and builtin type fields #2011

Merged
merged 6 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const builtin = @import("builtin");
const zls_version = std.SemanticVersion{ .major = 0, .minor = 14, .patch = 0, .pre = "dev" };

/// Specify the minimum Zig version that is required to compile and test ZLS:
/// std.zig.tokenizer: simplification and spec conformance (#20885)
/// std: update `std.builtin.Type` fields to follow naming conventions (#21225)
///
/// If you do not use Nix, a ZLS maintainer can take care of this.
/// Whenever this version is increased, run the following command:
Expand All @@ -15,7 +15,7 @@ const zls_version = std.SemanticVersion{ .major = 0, .minor = 14, .patch = 0, .p
/// ```
///
/// Must match the `minimum_zig_version` in `build.zig.zon`.
const minimum_build_zig_version = "0.14.0-dev.1232+61919fe63";
const minimum_build_zig_version = "0.14.0-dev.1346+31fef6f11";

/// Specify the minimum Zig version that is required to run ZLS:
/// Release 0.12.0
Expand Down
6 changes: 3 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Must match the `zls_version` in `build.zig`
.version = "0.14.0-dev",
// Must match the `minimum_build_zig_version` in `build.zig`
.minimum_zig_version = "0.14.0-dev.1232+61919fe63",
.minimum_zig_version = "0.14.0-dev.1346+31fef6f11",
// If you do not use Nix, a ZLS maintainer can take care of this.
// Whenever the dependencies are updated, run the following command:
// ```bash
Expand All @@ -20,8 +20,8 @@
.hash = "1220102cb2c669d82184fb1dc5380193d37d68b54e8d75b76b2d155b9af7d7e2e76d",
},
.@"lsp-codegen" = .{
.url = "https://github.com/zigtools/zig-lsp-codegen/archive/193a210ebe4a090a6f1bf1cb538375b56472688d.tar.gz",
.hash = "1220c527c348bd6ce5dd545aacaf811a47f7f08dfeb2cb6fd9325680b788b5272041",
.url = "https://github.com/zigtools/zig-lsp-codegen/archive/6b34887189def7c859307f4a9fc436bc5f2f04c9.tar.gz",
.hash = "122054fe123b819c1cca154f0f89dd799832a639d432287a2371499bcaf7b9dcb7a0",
},
},
.paths = .{""},
Expand Down
6 changes: 3 additions & 3 deletions deps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ in linkFarm name [
};
}
{
name = "1220c527c348bd6ce5dd545aacaf811a47f7f08dfeb2cb6fd9325680b788b5272041";
name = "122054fe123b819c1cca154f0f89dd799832a639d432287a2371499bcaf7b9dcb7a0";
path = fetchZigArtifact {
name = "lsp-codegen";
url = "https://github.com/zigtools/zig-lsp-codegen/archive/193a210ebe4a090a6f1bf1cb538375b56472688d.tar.gz";
hash = "sha256-JqtvsWdQULNfLlesil24Dzms9RWODdoTAKblRjL5z1M=";
url = "https://github.com/zigtools/zig-lsp-codegen/archive/6b34887189def7c859307f4a9fc436bc5f2f04c9.tar.gz";
hash = "sha256-Q1Lm0YornfymWeryFdKe0AXsOJxhxHH72U1IcMxiVtA=";
};
}
]
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub const Handle = struct {
}

fn getDocumentScopeCold(self: *Handle) error{OutOfMemory}!DocumentScope {
@setCold(true);
@branchHint(.cold);
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();

Expand Down Expand Up @@ -412,7 +412,7 @@ pub const Handle = struct {
}

fn getZirCold(self: *Handle) error{OutOfMemory}!Zir {
@setCold(true);
@branchHint(.cold);
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();

Expand Down
8 changes: 4 additions & 4 deletions src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,11 @@ pub fn updateConfiguration(
else => {
if (old_config_value != new_config_value) {
switch (@typeInfo(@TypeOf(new_config_value))) {
.Bool,
.Int,
.Float,
.bool,
.int,
.float,
=> log.info("Set config option '{s}' to '{}'", .{ field.name, new_config_value }),
.Enum => log.info("Set config option '{s}' to '{s}'", .{ field.name, @tagName(new_config_value) }),
.@"enum" => log.info("Set config option '{s}' to '{s}'", .{ field.name, @tagName(new_config_value) }),
else => @compileError("unexpected config type ++ (" ++ @typeName(@TypeOf(new_config_value)) ++ ")"),
}
@field(server.config, field.name) = new_config_value;
Expand Down
142 changes: 71 additions & 71 deletions src/analyser/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ pub fn coerce(
if (in_memory_result == .ok) return try ip.getUnknown(gpa, dest_ty);

switch (ip.zigTypeTag(dest_ty)) {
.Optional => optional: {
.optional => optional: {
// null to ?T
if (inst_ty == .null_type) {
return try ip.getNull(gpa, dest_ty);
Expand All @@ -1698,11 +1698,11 @@ pub fn coerce(
.val = intermediate,
} });
},
.Pointer => pointer: {
.pointer => pointer: {
const dest_info = ip.indexToKey(dest_ty).pointer_type;

// Function body to function pointer.
if (ip.zigTypeTag(inst_ty) == .Fn) {
if (ip.zigTypeTag(inst_ty) == .@"fn") {
return try ip.getUnknown(gpa, dest_ty);
}

Expand Down Expand Up @@ -1781,7 +1781,7 @@ pub fn coerce(
if (dest_info.elem_type == .anyopaque_type and inst_ty_key == .pointer_type) {
// TODO if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
const elem_ty = ip.indexToKey(inst_ty).pointer_type.elem_type;
const is_pointer = ip.zigTypeTag(elem_ty) == .Pointer;
const is_pointer = ip.zigTypeTag(elem_ty) == .pointer;
if (is_pointer or ip.isPtrLikeOptional(elem_ty)) {
in_memory_result = .{ .double_ptr_to_anyopaque = .{
.actual = inst_ty,
Expand All @@ -1795,9 +1795,9 @@ pub fn coerce(

return try ip.getUnknown(gpa, dest_ty);
},
.Int, .ComptimeInt => switch (ip.zigTypeTag(inst_ty)) {
.Float, .ComptimeFloat => return try ip.getUnknown(gpa, dest_ty),
.Int, .ComptimeInt => {
.int, .comptime_int => switch (ip.zigTypeTag(inst_ty)) {
.float, .comptime_float => return try ip.getUnknown(gpa, dest_ty),
.int, .comptime_int => {
if (try ip.intFitsInType(inst, dest_ty, target)) {
return try ip.coerceInt(gpa, dest_ty, inst);
} else {
Expand All @@ -1810,13 +1810,13 @@ pub fn coerce(
},
else => {},
},
.Float, .ComptimeFloat => return try ip.getUnknown(gpa, dest_ty),
.Enum => return try ip.getUnknown(gpa, dest_ty),
.ErrorUnion => return try ip.getUnknown(gpa, dest_ty),
.Union => return try ip.getUnknown(gpa, dest_ty),
.Array => switch (ip.zigTypeTag(inst_ty)) {
.Vector => return try ip.getUnknown(gpa, dest_ty),
.Struct => {
.float, .comptime_float => return try ip.getUnknown(gpa, dest_ty),
.@"enum" => return try ip.getUnknown(gpa, dest_ty),
.error_union => return try ip.getUnknown(gpa, dest_ty),
.@"union" => return try ip.getUnknown(gpa, dest_ty),
.array => switch (ip.zigTypeTag(inst_ty)) {
.vector => return try ip.getUnknown(gpa, dest_ty),
.@"struct" => {
if (inst_ty == Index.empty_struct_type) {
const len = ip.indexToKey(dest_ty).array_type.len;
if (len != 0) {
Expand All @@ -1833,8 +1833,8 @@ pub fn coerce(
},
else => {},
},
.Vector => return try ip.getUnknown(gpa, dest_ty),
.Struct => return try ip.getUnknown(gpa, dest_ty),
.vector => return try ip.getUnknown(gpa, dest_ty),
.@"struct" => return try ip.getUnknown(gpa, dest_ty),
else => {},
}

Expand Down Expand Up @@ -2216,7 +2216,7 @@ pub fn resolvePeerTypes(ip: *InternPool, gpa: Allocator, types: []const Index, t
},
.function_type => {
if (candidate_info.flags.is_const and
ip.zigTypeTag(candidate_info.elem_type) == .Fn and
ip.zigTypeTag(candidate_info.elem_type) == .@"fn" and
.ok == try ip.coerceInMemoryAllowedFns(gpa, arena, chosen, candidate_info.elem_type, target))
{
chosen = candidate;
Expand Down Expand Up @@ -2503,7 +2503,7 @@ fn coerceInMemoryAllowed(
}

switch (dest_tag) {
.Int => {
.int => {
const dest_info = ip.intInfo(dest_ty, target);
const src_info = ip.intInfo(src_ty, target);

Expand All @@ -2523,7 +2523,7 @@ fn coerceInMemoryAllowed(
}
return .ok;
},
.Float => {
.float => {
const dest_bits = ip.floatBits(dest_ty, target);
const src_bits = ip.floatBits(src_ty, target);
if (dest_bits == src_bits) return .ok;
Expand All @@ -2532,10 +2532,10 @@ fn coerceInMemoryAllowed(
.wanted = src_ty,
} };
},
.Pointer => {
.pointer => {
return try ip.coerceInMemoryAllowedPtrs(gpa, arena, dest_ty, src_ty, dest_is_const, target);
},
.Optional => {
.optional => {
// Pointer-like Optionals
const maybe_dest_ptr_ty = ip.optionalPtrTy(dest_ty);
const maybe_src_ptr_ty = ip.optionalPtrTy(src_ty);
Expand Down Expand Up @@ -2564,10 +2564,10 @@ fn coerceInMemoryAllowed(

return .ok;
},
.Fn => {
.@"fn" => {
return try ip.coerceInMemoryAllowedFns(gpa, arena, dest_ty, src_ty, target);
},
.ErrorUnion => {
.error_union => {
const dest_payload = dest_key.error_union_type.payload_type;
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);
Expand All @@ -2583,10 +2583,10 @@ fn coerceInMemoryAllowed(
if (dest_set == .none or src_set == .none) return .ok;
return try ip.coerceInMemoryAllowedErrorSets(gpa, arena, dest_set, src_set);
},
.ErrorSet => {
.error_set => {
return try ip.coerceInMemoryAllowedErrorSets(gpa, arena, dest_ty, src_ty);
},
.Array => {
.array => {
const dest_info = dest_key.array_type;
const src_info = src_key.array_type;
if (dest_info.len != src_info.len) {
Expand Down Expand Up @@ -2618,7 +2618,7 @@ fn coerceInMemoryAllowed(
}
return .ok;
},
.Vector => {
.vector => {
const dest_len = dest_key.vector_type.len;
const src_len = src_key.vector_type.len;

Expand Down Expand Up @@ -2932,7 +2932,7 @@ pub fn zigTypeTag(ip: *InternPool, index: Index) std.builtin.TypeId {
.f80,
.f128,
.c_longdouble,
=> .Float,
=> .float,

.usize,
.isize,
Expand All @@ -2945,51 +2945,51 @@ pub fn zigTypeTag(ip: *InternPool, index: Index) std.builtin.TypeId {
.c_ulong,
.c_longlong,
.c_ulonglong,
=> .Int,

.comptime_int => .ComptimeInt,
.comptime_float => .ComptimeFloat,

.anyopaque => .Opaque,
.bool => .Bool,
.void => .Void,
.type => .Type,
.anyerror => .ErrorSet,
.noreturn => .NoReturn,
.anyframe_type => .AnyFrame,
.empty_struct_type => .Struct,
.null_type => .Null,
.undefined_type => .Undefined,
.enum_literal_type => .EnumLiteral,

.atomic_order => .Enum,
.atomic_rmw_op => .Enum,
.calling_convention => .Enum,
.address_space => .Enum,
.float_mode => .Enum,
.reduce_op => .Enum,
.modifier => .Enum,
.prefetch_options => .Struct,
.export_options => .Struct,
.extern_options => .Struct,
.type_info => .Union,
=> .int,

.comptime_int => .comptime_int,
.comptime_float => .comptime_float,

.anyopaque => .@"opaque",
.bool => .bool,
.void => .void,
.type => .type,
.anyerror => .error_set,
.noreturn => .noreturn,
.anyframe_type => .@"anyframe",
.empty_struct_type => .@"struct",
.null_type => .null,
.undefined_type => .undefined,
.enum_literal_type => .enum_literal,

.atomic_order => .@"enum",
.atomic_rmw_op => .@"enum",
.calling_convention => .@"enum",
.address_space => .@"enum",
.float_mode => .@"enum",
.reduce_op => .@"enum",
.modifier => .@"enum",
.prefetch_options => .@"struct",
.export_options => .@"struct",
.extern_options => .@"struct",
.type_info => .@"union",

.unknown => unreachable,
.generic_poison => unreachable,
},
.type_int_signed, .type_int_unsigned => .Int,
.type_pointer => .Pointer,
.type_array => .Array,
.type_struct => .Struct,
.type_optional => .Optional,
.type_error_union => .ErrorUnion,
.type_error_set => .ErrorSet,
.type_enum => .Enum,
.type_function => .Fn,
.type_union => .Union,
.type_tuple => .Struct,
.type_vector => .Vector,
.type_anyframe => .AnyFrame,
.type_int_signed, .type_int_unsigned => .int,
.type_pointer => .pointer,
.type_array => .array,
.type_struct => .@"struct",
.type_optional => .optional,
.type_error_union => .error_union,
.type_error_set => .error_set,
.type_enum => .@"enum",
.type_function => .@"fn",
.type_union => .@"union",
.type_tuple => .@"struct",
.type_vector => .vector,
.type_anyframe => .@"anyframe",

.simple_value,
.int_u64,
Expand Down Expand Up @@ -3433,8 +3433,8 @@ pub fn elemType(ip: *InternPool, ty: Index) Index {
}

pub fn errorSetMerge(ip: *InternPool, gpa: Allocator, a_ty: Index, b_ty: Index) Allocator.Error!Index {
assert(ip.zigTypeTag(a_ty) == .ErrorSet);
assert(ip.zigTypeTag(b_ty) == .ErrorSet);
assert(ip.zigTypeTag(a_ty) == .error_set);
assert(ip.zigTypeTag(b_ty) == .error_set);

// Anything merged with anyerror is anyerror.
if (a_ty == .anyerror_type or b_ty == .anyerror_type) {
Expand Down Expand Up @@ -3709,7 +3709,7 @@ pub fn isZero(ip: *InternPool, val: Index) bool {

/// If the value fits in the given integer, return it, otherwise null.
pub fn toInt(ip: *InternPool, val: Index, comptime T: type) ?T {
comptime assert(@typeInfo(T) == .Int);
comptime assert(@typeInfo(T) == .int);
return switch (ip.indexToKey(val)) {
.simple_value => |simple| switch (simple) {
.null_value => 0,
Expand Down
Loading