authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-12-06 08:51:15+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-12-06 08:51:15+01:00
logdbb4c8d1514f351bbef4a6977a0b188a3c6b81dc
tree729996c74031c30dd7c721fc5bf460eb27f5207d
parentd41c16930df6fad85f2a63fec2e8e02b128cb1ed
parent39fa8319478e4843d5384e81935520be2dbbadef

Merge pull request 'Remove things deprecated during the 0.15 release cycle' (#30018) from linus/zig:remove-deprecated-stuff into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30018

30 files changed, 53 insertions(+), 711 deletions(-)

lib/compiler/aro/assembly_backend/x86_64.zig+2-2
......@@ -58,7 +58,7 @@ fn serializeFloat(comptime T: type, value: T, w: *std.Io.Writer) !void {
5858 },
5959 else => {
6060 const size = @bitSizeOf(T);
61 const storage_unit = std.meta.intToEnum(StorageUnit, size) catch unreachable;
61 const storage_unit = std.enums.fromInt(StorageUnit, size).?;
6262 const IntTy = @Int(.unsigned, size);
6363 const int_val: IntTy = @bitCast(value);
6464 return serializeInt(int_val, storage_unit, w);
......@@ -95,7 +95,7 @@ fn emitSingleValue(c: *AsmCodeGen, qt: QualType, node: Node.Index) !void {
9595 if (!scalar_kind.isReal()) {
9696 return c.todo("Codegen _Complex values", node.tok(c.tree));
9797 } else if (scalar_kind.isInt()) {
98 const storage_unit = std.meta.intToEnum(StorageUnit, bit_size) catch return c.todo("Codegen _BitInt values", node.tok(c.tree));
98 const storage_unit = std.enums.fromInt(StorageUnit, bit_size) orelse return c.todo("Codegen _BitInt values", node.tok(c.tree));
9999 try c.data.print(" .{s} ", .{@tagName(storage_unit)});
100100 _ = try value.print(qt, c.comp, c.data);
101101 try c.data.writeByte('\n');
lib/compiler/reduce/Walk.zig-9
......@@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
501501 .@"asm",
502502 => return walkAsm(w, ast.fullAsm(node).?),
503503
504 .asm_legacy => {
505 return walkAsmLegacy(w, ast.legacyAsm(node).?);
506 },
507
508504 .enum_literal => {
509505 return walkIdentifier(w, ast.nodeMainToken(node)); // name
510506 },
......@@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void {
881877 try walkExpressions(w, asm_node.ast.items);
882878}
883879
884fn walkAsmLegacy(w: *Walk, asm_node: Ast.full.AsmLegacy) Error!void {
885 try walkExpression(w, asm_node.ast.template);
886 try walkExpressions(w, asm_node.ast.items);
887}
888
889880/// Check if it is already gutted (i.e. its body replaced with `@trap()`).
890881fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool {
891882 // skip over discards
lib/docs/wasm/Walk.zig-2
......@@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
791791 try expr(w, scope, parent_decl, full.ast.template);
792792 },
793793
794 .asm_legacy => {},
795
796794 .builtin_call_two,
797795 .builtin_call_two_comma,
798796 .builtin_call,
lib/docs/wasm/markdown.zig+1-1
......@@ -149,7 +149,7 @@ fn mainImpl() !void {
149149 var stdin_reader = std.fs.File.stdin().reader(&stdin_buffer);
150150
151151 while (stdin_reader.takeDelimiterExclusive('\n')) |line| {
152 const trimmed = std.mem.trimRight(u8, line, '\r');
152 const trimmed = std.mem.trimEnd(u8, line, '\r');
153153 try parser.feedLine(trimmed);
154154 } else |err| switch (err) {
155155 error.EndOfStream => {},
lib/std/Build/Step/Compile.zig+2-135
......@@ -188,9 +188,6 @@ force_undefined_symbols: std.StringHashMap(void),
188188/// Overrides the default stack size
189189stack_size: ?u64 = null,
190190
191/// Deprecated; prefer using `lto`.
192want_lto: ?bool = null,
193
194191use_llvm: ?bool,
195192use_lld: ?bool,
196193use_new_linker: ?bool,
......@@ -540,7 +537,7 @@ pub fn installHeadersDirectory(
540537/// When a module links with this artifact, all headers marked for installation are added to that
541538/// module's include search path.
542539pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void {
543 cs.installHeader(config_header.getOutput(), config_header.include_path);
540 cs.installHeader(config_header.getOutputFile(), config_header.include_path);
544541}
545542
546543/// Forwards all headers marked for installation from `lib` to this artifact.
......@@ -683,18 +680,6 @@ pub fn producesImplib(compile: *Compile) bool {
683680 return compile.isDll();
684681}
685682
686/// Deprecated; use `compile.root_module.link_libc = true` instead.
687/// To be removed after 0.15.0 is tagged.
688pub fn linkLibC(compile: *Compile) void {
689 compile.root_module.link_libc = true;
690}
691
692/// Deprecated; use `compile.root_module.link_libcpp = true` instead.
693/// To be removed after 0.15.0 is tagged.
694pub fn linkLibCpp(compile: *Compile) void {
695 compile.root_module.link_libcpp = true;
696}
697
698683const PkgConfigResult = struct {
699684 cflags: []const []const u8,
700685 libs: []const []const u8,
......@@ -808,46 +793,6 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
808793 };
809794}
810795
811/// Deprecated; use `compile.root_module.linkSystemLibrary(name, .{})` instead.
812/// To be removed after 0.15.0 is tagged.
813pub fn linkSystemLibrary(compile: *Compile, name: []const u8) void {
814 return compile.root_module.linkSystemLibrary(name, .{});
815}
816
817/// Deprecated; use `compile.root_module.linkSystemLibrary(name, options)` instead.
818/// To be removed after 0.15.0 is tagged.
819pub fn linkSystemLibrary2(
820 compile: *Compile,
821 name: []const u8,
822 options: Module.LinkSystemLibraryOptions,
823) void {
824 return compile.root_module.linkSystemLibrary(name, options);
825}
826
827/// Deprecated; use `c.root_module.linkFramework(name, .{})` instead.
828/// To be removed after 0.15.0 is tagged.
829pub fn linkFramework(c: *Compile, name: []const u8) void {
830 c.root_module.linkFramework(name, .{});
831}
832
833/// Deprecated; use `compile.root_module.addCSourceFiles(options)` instead.
834/// To be removed after 0.15.0 is tagged.
835pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void {
836 compile.root_module.addCSourceFiles(options);
837}
838
839/// Deprecated; use `compile.root_module.addCSourceFile(source)` instead.
840/// To be removed after 0.15.0 is tagged.
841pub fn addCSourceFile(compile: *Compile, source: Module.CSourceFile) void {
842 compile.root_module.addCSourceFile(source);
843}
844
845/// Deprecated; use `compile.root_module.addWin32ResourceFile(source)` instead.
846/// To be removed after 0.15.0 is tagged.
847pub fn addWin32ResourceFile(compile: *Compile, source: Module.RcSourceFile) void {
848 compile.root_module.addWin32ResourceFile(source);
849}
850
851796pub fn setVerboseLink(compile: *Compile, value: bool) void {
852797 compile.verbose_link = value;
853798}
......@@ -929,84 +874,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath {
929874 return compile.getEmittedFileGeneric(&compile.generated_llvm_bc);
930875}
931876
932/// Deprecated; use `compile.root_module.addAssemblyFile(source)` instead.
933/// To be removed after 0.15.0 is tagged.
934pub fn addAssemblyFile(compile: *Compile, source: LazyPath) void {
935 compile.root_module.addAssemblyFile(source);
936}
937
938/// Deprecated; use `compile.root_module.addObjectFile(source)` instead.
939/// To be removed after 0.15.0 is tagged.
940pub fn addObjectFile(compile: *Compile, source: LazyPath) void {
941 compile.root_module.addObjectFile(source);
942}
943
944/// Deprecated; use `compile.root_module.addObject(object)` instead.
945/// To be removed after 0.15.0 is tagged.
946pub fn addObject(compile: *Compile, object: *Compile) void {
947 compile.root_module.addObject(object);
948}
949
950/// Deprecated; use `compile.root_module.linkLibrary(library)` instead.
951/// To be removed after 0.15.0 is tagged.
952pub fn linkLibrary(compile: *Compile, library: *Compile) void {
953 compile.root_module.linkLibrary(library);
954}
955
956/// Deprecated; use `compile.root_module.addAfterIncludePath(lazy_path)` instead.
957/// To be removed after 0.15.0 is tagged.
958pub fn addAfterIncludePath(compile: *Compile, lazy_path: LazyPath) void {
959 compile.root_module.addAfterIncludePath(lazy_path);
960}
961
962/// Deprecated; use `compile.root_module.addSystemIncludePath(lazy_path)` instead.
963/// To be removed after 0.15.0 is tagged.
964pub fn addSystemIncludePath(compile: *Compile, lazy_path: LazyPath) void {
965 compile.root_module.addSystemIncludePath(lazy_path);
966}
967
968/// Deprecated; use `compile.root_module.addIncludePath(lazy_path)` instead.
969/// To be removed after 0.15.0 is tagged.
970pub fn addIncludePath(compile: *Compile, lazy_path: LazyPath) void {
971 compile.root_module.addIncludePath(lazy_path);
972}
973
974/// Deprecated; use `compile.root_module.addConfigHeader(config_header)` instead.
975/// To be removed after 0.15.0 is tagged.
976pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) void {
977 compile.root_module.addConfigHeader(config_header);
978}
979
980/// Deprecated; use `compile.root_module.addEmbedPath(lazy_path)` instead.
981/// To be removed after 0.15.0 is tagged.
982pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void {
983 compile.root_module.addEmbedPath(lazy_path);
984}
985
986/// Deprecated; use `compile.root_module.addLibraryPath(directory_path)` instead.
987/// To be removed after 0.15.0 is tagged.
988pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void {
989 compile.root_module.addLibraryPath(directory_path);
990}
991
992/// Deprecated; use `compile.root_module.addRPath(directory_path)` instead.
993/// To be removed after 0.15.0 is tagged.
994pub fn addRPath(compile: *Compile, directory_path: LazyPath) void {
995 compile.root_module.addRPath(directory_path);
996}
997
998/// Deprecated; use `compile.root_module.addSystemFrameworkPath(directory_path)` instead.
999/// To be removed after 0.15.0 is tagged.
1000pub fn addSystemFrameworkPath(compile: *Compile, directory_path: LazyPath) void {
1001 compile.root_module.addSystemFrameworkPath(directory_path);
1002}
1003
1004/// Deprecated; use `compile.root_module.addFrameworkPath(directory_path)` instead.
1005/// To be removed after 0.15.0 is tagged.
1006pub fn addFrameworkPath(compile: *Compile, directory_path: LazyPath) void {
1007 compile.root_module.addFrameworkPath(directory_path);
1008}
1009
1010877pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void {
1011878 const b = compile.step.owner;
1012879 assert(compile.kind == .@"test");
......@@ -1763,7 +1630,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
17631630 .thin => "-flto=thin",
17641631 .none => "-fno-lto",
17651632 });
1766 } else try addFlag(&zig_args, "lto", compile.want_lto);
1633 }
17671634
17681635 try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard);
17691636
lib/std/Build/Step/ConfigHeader.zig-3
......@@ -124,9 +124,6 @@ pub fn getOutputFile(ch: *ConfigHeader) std.Build.LazyPath {
124124 return ch.getOutputDir().path(ch.step.owner, ch.include_path);
125125}
126126
127/// Deprecated; use `getOutputFile`.
128pub const getOutput = getOutputFile;
129
130127fn addValueInner(config_header: *ConfigHeader, name: []const u8, comptime T: type, value: T) !void {
131128 switch (@typeInfo(T)) {
132129 .null => {
lib/std/Build/Step/Run.zig-5
......@@ -88,9 +88,6 @@ skip_foreign_checks: bool,
8888/// external executor (such as qemu) but not fail if the executor is unavailable.
8989failing_to_execute_foreign_is_an_error: bool,
9090
91/// Deprecated in favor of `stdio_limit`.
92max_stdio_size: usize,
93
9491/// If stderr or stdout exceeds this amount, the child process is killed and
9592/// the step fails.
9693stdio_limit: std.Io.Limit,
......@@ -223,7 +220,6 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {
223220 .rename_step_with_output_arg = true,
224221 .skip_foreign_checks = false,
225222 .failing_to_execute_foreign_is_an_error = true,
226 .max_stdio_size = 10 * 1024 * 1024,
227223 .stdio_limit = .unlimited,
228224 .captured_stdout = null,
229225 .captured_stderr = null,
......@@ -2217,7 +2213,6 @@ fn evalGeneric(run: *Run, child: *std.process.Child) !EvalGenericResult {
22172213 var stdout_bytes: ?[]const u8 = null;
22182214 var stderr_bytes: ?[]const u8 = null;
22192215
2220 run.stdio_limit = run.stdio_limit.min(.limited(run.max_stdio_size));
22212216 if (child.stdout) |stdout| {
22222217 if (child.stderr) |stderr| {
22232218 var poller = std.Io.poll(arena, enum { stdout, stderr }, .{
lib/std/Io/Reader.zig+1-1
......@@ -1252,7 +1252,7 @@ pub const TakeEnumError = Error || error{InvalidEnumTag};
12521252pub fn takeEnum(r: *Reader, comptime Enum: type, endian: std.builtin.Endian) TakeEnumError!Enum {
12531253 const Tag = @typeInfo(Enum).@"enum".tag_type;
12541254 const int = try r.takeInt(Tag, endian);
1255 return std.meta.intToEnum(Enum, int);
1255 return std.enums.fromInt(Enum, int) orelse return error.InvalidEnumTag;
12561256}
12571257
12581258/// Reads an integer with the same size as the given nonexhaustive enum's tag type.
lib/std/Io/Writer.zig+1-5
......@@ -1211,10 +1211,6 @@ pub fn printValue(
12111211 }
12121212
12131213 const is_any = comptime std.mem.eql(u8, fmt, ANY);
1214 if (!is_any and std.meta.hasMethod(T, "format") and fmt.len == 0) {
1215 // after 0.15.0 is tagged, delete this compile error and its condition
1216 @compileError("ambiguous format string; specify {f} to call format method, or {any} to skip it");
1217 }
12181214
12191215 switch (@typeInfo(T)) {
12201216 .float, .comptime_float => {
......@@ -1702,7 +1698,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi
17021698
17031699 try w.writeAll("0x");
17041700 try w.writeByte(buf[0]);
1705 const trimmed = std.mem.trimRight(u8, buf[1..], "0");
1701 const trimmed = std.mem.trimEnd(u8, buf[1..], "0");
17061702 if (opt_precision) |precision| {
17071703 if (precision > 0) try w.writeAll(".");
17081704 } else if (trimmed.len > 0) {
lib/std/Io/tty.zig-5
......@@ -5,11 +5,6 @@ const process = std.process;
55const windows = std.os.windows;
66const native_os = builtin.os.tag;
77
8/// Deprecated in favor of `Config.detect`.
9pub fn detectConfig(file: File) Config {
10 return .detect(file);
11}
12
138pub const Color = enum {
149 black,
1510 red,
lib/std/crypto/tls/Client.zig+1-1
......@@ -1158,7 +1158,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
11581158 P.AEAD.decrypt(cleartext, ciphertext, auth_tag, ad, nonce, pv.server_key) catch
11591159 return failRead(c, error.TlsBadRecordMac);
11601160 // TODO use scalar, non-slice version
1161 const msg = mem.trimRight(u8, cleartext, "\x00");
1161 const msg = mem.trimEnd(u8, cleartext, "\x00");
11621162 break :cleartext .{ msg.len - 1, @enumFromInt(msg[msg.len - 1]) };
11631163 },
11641164 .tls_1_2 => {
lib/std/debug.zig+4-4
......@@ -329,16 +329,16 @@ pub fn dumpHex(bytes: []const u8) void {
329329}
330330
331331/// Prints a hexadecimal view of the bytes, returning any error that occurs.
332pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !void {
332pub fn dumpHexFallible(bw: *Writer, tty_config: tty.Config, bytes: []const u8) !void {
333333 var chunks = mem.window(u8, bytes, 16, 16);
334334 while (chunks.next()) |window| {
335335 // 1. Print the address.
336336 const address = (@intFromPtr(bytes.ptr) + 0x10 * (std.math.divCeil(usize, chunks.index orelse bytes.len, 16) catch unreachable)) - 0x10;
337 try ttyconf.setColor(bw, .dim);
337 try tty_config.setColor(bw, .dim);
338338 // We print the address in lowercase and the bytes in uppercase hexadecimal to distinguish them more.
339339 // Also, make sure all lines are aligned by padding the address.
340340 try bw.print("{x:0>[1]} ", .{ address, @sizeOf(usize) * 2 });
341 try ttyconf.setColor(bw, .reset);
341 try tty_config.setColor(bw, .reset);
342342
343343 // 2. Print the bytes.
344344 for (window, 0..) |byte, index| {
......@@ -358,7 +358,7 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !voi
358358 try bw.writeByte(byte);
359359 } else {
360360 // Related: https://github.com/ziglang/zig/issues/7600
361 if (ttyconf == .windows_api) {
361 if (tty_config == .windows_api) {
362362 try bw.writeByte('.');
363363 continue;
364364 }
lib/std/enums.zig-42
......@@ -202,48 +202,6 @@ test "directEnumArrayDefault slice" {
202202 try testing.expectEqualSlices(u8, "default", array[2]);
203203}
204204
205/// Deprecated: Use @field(E, @tagName(tag)) or @field(E, string)
206pub fn nameCast(comptime E: type, comptime value: anytype) E {
207 return comptime blk: {
208 const V = @TypeOf(value);
209 if (V == E) break :blk value;
210 const name: ?[]const u8 = switch (@typeInfo(V)) {
211 .enum_literal, .@"enum" => @tagName(value),
212 .pointer => value,
213 else => null,
214 };
215 if (name) |n| {
216 if (@hasField(E, n)) {
217 break :blk @field(E, n);
218 }
219 @compileError("Enum " ++ @typeName(E) ++ " has no field named " ++ n);
220 }
221 @compileError("Cannot cast from " ++ @typeName(@TypeOf(value)) ++ " to " ++ @typeName(E));
222 };
223}
224
225test nameCast {
226 const A = enum(u1) { a = 0, b = 1 };
227 const B = enum(u1) { a = 1, b = 0 };
228 try testing.expectEqual(A.a, nameCast(A, .a));
229 try testing.expectEqual(A.a, nameCast(A, A.a));
230 try testing.expectEqual(A.a, nameCast(A, B.a));
231 try testing.expectEqual(A.a, nameCast(A, "a"));
232 try testing.expectEqual(A.a, nameCast(A, @as(*const [1]u8, "a")));
233 try testing.expectEqual(A.a, nameCast(A, @as([:0]const u8, "a")));
234 try testing.expectEqual(A.a, nameCast(A, @as([]const u8, "a")));
235
236 try testing.expectEqual(B.a, nameCast(B, .a));
237 try testing.expectEqual(B.a, nameCast(B, A.a));
238 try testing.expectEqual(B.a, nameCast(B, B.a));
239 try testing.expectEqual(B.a, nameCast(B, "a"));
240
241 try testing.expectEqual(B.b, nameCast(B, .b));
242 try testing.expectEqual(B.b, nameCast(B, A.b));
243 try testing.expectEqual(B.b, nameCast(B, B.b));
244 try testing.expectEqual(B.b, nameCast(B, "b"));
245}
246
247205test fromInt {
248206 const E1 = enum {
249207 A,
lib/std/heap/debug_allocator.zig+8-8
......@@ -460,7 +460,7 @@ pub fn DebugAllocator(comptime config: Config) type {
460460 pub fn detectLeaks(self: *Self) usize {
461461 var leaks: usize = 0;
462462
463 const tty_config = std.Io.tty.detectConfig(.stderr());
463 const tty_config: std.Io.tty.Config = .detect(.stderr());
464464
465465 for (self.buckets, 0..) |init_optional_bucket, size_class_index| {
466466 var optional_bucket = init_optional_bucket;
......@@ -536,7 +536,7 @@ pub fn DebugAllocator(comptime config: Config) type {
536536 fn reportDoubleFree(ret_addr: usize, alloc_stack_trace: StackTrace, free_stack_trace: StackTrace) void {
537537 var addr_buf: [stack_n]usize = undefined;
538538 const second_free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf);
539 const tty_config = std.Io.tty.detectConfig(.stderr());
539 const tty_config: std.Io.tty.Config = .detect(.stderr());
540540 log.err("Double free detected. Allocation: {f} First free: {f} Second free: {f}", .{
541541 std.debug.FormatStackTrace{
542542 .stack_trace = alloc_stack_trace,
......@@ -590,7 +590,7 @@ pub fn DebugAllocator(comptime config: Config) type {
590590 if (config.safety and old_mem.len != entry.value_ptr.bytes.len) {
591591 var addr_buf: [stack_n]usize = undefined;
592592 const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf);
593 const tty_config = std.Io.tty.detectConfig(.stderr());
593 const tty_config: std.Io.tty.Config = .detect(.stderr());
594594 log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{
595595 entry.value_ptr.bytes.len,
596596 old_mem.len,
......@@ -703,7 +703,7 @@ pub fn DebugAllocator(comptime config: Config) type {
703703 if (config.safety and old_mem.len != entry.value_ptr.bytes.len) {
704704 var addr_buf: [stack_n]usize = undefined;
705705 const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf);
706 const tty_config = std.Io.tty.detectConfig(.stderr());
706 const tty_config: std.Io.tty.Config = .detect(.stderr());
707707 log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{
708708 entry.value_ptr.bytes.len,
709709 old_mem.len,
......@@ -935,7 +935,7 @@ pub fn DebugAllocator(comptime config: Config) type {
935935 var addr_buf: [stack_n]usize = undefined;
936936 const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf);
937937 if (old_memory.len != requested_size) {
938 const tty_config = std.Io.tty.detectConfig(.stderr());
938 const tty_config: std.Io.tty.Config = .detect(.stderr());
939939 log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{
940940 requested_size,
941941 old_memory.len,
......@@ -950,7 +950,7 @@ pub fn DebugAllocator(comptime config: Config) type {
950950 });
951951 }
952952 if (alignment != slot_alignment) {
953 const tty_config = std.Io.tty.detectConfig(.stderr());
953 const tty_config: std.Io.tty.Config = .detect(.stderr());
954954 log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{
955955 slot_alignment.toByteUnits(),
956956 alignment.toByteUnits(),
......@@ -1044,7 +1044,7 @@ pub fn DebugAllocator(comptime config: Config) type {
10441044 var addr_buf: [stack_n]usize = undefined;
10451045 const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf);
10461046 if (memory.len != requested_size) {
1047 const tty_config = std.Io.tty.detectConfig(.stderr());
1047 const tty_config: std.Io.tty.Config = .detect(.stderr());
10481048 log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{
10491049 requested_size,
10501050 memory.len,
......@@ -1059,7 +1059,7 @@ pub fn DebugAllocator(comptime config: Config) type {
10591059 });
10601060 }
10611061 if (alignment != slot_alignment) {
1062 const tty_config = std.Io.tty.detectConfig(.stderr());
1062 const tty_config: std.Io.tty.Config = .detect(.stderr());
10631063 log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{
10641064 slot_alignment.toByteUnits(),
10651065 alignment.toByteUnits(),
lib/std/http/Client.zig+1-1
......@@ -529,7 +529,7 @@ pub const Response = struct {
529529 };
530530 if (first_line[8] != ' ') return error.HttpHeadersInvalid;
531531 const status: http.Status = @enumFromInt(parseInt3(first_line[9..12]));
532 const reason = mem.trimLeft(u8, first_line[12..], " ");
532 const reason = mem.trimStart(u8, first_line[12..], " ");
533533
534534 res.version = version;
535535 res.status = status;
lib/std/mem.zig-6
......@@ -1221,9 +1221,6 @@ test trimStart {
12211221 try testing.expectEqualSlices(u8, "foo\n ", trimStart(u8, " foo\n ", " \n"));
12221222}
12231223
1224/// Deprecated: use `trimStart` instead.
1225pub const trimLeft = trimStart;
1226
12271224/// Remove a set of values from the end of a slice.
12281225pub fn trimEnd(comptime T: type, slice: []const T, values_to_strip: []const T) []const T {
12291226 var end: usize = slice.len;
......@@ -1235,9 +1232,6 @@ test trimEnd {
12351232 try testing.expectEqualSlices(u8, " foo", trimEnd(u8, " foo\n ", " \n"));
12361233}
12371234
1238/// Deprecated: use `trimEnd` instead.
1239pub const trimRight = trimEnd;
1240
12411235/// Remove a set of values from the beginning and end of a slice.
12421236pub fn trim(comptime T: type, slice: []const T, values_to_strip: []const T) []const T {
12431237 var begin: usize = 0;
lib/std/meta.zig-40
......@@ -614,38 +614,6 @@ test activeTag {
614614 try testing.expect(activeTag(u) == UE.Float);
615615}
616616
617/// Deprecated: Use @FieldType(U, tag_name)
618const TagPayloadType = TagPayload;
619
620/// Deprecated: Use @FieldType(U, tag_name)
621pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
622 const info = @typeInfo(U).@"union";
623
624 inline for (info.fields) |field_info| {
625 if (comptime mem.eql(u8, field_info.name, tag_name))
626 return field_info.type;
627 }
628
629 @compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'");
630}
631
632/// Deprecated: Use @FieldType(U, @tagName(tag))
633pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
634 return TagPayloadByName(U, @tagName(tag));
635}
636
637test TagPayload {
638 const Event = union(enum) {
639 Moved: struct {
640 from: i32,
641 to: i32,
642 },
643 };
644 const MovedEvent = TagPayload(Event, Event.Moved);
645 const e: Event = .{ .Moved = undefined };
646 try testing.expect(MovedEvent == @TypeOf(e.Moved));
647}
648
649617/// Compares two of any type for equality. Containers that do not support comparison
650618/// on their own are compared on a field-by-field basis. Pointers are not followed.
651619pub fn eql(a: anytype, b: @TypeOf(a)) bool {
......@@ -774,14 +742,6 @@ test eql {
774742 try testing.expect(!eql(v1, v3));
775743}
776744
777/// Deprecated: use `std.enums.fromInt` instead and handle null.
778pub const IntToEnumError = error{InvalidEnumTag};
779
780/// Deprecated: use `std.enums.fromInt` instead and handle null instead of an error.
781pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag {
782 return std.enums.fromInt(EnumTag, tag_int) orelse return error.InvalidEnumTag;
783}
784
785745/// Given a type and a name, return the field index according to source order.
786746/// Returns `null` if the field is not found.
787747pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
lib/std/os/linux/test.zig+7-7
......@@ -138,23 +138,23 @@ test "sigset_t" {
138138 // See that none are set, then set each one, see that they're all set, then
139139 // remove them all, and then see that none are set.
140140 for (1..linux.NSIG) |i| {
141 const sig = std.meta.intToEnum(SIG, i) catch continue;
141 const sig = std.enums.fromInt(SIG, i) orelse continue;
142142 try expectEqual(false, linux.sigismember(&sigset, sig));
143143 }
144144 for (1..linux.NSIG) |i| {
145 const sig = std.meta.intToEnum(SIG, i) catch continue;
145 const sig = std.enums.fromInt(SIG, i) orelse continue;
146146 linux.sigaddset(&sigset, sig);
147147 }
148148 for (1..linux.NSIG) |i| {
149 const sig = std.meta.intToEnum(SIG, i) catch continue;
149 const sig = std.enums.fromInt(SIG, i) orelse continue;
150150 try expectEqual(true, linux.sigismember(&sigset, sig));
151151 }
152152 for (1..linux.NSIG) |i| {
153 const sig = std.meta.intToEnum(SIG, i) catch continue;
153 const sig = std.enums.fromInt(SIG, i) orelse continue;
154154 linux.sigdelset(&sigset, sig);
155155 }
156156 for (1..linux.NSIG) |i| {
157 const sig = std.meta.intToEnum(SIG, i) catch continue;
157 const sig = std.enums.fromInt(SIG, i) orelse continue;
158158 try expectEqual(false, linux.sigismember(&sigset, sig));
159159 }
160160}
......@@ -163,7 +163,7 @@ test "sigfillset" {
163163 // unlike the C library, all the signals are set in the kernel-level fillset
164164 const sigset = linux.sigfillset();
165165 for (1..linux.NSIG) |i| {
166 const sig = std.meta.intToEnum(linux.SIG, i) catch continue;
166 const sig = std.enums.fromInt(linux.SIG, i) orelse continue;
167167 try expectEqual(true, linux.sigismember(&sigset, sig));
168168 }
169169}
......@@ -171,7 +171,7 @@ test "sigfillset" {
171171test "sigemptyset" {
172172 const sigset = linux.sigemptyset();
173173 for (1..linux.NSIG) |i| {
174 const sig = std.meta.intToEnum(linux.SIG, i) catch continue;
174 const sig = std.enums.fromInt(linux.SIG, i) orelse continue;
175175 try expectEqual(false, linux.sigismember(&sigset, sig));
176176 }
177177}
lib/std/os/uefi/protocol/ip6_config.zig+3-3
......@@ -44,7 +44,7 @@ pub const Ip6Config = extern struct {
4444 pub fn setData(
4545 self: *const Ip6Config,
4646 comptime data_type: std.meta.Tag(DataType),
47 payload: *const std.meta.TagPayload(DataType, data_type),
47 payload: *const @FieldType(DataType, @tagName(data_type)),
4848 ) SetDataError!void {
4949 const data_size = @sizeOf(@TypeOf(payload));
5050 switch (self._set_data(self, data_type, data_size, @ptrCast(payload))) {
......@@ -64,8 +64,8 @@ pub const Ip6Config = extern struct {
6464 pub fn getData(
6565 self: *const Ip6Config,
6666 comptime data_type: std.meta.Tag(DataType),
67 ) GetDataError!std.meta.TagPayload(DataType, data_type) {
68 const DataPayload = std.meta.TagPayload(DataType, data_type);
67 ) GetDataError!@FieldType(DataType, @tagName(data_type)) {
68 const DataPayload = @FieldType(DataType, @tagName(data_type));
6969
7070 var payload: DataPayload = undefined;
7171 var payload_size: usize = @sizeOf(DataPayload);
lib/std/posix/test.zig+6-6
......@@ -536,7 +536,7 @@ test "sigset empty/full" {
536536
537537 var set: posix.sigset_t = posix.sigemptyset();
538538 for (1..posix.NSIG) |i| {
539 const sig = std.meta.intToEnum(posix.SIG, i) catch continue;
539 const sig = std.enums.fromInt(posix.SIG, i) orelse continue;
540540 try expectEqual(false, posix.sigismember(&set, sig));
541541 }
542542
......@@ -565,29 +565,29 @@ test "sigset add/del" {
565565 // See that none are set, then set each one, see that they're all set, then
566566 // remove them all, and then see that none are set.
567567 for (1..posix.NSIG) |i| {
568 const sig = std.meta.intToEnum(posix.SIG, i) catch continue;
568 const sig = std.enums.fromInt(posix.SIG, i) orelse continue;
569569 try expectEqual(false, posix.sigismember(&sigset, sig));
570570 }
571571 for (1..posix.NSIG) |i| {
572572 if (!reserved_signo(i)) {
573 const sig = std.meta.intToEnum(posix.SIG, i) catch continue;
573 const sig = std.enums.fromInt(posix.SIG, i) orelse continue;
574574 posix.sigaddset(&sigset, sig);
575575 }
576576 }
577577 for (1..posix.NSIG) |i| {
578578 if (!reserved_signo(i)) {
579 const sig = std.meta.intToEnum(posix.SIG, i) catch continue;
579 const sig = std.enums.fromInt(posix.SIG, i) orelse continue;
580580 try expectEqual(true, posix.sigismember(&sigset, sig));
581581 }
582582 }
583583 for (1..posix.NSIG) |i| {
584584 if (!reserved_signo(i)) {
585 const sig = std.meta.intToEnum(posix.SIG, i) catch continue;
585 const sig = std.enums.fromInt(posix.SIG, i) orelse continue;
586586 posix.sigdelset(&sigset, sig);
587587 }
588588 }
589589 for (1..posix.NSIG) |i| {
590 const sig = std.meta.intToEnum(posix.SIG, i) catch continue;
590 const sig = std.enums.fromInt(posix.SIG, i) orelse continue;
591591 try expectEqual(false, posix.sigismember(&sigset, sig));
592592 }
593593}
lib/std/testing.zig+1-1
......@@ -1160,7 +1160,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
11601160 } else |err| switch (err) {
11611161 error.OutOfMemory => {
11621162 if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) {
1163 const tty_config = std.Io.tty.detectConfig(.stderr());
1163 const tty_config: std.Io.tty.Config = .detect(.stderr());
11641164 print(
11651165 "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {f}",
11661166 .{
lib/std/zig/Ast.zig-118
......@@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
636636 .@"nosuspend",
637637 .asm_simple,
638638 .@"asm",
639 .asm_legacy,
640639 .array_type,
641640 .array_type_sentinel,
642641 .error_value,
......@@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
10501049 n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter
10511050 }
10521051 },
1053 .asm_legacy => {
1054 _, const extra_index = tree.nodeData(n).node_and_extra;
1055 const extra = tree.extraData(extra_index, Node.AsmLegacy);
1056 return extra.rparen + end_offset;
1057 },
10581052 .@"asm" => {
10591053 _, const extra_index = tree.nodeData(n).node_and_extra;
10601054 const extra = tree.extraData(extra_index, Node.Asm);
......@@ -1900,18 +1894,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm {
19001894 });
19011895}
19021896
1903pub fn asmLegacy(tree: Ast, node: Node.Index) full.AsmLegacy {
1904 const template, const extra_index = tree.nodeData(node).node_and_extra;
1905 const extra = tree.extraData(extra_index, Node.AsmLegacy);
1906 const items = tree.extraDataSlice(.{ .start = extra.items_start, .end = extra.items_end }, Node.Index);
1907 return tree.legacyAsmComponents(.{
1908 .asm_token = tree.nodeMainToken(node),
1909 .template = template,
1910 .items = items,
1911 .rparen = extra.rparen,
1912 });
1913}
1914
19151897pub fn asmFull(tree: Ast, node: Node.Index) full.Asm {
19161898 const template, const extra_index = tree.nodeData(node).node_and_extra;
19171899 const extra = tree.extraData(extra_index, Node.Asm);
......@@ -2217,67 +2199,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N
22172199 return result;
22182200}
22192201
2220fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy {
2221 var result: full.AsmLegacy = .{
2222 .ast = info,
2223 .volatile_token = null,
2224 .inputs = &.{},
2225 .outputs = &.{},
2226 .first_clobber = null,
2227 };
2228 if (tree.tokenTag(info.asm_token + 1) == .keyword_volatile) {
2229 result.volatile_token = info.asm_token + 1;
2230 }
2231 const outputs_end: usize = for (info.items, 0..) |item, i| {
2232 switch (tree.nodeTag(item)) {
2233 .asm_output => continue,
2234 else => break i,
2235 }
2236 } else info.items.len;
2237
2238 result.outputs = info.items[0..outputs_end];
2239 result.inputs = info.items[outputs_end..];
2240
2241 if (info.items.len == 0) {
2242 // asm ("foo" ::: "a", "b");
2243 const template_token = tree.lastToken(info.template);
2244 if (tree.tokenTag(template_token + 1) == .colon and
2245 tree.tokenTag(template_token + 2) == .colon and
2246 tree.tokenTag(template_token + 3) == .colon and
2247 tree.tokenTag(template_token + 4) == .string_literal)
2248 {
2249 result.first_clobber = template_token + 4;
2250 }
2251 } else if (result.inputs.len != 0) {
2252 // asm ("foo" :: [_] "" (y) : "a", "b");
2253 const last_input = result.inputs[result.inputs.len - 1];
2254 const rparen = tree.lastToken(last_input);
2255 var i = rparen + 1;
2256 // Allow a (useless) comma right after the closing parenthesis.
2257 if (tree.tokenTag(i) == .comma) i = i + 1;
2258 if (tree.tokenTag(i) == .colon and
2259 tree.tokenTag(i + 1) == .string_literal)
2260 {
2261 result.first_clobber = i + 1;
2262 }
2263 } else {
2264 // asm ("foo" : [_] "" (x) :: "a", "b");
2265 const last_output = result.outputs[result.outputs.len - 1];
2266 const rparen = tree.lastToken(last_output);
2267 var i = rparen + 1;
2268 // Allow a (useless) comma right after the closing parenthesis.
2269 if (tree.tokenTag(i) == .comma) i = i + 1;
2270 if (tree.tokenTag(i) == .colon and
2271 tree.tokenTag(i + 1) == .colon and
2272 tree.tokenTag(i + 2) == .string_literal)
2273 {
2274 result.first_clobber = i + 2;
2275 }
2276 }
2277
2278 return result;
2279}
2280
22812202fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm {
22822203 var result: full.Asm = .{
22832204 .ast = info,
......@@ -2495,14 +2416,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm {
24952416 };
24962417}
24972418
2498/// To be deleted after 0.15.0 is tagged
2499pub fn legacyAsm(tree: Ast, node: Node.Index) ?full.AsmLegacy {
2500 return switch (tree.nodeTag(node)) {
2501 .asm_legacy => tree.asmLegacy(node),
2502 else => null,
2503 };
2504}
2505
25062419pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call {
25072420 return switch (tree.nodeTag(node)) {
25082421 .call, .call_comma => tree.callFull(node),
......@@ -2897,21 +2810,6 @@ pub const full = struct {
28972810 };
28982811 };
28992812
2900 pub const AsmLegacy = struct {
2901 ast: Components,
2902 volatile_token: ?TokenIndex,
2903 first_clobber: ?TokenIndex,
2904 outputs: []const Node.Index,
2905 inputs: []const Node.Index,
2906
2907 pub const Components = struct {
2908 asm_token: TokenIndex,
2909 template: Node.Index,
2910 items: []const Node.Index,
2911 rparen: TokenIndex,
2912 };
2913 };
2914
29152813 pub const Call = struct {
29162814 ast: Components,
29172815
......@@ -3908,14 +3806,6 @@ pub const Node = struct {
39083806 ///
39093807 /// The `main_token` field is the `asm` token.
39103808 asm_simple,
3911 /// `asm(lhs, a)`.
3912 ///
3913 /// The `data` field is a `.node_and_extra`:
3914 /// 1. a `Node.Index` to lhs.
3915 /// 2. a `ExtraIndex` to `AsmLegacy`.
3916 ///
3917 /// The `main_token` field is the `asm` token.
3918 asm_legacy,
39193809 /// `asm(a, b)`.
39203810 ///
39213811 /// The `data` field is a `.node_and_extra`:
......@@ -4092,14 +3982,6 @@ pub const Node = struct {
40923982 callconv_expr: OptionalIndex,
40933983 };
40943984
4095 /// To be removed after 0.15.0 is tagged
4096 pub const AsmLegacy = struct {
4097 items_start: ExtraIndex,
4098 items_end: ExtraIndex,
4099 /// Needed to make lastToken() work.
4100 rparen: TokenIndex,
4101 };
4102
41033985 pub const Asm = struct {
41043986 items_start: ExtraIndex,
41053987 items_end: ExtraIndex,
lib/std/zig/Ast/Render.zig-182
......@@ -896,9 +896,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
896896 .@"asm",
897897 => return renderAsm(r, tree.fullAsm(node).?, space),
898898
899 // To be removed after 0.15.0 is tagged
900 .asm_legacy => return renderAsmLegacy(r, tree.legacyAsm(node).?, space),
901
902899 .enum_literal => {
903900 try renderToken(r, tree.nodeMainToken(node) - 1, .none); // .
904901 return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name
......@@ -2413,185 +2410,6 @@ fn renderContainerDecl(
24132410 return renderToken(r, rbrace, space); // rbrace
24142411}
24152412
2416fn renderAsmLegacy(
2417 r: *Render,
2418 asm_node: Ast.full.AsmLegacy,
2419 space: Space,
2420) Error!void {
2421 const tree = r.tree;
2422 const ais = r.ais;
2423
2424 try renderToken(r, asm_node.ast.asm_token, .space); // asm
2425
2426 if (asm_node.volatile_token) |volatile_token| {
2427 try renderToken(r, volatile_token, .space); // volatile
2428 try renderToken(r, volatile_token + 1, .none); // lparen
2429 } else {
2430 try renderToken(r, asm_node.ast.asm_token + 1, .none); // lparen
2431 }
2432
2433 if (asm_node.ast.items.len == 0) {
2434 try ais.forcePushIndent(.normal);
2435 if (asm_node.first_clobber) |first_clobber| {
2436 // asm ("foo" ::: "a", "b")
2437 // asm ("foo" ::: "a", "b",)
2438 try renderExpression(r, asm_node.ast.template, .space);
2439 // Render the three colons.
2440 try renderToken(r, first_clobber - 3, .none);
2441 try renderToken(r, first_clobber - 2, .none);
2442 try renderToken(r, first_clobber - 1, .space);
2443
2444 try ais.writeAll(".{ ");
2445
2446 var tok_i = first_clobber;
2447 while (true) : (tok_i += 1) {
2448 try ais.writeByte('.');
2449 _ = try writeStringLiteralAsIdentifier(r, tok_i);
2450 try ais.writeAll(" = true");
2451
2452 tok_i += 1;
2453 switch (tree.tokenTag(tok_i)) {
2454 .r_paren => {
2455 try ais.writeAll(" }");
2456 ais.popIndent();
2457 return renderToken(r, tok_i, space);
2458 },
2459 .comma => {
2460 if (tree.tokenTag(tok_i + 1) == .r_paren) {
2461 try ais.writeAll(" }");
2462 ais.popIndent();
2463 return renderToken(r, tok_i + 1, space);
2464 } else {
2465 try renderToken(r, tok_i, .space);
2466 }
2467 },
2468 else => unreachable,
2469 }
2470 }
2471 } else {
2472 unreachable;
2473 }
2474 }
2475
2476 try ais.forcePushIndent(.normal);
2477 try renderExpression(r, asm_node.ast.template, .newline);
2478 ais.setIndentDelta(asm_indent_delta);
2479 const colon1 = tree.lastToken(asm_node.ast.template) + 1;
2480
2481 const colon2 = if (asm_node.outputs.len == 0) colon2: {
2482 try renderToken(r, colon1, .newline); // :
2483 break :colon2 colon1 + 1;
2484 } else colon2: {
2485 try renderToken(r, colon1, .space); // :
2486
2487 try ais.forcePushIndent(.normal);
2488 for (asm_node.outputs, 0..) |asm_output, i| {
2489 if (i + 1 < asm_node.outputs.len) {
2490 const next_asm_output = asm_node.outputs[i + 1];
2491 try renderAsmOutput(r, asm_output, .none);
2492
2493 const comma = tree.firstToken(next_asm_output) - 1;
2494 try renderToken(r, comma, .newline); // ,
2495 try renderExtraNewlineToken(r, tree.firstToken(next_asm_output));
2496 } else if (asm_node.inputs.len == 0 and asm_node.first_clobber == null) {
2497 try ais.pushSpace(.comma);
2498 try renderAsmOutput(r, asm_output, .comma);
2499 ais.popSpace();
2500 ais.popIndent();
2501 ais.setIndentDelta(indent_delta);
2502 ais.popIndent();
2503 return renderToken(r, asm_node.ast.rparen, space); // rparen
2504 } else {
2505 try ais.pushSpace(.comma);
2506 try renderAsmOutput(r, asm_output, .comma);
2507 ais.popSpace();
2508 const comma_or_colon = tree.lastToken(asm_output) + 1;
2509 ais.popIndent();
2510 break :colon2 switch (tree.tokenTag(comma_or_colon)) {
2511 .comma => comma_or_colon + 1,
2512 else => comma_or_colon,
2513 };
2514 }
2515 } else unreachable;
2516 };
2517
2518 const colon3 = if (asm_node.inputs.len == 0) colon3: {
2519 try renderToken(r, colon2, .newline); // :
2520 break :colon3 colon2 + 1;
2521 } else colon3: {
2522 try renderToken(r, colon2, .space); // :
2523 try ais.forcePushIndent(.normal);
2524 for (asm_node.inputs, 0..) |asm_input, i| {
2525 if (i + 1 < asm_node.inputs.len) {
2526 const next_asm_input = asm_node.inputs[i + 1];
2527 try renderAsmInput(r, asm_input, .none);
2528
2529 const first_token = tree.firstToken(next_asm_input);
2530 try renderToken(r, first_token - 1, .newline); // ,
2531 try renderExtraNewlineToken(r, first_token);
2532 } else if (asm_node.first_clobber == null) {
2533 try ais.pushSpace(.comma);
2534 try renderAsmInput(r, asm_input, .comma);
2535 ais.popSpace();
2536 ais.popIndent();
2537 ais.setIndentDelta(indent_delta);
2538 ais.popIndent();
2539 return renderToken(r, asm_node.ast.rparen, space); // rparen
2540 } else {
2541 try ais.pushSpace(.comma);
2542 try renderAsmInput(r, asm_input, .comma);
2543 ais.popSpace();
2544 const comma_or_colon = tree.lastToken(asm_input) + 1;
2545 ais.popIndent();
2546 break :colon3 switch (tree.tokenTag(comma_or_colon)) {
2547 .comma => comma_or_colon + 1,
2548 else => comma_or_colon,
2549 };
2550 }
2551 }
2552 unreachable;
2553 };
2554
2555 try renderToken(r, colon3, .space); // :
2556 try ais.writeAll(".{ ");
2557 const first_clobber = asm_node.first_clobber.?;
2558 var tok_i = first_clobber;
2559 while (true) {
2560 switch (tree.tokenTag(tok_i + 1)) {
2561 .r_paren => {
2562 ais.setIndentDelta(indent_delta);
2563 try ais.writeByte('.');
2564 const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i);
2565 try ais.writeAll(" = true }");
2566 try renderSpace(r, tok_i, lexeme_len, .newline);
2567 ais.popIndent();
2568 return renderToken(r, tok_i + 1, space);
2569 },
2570 .comma => {
2571 switch (tree.tokenTag(tok_i + 2)) {
2572 .r_paren => {
2573 ais.setIndentDelta(indent_delta);
2574 try ais.writeByte('.');
2575 const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i);
2576 try ais.writeAll(" = true }");
2577 try renderSpace(r, tok_i, lexeme_len, .newline);
2578 ais.popIndent();
2579 return renderToken(r, tok_i + 2, space);
2580 },
2581 else => {
2582 try ais.writeByte('.');
2583 _ = try writeStringLiteralAsIdentifier(r, tok_i);
2584 try ais.writeAll(" = true");
2585 try renderToken(r, tok_i + 1, .space);
2586 tok_i += 2;
2587 },
2588 }
2589 },
2590 else => unreachable,
2591 }
2592 }
2593}
2594
25952413fn renderAsm(
25962414 r: *Render,
25972415 asm_node: Ast.full.Asm,
lib/std/zig/AstGen.zig-10
......@@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins
507507 .bool_or,
508508 .@"asm",
509509 .asm_simple,
510 .asm_legacy,
511510 .string_literal,
512511 .number_literal,
513512 .call,
......@@ -814,12 +813,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
814813 .@"asm",
815814 => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?),
816815
817 .asm_legacy => {
818 return astgen.failNodeNotes(node, "legacy asm clobbers syntax", .{}, &[_]u32{
819 try astgen.errNoteNode(node, "use 'zig fmt' to auto-upgrade", .{}),
820 });
821 },
822
823816 .string_literal => return stringLiteral(gz, ri, node),
824817 .multiline_string_literal => return multilineStringLiteral(gz, ri, node),
825818
......@@ -10502,7 +10495,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev
1050210495
1050310496 .@"asm",
1050410497 .asm_simple,
10505 .asm_legacy,
1050610498 .identifier,
1050710499 .field_access,
1050810500 .deref,
......@@ -10746,7 +10738,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In
1074610738 .tagged_union_enum_tag_trailing,
1074710739 .@"asm",
1074810740 .asm_simple,
10749 .asm_legacy,
1075010741 .add,
1075110742 .add_wrap,
1075210743 .add_sat,
......@@ -10985,7 +10976,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool {
1098510976 .tagged_union_enum_tag_trailing,
1098610977 .@"asm",
1098710978 .asm_simple,
10988 .asm_legacy,
1098910979 .add,
1099010980 .add_wrap,
1099110981 .add_sat,
lib/std/zig/AstRlAnnotate.zig-1
......@@ -310,7 +310,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI
310310 .unreachable_literal,
311311 .asm_simple,
312312 .@"asm",
313 .asm_legacy,
314313 .enum_literal,
315314 .error_value,
316315 .anyframe_literal,
lib/std/zig/Parse.zig-26
......@@ -2857,32 +2857,6 @@ fn expectAsmExpr(p: *Parse) !Node.Index {
28572857
28582858 _ = p.eatToken(.colon) orelse break :clobbers .none;
28592859
2860 // For automatic upgrades; delete after 0.15.0 released.
2861 if (p.tokenTag(p.tok_i) == .string_literal) {
2862 while (p.eatToken(.string_literal)) |_| {
2863 switch (p.tokenTag(p.tok_i)) {
2864 .comma => p.tok_i += 1,
2865 .colon, .r_paren, .r_brace, .r_bracket => break,
2866 // Likely just a missing comma; give error but continue parsing.
2867 else => try p.warnExpected(.comma),
2868 }
2869 }
2870 const rparen = try p.expectToken(.r_paren);
2871 const span = try p.listToSpan(p.scratch.items[scratch_top..]);
2872 return p.addNode(.{
2873 .tag = .asm_legacy,
2874 .main_token = asm_token,
2875 .data = .{ .node_and_extra = .{
2876 template,
2877 try p.addExtra(Node.AsmLegacy{
2878 .items_start = span.start,
2879 .items_end = span.end,
2880 .rparen = rparen,
2881 }),
2882 } },
2883 });
2884 }
2885
28862860 break :clobbers (try p.expectExpr()).toOptional();
28872861 } else .none;
28882862
lib/std/zig/ZonGen.zig+1-1
......@@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator
238238 => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}),
239239
240240 .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}),
241 .asm_simple, .@"asm", .asm_legacy => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}),
241 .asm_simple, .@"asm" => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}),
242242
243243 .builtin_call_two,
244244 .builtin_call_two_comma,
lib/std/zig/parser_test.zig+10-82
......@@ -31,54 +31,16 @@ test "zig fmt: tuple struct" {
3131}
3232
3333test "zig fmt: preserves clobbers in inline asm with stray comma" {
34 try testTransform(
35 \\fn foo() void {
36 \\ asm volatile (""
37 \\ : [_] "" (-> type),
38 \\ :
39 \\ : "clobber"
40 \\ );
41 \\ asm volatile (""
42 \\ :
43 \\ : [_] "" (type),
44 \\ : "clobber"
45 \\ );
46 \\}
47 \\
48 ,
34 try testCanonical(
4935 \\fn foo() void {
5036 \\ asm volatile (""
5137 \\ : [_] "" (-> type),
5238 \\ :
53 \\ : .{ .clobber = true }
54 \\ );
39 \\ : .{ .clobber = true });
5540 \\ asm volatile (""
5641 \\ :
5742 \\ : [_] "" (type),
58 \\ : .{ .clobber = true }
59 \\ );
60 \\}
61 \\
62 );
63}
64
65test "zig fmt: remove trailing comma at the end of assembly clobber" {
66 try testTransform(
67 \\fn foo() void {
68 \\ asm volatile (""
69 \\ : [_] "" (-> type),
70 \\ :
71 \\ : "clobber1", "clobber2",
72 \\ );
73 \\}
74 \\
75 ,
76 \\fn foo() void {
77 \\ asm volatile (""
78 \\ : [_] "" (-> type),
79 \\ :
80 \\ : .{ .clobber1 = true, .clobber2 = true }
81 \\ );
43 \\ : .{ .clobber = true });
8244 \\}
8345 \\
8446 );
......@@ -641,27 +603,7 @@ test "zig fmt: builtin call with trailing comma" {
641603}
642604
643605test "zig fmt: asm expression with comptime content" {
644 try testTransform(
645 \\comptime {
646 \\ asm ("foo" ++ "bar");
647 \\}
648 \\pub fn main() void {
649 \\ asm volatile ("foo" ++ "bar");
650 \\ asm volatile ("foo" ++ "bar"
651 \\ : [_] "" (x),
652 \\ );
653 \\ asm volatile ("foo" ++ "bar"
654 \\ : [_] "" (x),
655 \\ : [_] "" (y),
656 \\ );
657 \\ asm volatile ("foo" ++ "bar"
658 \\ : [_] "" (x),
659 \\ : [_] "" (y),
660 \\ : "h", "e", "l", "l", "o"
661 \\ );
662 \\}
663 \\
664 ,
606 try testCanonical(
665607 \\comptime {
666608 \\ asm ("foo" ++ "bar");
667609 \\}
......@@ -677,8 +619,7 @@ test "zig fmt: asm expression with comptime content" {
677619 \\ asm volatile ("foo" ++ "bar"
678620 \\ : [_] "" (x),
679621 \\ : [_] "" (y),
680 \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true }
681 \\ );
622 \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true });
682623 \\}
683624 \\
684625 );
......@@ -2198,7 +2139,7 @@ test "zig fmt: simple asm" {
21982139 \\ asm ("not real assembly"
21992140 \\ :[a] "x" (->i32),:[a] "x" (1),);
22002141 \\ asm ("still not real assembly"
2201 \\ :::"a","b",);
2142 \\ :::.{.a=true,.b=true});
22022143 \\}
22032144 ,
22042145 \\comptime {
......@@ -3940,24 +3881,13 @@ test "zig fmt: fn type" {
39403881}
39413882
39423883test "zig fmt: inline asm" {
3943 try testTransform(
3944 \\pub fn syscall1(number: usize, arg1: usize) usize {
3945 \\ return asm volatile ("syscall"
3946 \\ : [ret] "={rax}" (-> usize),
3947 \\ : [number] "{rax}" (number),
3948 \\ [arg1] "{rdi}" (arg1),
3949 \\ : "rcx", "r11"
3950 \\ );
3951 \\}
3952 \\
3953 ,
3884 try testCanonical(
39543885 \\pub fn syscall1(number: usize, arg1: usize) usize {
39553886 \\ return asm volatile ("syscall"
39563887 \\ : [ret] "={rax}" (-> usize),
39573888 \\ : [number] "{rax}" (number),
39583889 \\ [arg1] "{rdi}" (arg1),
3959 \\ : .{ .rcx = true, .r11 = true }
3960 \\ );
3890 \\ : .{ .rcx = true, .r11 = true });
39613891 \\}
39623892 \\
39633893 );
......@@ -5789,8 +5719,7 @@ test "zig fmt: canonicalize symbols (asm)" {
57895719 \\ [@"arg1"] "{rdi}" (arg),
57905720 \\ [arg2] "{rsi}" (arg),
57915721 \\ [arg3] "{rdx}" (arg),
5792 \\ : "rcx", "fn"
5793 \\ );
5722 \\ : .{ .rcx = true, .@"fn" = true });
57945723 \\
57955724 \\ const @"false": usize = 10;
57965725 \\ const @"true" = "explode";
......@@ -5811,8 +5740,7 @@ test "zig fmt: canonicalize symbols (asm)" {
58115740 \\ [arg1] "{rdi}" (arg),
58125741 \\ [arg2] "{rsi}" (arg),
58135742 \\ [arg3] "{rdx}" (arg),
5814 \\ : .{ .rcx = true, .@"fn" = true }
5815 \\ );
5743 \\ : .{ .rcx = true, .@"fn" = true });
58165744 \\
58175745 \\ const @"false": usize = 10;
58185746 \\ const @"true" = "explode";
test/standalone/config_header/build.zig+1-1
......@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void {
2121 },
2222 );
2323
24 const check_config_header = b.addCheckFile(config_header.getOutput(), .{ .expected_exact = @embedFile("config.h") });
24 const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ .expected_exact = @embedFile("config.h") });
2525
2626 const test_step = b.step("test", "Test it");
2727 test_step.dependOn(&check_config_header.step);
test/standalone/test_obj_link_run/build.zig+3-3
......@@ -9,9 +9,9 @@ pub fn build(b: *std.Build) void {
99 }),
1010 });
1111 if (is_windows) {
12 test_obj.linkSystemLibrary("ntdll");
13 test_obj.linkSystemLibrary("kernel32");
14 test_obj.linkSystemLibrary("ws2_32");
12 test_obj.root_module.linkSystemLibrary("ntdll", .{});
13 test_obj.root_module.linkSystemLibrary("kernel32", .{});
14 test_obj.root_module.linkSystemLibrary("ws2_32", .{});
1515 }
1616
1717 const test_exe_mod = b.createModule(.{