diff --git a/build.zig b/build.zig index 190c128d3..4af1077b9 100644 --- a/build.zig +++ b/build.zig @@ -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: @@ -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 diff --git a/build.zig.zon b/build.zig.zon index fd1003e3b..9f06982a0 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -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 @@ -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 = .{""}, diff --git a/deps.nix b/deps.nix index 163bf282e..88c196467 100644 --- a/deps.nix +++ b/deps.nix @@ -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="; }; } ] \ No newline at end of file diff --git a/flake.lock b/flake.lock index e388129bc..43bdaceab 100644 --- a/flake.lock +++ b/flake.lock @@ -74,11 +74,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1724242322, - "narHash": "sha256-HMpK7hNjhEk4z5SFg5UtxEio9OWFocHdaQzCfW1pE7w=", + "lastModified": 1725001927, + "narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "224042e9a3039291f22f4f2ded12af95a616cca0", + "rev": "6e99f2a27d600612004fbd2c3282d614bfee6421", "type": "github" }, "original": { @@ -135,11 +135,11 @@ ] }, "locked": { - "lastModified": 1724328603, - "narHash": "sha256-5udGQrqbdxkQ/nIuI0KAdohxuZtOzYhxVuERUkqde+E=", + "lastModified": 1725106169, + "narHash": "sha256-FS2i56CV5BcLOrErWPLTHldw29AK8DcnE7aKUUoS2FU=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "1f0785c9b064455d5ba78002470f6dfad65de2a8", + "rev": "695df248dde30f61298951a8d96faa984ac84581", "type": "github" }, "original": { diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig index 00e26e878..90022ba30 100644 --- a/src/DocumentStore.zig +++ b/src/DocumentStore.zig @@ -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(); @@ -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(); diff --git a/src/Server.zig b/src/Server.zig index 9b89dbd70..dab396c3a 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -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; diff --git a/src/analyser/InternPool.zig b/src/analyser/InternPool.zig index 6a70e1eb0..3fffc8c60 100644 --- a/src/analyser/InternPool.zig +++ b/src/analyser/InternPool.zig @@ -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); @@ -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); } @@ -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, @@ -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 { @@ -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) { @@ -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 => {}, } @@ -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; @@ -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); @@ -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; @@ -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); @@ -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); @@ -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) { @@ -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; @@ -2932,7 +2932,7 @@ pub fn zigTypeTag(ip: *InternPool, index: Index) std.builtin.TypeId { .f80, .f128, .c_longdouble, - => .Float, + => .float, .usize, .isize, @@ -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, @@ -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) { @@ -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, diff --git a/src/analyser/error_msg.zig b/src/analyser/error_msg.zig index d31bb9191..8fe7e02a1 100644 --- a/src/analyser/error_msg.zig +++ b/src/analyser/error_msg.zig @@ -79,30 +79,30 @@ pub const ErrorMsg = union(enum) { ), .expected_tag_type => |info| blk: { const expected_tag_str = switch (info.expected_tag) { - .Type => "type", - .Void => "void", - .Bool => "bool", - .NoReturn => "noreturn", - .Int => "integer", - .Float => "float", - .Pointer => "pointer", - .Array => "array", - .Struct => "struct", - .ComptimeFloat => "comptime_float", - .ComptimeInt => "comptime_int", - .Undefined => "undefined", - .Null => "null", - .Optional => "optional", - .ErrorUnion => "error union", - .ErrorSet => "error set", - .Enum => "enum", - .Union => "union", - .Fn => "function", - .Opaque => "opaque", - .Frame => "frame", - .AnyFrame => "anyframe", - .Vector => "vector", - .EnumLiteral => "enum literal", + .type => "type", + .void => "void", + .bool => "bool", + .noreturn => "noreturn", + .int => "integer", + .float => "float", + .pointer => "pointer", + .array => "array", + .@"struct" => "struct", + .comptime_float => "comptime_float", + .comptime_int => "comptime_int", + .undefined => "undefined", + .null => "null", + .optional => "optional", + .error_union => "error union", + .error_set => "error set", + .@"enum" => "enum", + .@"union" => "union", + .@"fn" => "function", + .@"opaque" => "opaque", + .frame => "frame", + .@"anyframe" => "anyframe", + .vector => "vector", + .enum_literal => "enum literal", }; break :blk std.fmt.format( writer, diff --git a/src/configuration.zig b/src/configuration.zig index 3f630bcc6..30c659025 100644 --- a/src/configuration.zig +++ b/src/configuration.zig @@ -194,18 +194,18 @@ pub const Configuration = getConfigurationType(); // returns a Struct which is the same as `Config` except that every field is optional. fn getConfigurationType() type { var config_info: std.builtin.Type = @typeInfo(Config); - var fields: [config_info.Struct.fields.len]std.builtin.Type.StructField = undefined; - for (config_info.Struct.fields, &fields) |field, *new_field| { + var fields: [config_info.@"struct".fields.len]std.builtin.Type.StructField = undefined; + for (config_info.@"struct".fields, &fields) |field, *new_field| { new_field.* = field; - if (@typeInfo(field.type) != .Optional) { + if (@typeInfo(field.type) != .optional) { new_field.type = @Type(std.builtin.Type{ - .Optional = .{ .child = field.type }, + .optional = .{ .child = field.type }, }); } new_field.default_value = &@as(new_field.type, null); } - config_info.Struct.fields = fields[0..]; - config_info.Struct.decls = &.{}; + config_info.@"struct".fields = fields[0..]; + config_info.@"struct".decls = &.{}; return @Type(config_info); } diff --git a/src/features/inlay_hints.zig b/src/features/inlay_hints.zig index 66065a21c..50f2297f0 100644 --- a/src/features/inlay_hints.zig +++ b/src/features/inlay_hints.zig @@ -31,6 +31,7 @@ const excluded_builtins_set = blk: { .{"bitCast"}, .{"bitOffsetOf"}, .{"bitSizeOf"}, + .{"branchHint"}, .{"breakpoint"}, // no parameters // .{"mulAdd"}, .{"byteSwap"}, @@ -96,7 +97,6 @@ const excluded_builtins_set = blk: { .{"returnAddress"}, // no parameters // .{"select"}, // .{"setAlignStack"}, - .{"setCold"}, .{"setEvalBranchQuota"}, .{"setFloatMode"}, .{"setRuntimeSafety"}, diff --git a/src/tools/langref_master.html.in b/src/tools/langref_master.html.in index 3223308d4..73ffbb0de 100644 --- a/src/tools/langref_master.html.in +++ b/src/tools/langref_master.html.in @@ -4340,6 +4340,13 @@ comptime { {#see_also|@sizeOf|@typeInfo#} {#header_close#} + {#header_open|@branchHint#} +
{#syntax#}@branchHint(hint: BranchHint) void{#endsyntax#}
+

Hints to the optimizer how likely a given branch of control flow is to be reached.

+

{#syntax#}BranchHint{#endsyntax#} can be found with {#syntax#}@import("std").builtin.BranchHint{#endsyntax#}.

+

This function is only valid as the first statement in a control flow branch, or the first statement in a function.

+ {#header_close#} + {#header_open|@breakpoint#}
{#syntax#}@breakpoint() void{#endsyntax#}

@@ -4767,23 +4774,13 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val {#header_close#} {#header_open|@export#} -

{#syntax#}@export(declaration, comptime options: std.builtin.ExportOptions) void{#endsyntax#}
-

- Creates a symbol in the output object file. -

-

- declaration must be one of two things: -

- +
{#syntax#}@export(comptime ptr: *const anyopaque, comptime options: std.builtin.ExportOptions) void{#endsyntax#}
+

Creates a symbol in the output object file which refers to the target of ptr.

+

ptr must point to a global variable or a comptime-known constant.

This builtin can be called from a {#link|comptime#} block to conditionally export symbols. - When declaration is a function with the C calling convention and - {#syntax#}options.linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to + When ptr points to a function with the C calling convention and + {#syntax#}options.linkage{#endsyntax#} is {#syntax#}.Strong{#endsyntax#}, this is equivalent to the {#syntax#}export{#endsyntax#} keyword used on a function:

{#code|export_builtin.zig#} @@ -5252,15 +5249,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val

{#header_close#} - {#header_open|@setCold#} -
{#syntax#}@setCold(comptime is_cold: bool) void{#endsyntax#}
-

- Tells the optimizer that the current function is (or is not) rarely called. - - This function is only valid within function scope. -

- {#header_close#} - {#header_open|@setEvalBranchQuota#}
{#syntax#}@setEvalBranchQuota(comptime new_quota: u32) void{#endsyntax#}

diff --git a/tests/lsp_features/completion.zig b/tests/lsp_features/completion.zig index d7971b512..1e0464d9f 100644 --- a/tests/lsp_features/completion.zig +++ b/tests/lsp_features/completion.zig @@ -3589,7 +3589,7 @@ fn extractCompletionLabels(items: anytype) error{ DuplicateCompletionLabel, OutO try set.ensureTotalCapacity(allocator, items.len); for (items) |item| { const maybe_kind = switch (@typeInfo(@TypeOf(item.kind))) { - .Optional => item.kind, + .optional => item.kind, else => @as(?@TypeOf(item.kind), item.kind), }; if (maybe_kind) |kind| {