diff --git a/lib/compiler/aro/assembly_backend/x86_64.zig b/lib/compiler/aro/assembly_backend/x86_64.zig index 455d21aa82bd..eb2bac386146 100644 --- a/lib/compiler/aro/assembly_backend/x86_64.zig +++ b/lib/compiler/aro/assembly_backend/x86_64.zig @@ -58,7 +58,7 @@ fn serializeFloat(comptime T: type, value: T, w: *std.Io.Writer) !void { }, else => { const size = @bitSizeOf(T); - const storage_unit = std.meta.intToEnum(StorageUnit, size) catch unreachable; + const storage_unit = std.enums.fromInt(StorageUnit, size).?; const IntTy = @Type(.{ .int = .{ .signedness = .unsigned, .bits = size } }); const int_val: IntTy = @bitCast(value); return serializeInt(int_val, storage_unit, w); @@ -95,7 +95,7 @@ fn emitSingleValue(c: *AsmCodeGen, qt: QualType, node: Node.Index) !void { if (!scalar_kind.isReal()) { return c.todo("Codegen _Complex values", node.tok(c.tree)); } else if (scalar_kind.isInt()) { - const storage_unit = std.meta.intToEnum(StorageUnit, bit_size) catch return c.todo("Codegen _BitInt values", node.tok(c.tree)); + const storage_unit = std.enums.fromInt(StorageUnit, bit_size) orelse return c.todo("Codegen _BitInt values", node.tok(c.tree)); try c.data.print(" .{s} ", .{@tagName(storage_unit)}); _ = try value.print(qt, c.comp, c.data); try c.data.writeByte('\n'); diff --git a/lib/compiler/reduce/Walk.zig b/lib/compiler/reduce/Walk.zig index 7a448fad2172..d4a816f168a5 100644 --- a/lib/compiler/reduce/Walk.zig +++ b/lib/compiler/reduce/Walk.zig @@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void { .@"asm", => return walkAsm(w, ast.fullAsm(node).?), - .asm_legacy => { - return walkAsmLegacy(w, ast.legacyAsm(node).?); - }, - .enum_literal => { return walkIdentifier(w, ast.nodeMainToken(node)); // name }, @@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void { try walkExpressions(w, asm_node.ast.items); } -fn walkAsmLegacy(w: *Walk, asm_node: Ast.full.AsmLegacy) Error!void { - try walkExpression(w, asm_node.ast.template); - try walkExpressions(w, asm_node.ast.items); -} - /// Check if it is already gutted (i.e. its body replaced with `@trap()`). fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool { // skip over discards diff --git a/lib/docs/wasm/Walk.zig b/lib/docs/wasm/Walk.zig index 38652746cffa..fef2fa64e879 100644 --- a/lib/docs/wasm/Walk.zig +++ b/lib/docs/wasm/Walk.zig @@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index) try expr(w, scope, parent_decl, full.ast.template); }, - .asm_legacy => {}, - .builtin_call_two, .builtin_call_two_comma, .builtin_call, diff --git a/lib/docs/wasm/markdown.zig b/lib/docs/wasm/markdown.zig index 6e9b7a06036f..a15af8869c68 100644 --- a/lib/docs/wasm/markdown.zig +++ b/lib/docs/wasm/markdown.zig @@ -149,7 +149,7 @@ fn mainImpl() !void { var stdin_reader = std.fs.File.stdin().reader(&stdin_buffer); while (stdin_reader.takeDelimiterExclusive('\n')) |line| { - const trimmed = std.mem.trimRight(u8, line, '\r'); + const trimmed = std.mem.trimEnd(u8, line, '\r'); try parser.feedLine(trimmed); } else |err| switch (err) { error.EndOfStream => {}, diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index a5f2d696be1b..863c64bffb91 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -187,9 +187,6 @@ force_undefined_symbols: std.StringHashMap(void), /// Overrides the default stack size stack_size: ?u64 = null, -/// Deprecated; prefer using `lto`. -want_lto: ?bool = null, - use_llvm: ?bool, use_lld: ?bool, use_new_linker: ?bool, @@ -539,7 +536,7 @@ pub fn installHeadersDirectory( /// When a module links with this artifact, all headers marked for installation are added to that /// module's include search path. pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void { - cs.installHeader(config_header.getOutput(), config_header.include_path); + cs.installHeader(config_header.getOutputFile(), config_header.include_path); } /// Forwards all headers marked for installation from `lib` to this artifact. @@ -682,18 +679,6 @@ pub fn producesImplib(compile: *Compile) bool { return compile.isDll(); } -/// Deprecated; use `compile.root_module.link_libc = true` instead. -/// To be removed after 0.15.0 is tagged. -pub fn linkLibC(compile: *Compile) void { - compile.root_module.link_libc = true; -} - -/// Deprecated; use `compile.root_module.link_libcpp = true` instead. -/// To be removed after 0.15.0 is tagged. -pub fn linkLibCpp(compile: *Compile) void { - compile.root_module.link_libcpp = true; -} - const PkgConfigResult = struct { cflags: []const []const u8, libs: []const []const u8, @@ -807,46 +792,6 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult { }; } -/// Deprecated; use `compile.root_module.linkSystemLibrary(name, .{})` instead. -/// To be removed after 0.15.0 is tagged. -pub fn linkSystemLibrary(compile: *Compile, name: []const u8) void { - return compile.root_module.linkSystemLibrary(name, .{}); -} - -/// Deprecated; use `compile.root_module.linkSystemLibrary(name, options)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn linkSystemLibrary2( - compile: *Compile, - name: []const u8, - options: Module.LinkSystemLibraryOptions, -) void { - return compile.root_module.linkSystemLibrary(name, options); -} - -/// Deprecated; use `c.root_module.linkFramework(name, .{})` instead. -/// To be removed after 0.15.0 is tagged. -pub fn linkFramework(c: *Compile, name: []const u8) void { - c.root_module.linkFramework(name, .{}); -} - -/// Deprecated; use `compile.root_module.addCSourceFiles(options)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addCSourceFiles(compile: *Compile, options: Module.AddCSourceFilesOptions) void { - compile.root_module.addCSourceFiles(options); -} - -/// Deprecated; use `compile.root_module.addCSourceFile(source)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addCSourceFile(compile: *Compile, source: Module.CSourceFile) void { - compile.root_module.addCSourceFile(source); -} - -/// Deprecated; use `compile.root_module.addWin32ResourceFile(source)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addWin32ResourceFile(compile: *Compile, source: Module.RcSourceFile) void { - compile.root_module.addWin32ResourceFile(source); -} - pub fn setVerboseLink(compile: *Compile, value: bool) void { compile.verbose_link = value; } @@ -928,84 +873,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath { return compile.getEmittedFileGeneric(&compile.generated_llvm_bc); } -/// Deprecated; use `compile.root_module.addAssemblyFile(source)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addAssemblyFile(compile: *Compile, source: LazyPath) void { - compile.root_module.addAssemblyFile(source); -} - -/// Deprecated; use `compile.root_module.addObjectFile(source)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addObjectFile(compile: *Compile, source: LazyPath) void { - compile.root_module.addObjectFile(source); -} - -/// Deprecated; use `compile.root_module.addObject(object)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addObject(compile: *Compile, object: *Compile) void { - compile.root_module.addObject(object); -} - -/// Deprecated; use `compile.root_module.linkLibrary(library)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn linkLibrary(compile: *Compile, library: *Compile) void { - compile.root_module.linkLibrary(library); -} - -/// Deprecated; use `compile.root_module.addAfterIncludePath(lazy_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addAfterIncludePath(compile: *Compile, lazy_path: LazyPath) void { - compile.root_module.addAfterIncludePath(lazy_path); -} - -/// Deprecated; use `compile.root_module.addSystemIncludePath(lazy_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addSystemIncludePath(compile: *Compile, lazy_path: LazyPath) void { - compile.root_module.addSystemIncludePath(lazy_path); -} - -/// Deprecated; use `compile.root_module.addIncludePath(lazy_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addIncludePath(compile: *Compile, lazy_path: LazyPath) void { - compile.root_module.addIncludePath(lazy_path); -} - -/// Deprecated; use `compile.root_module.addConfigHeader(config_header)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) void { - compile.root_module.addConfigHeader(config_header); -} - -/// Deprecated; use `compile.root_module.addEmbedPath(lazy_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void { - compile.root_module.addEmbedPath(lazy_path); -} - -/// Deprecated; use `compile.root_module.addLibraryPath(directory_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void { - compile.root_module.addLibraryPath(directory_path); -} - -/// Deprecated; use `compile.root_module.addRPath(directory_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addRPath(compile: *Compile, directory_path: LazyPath) void { - compile.root_module.addRPath(directory_path); -} - -/// Deprecated; use `compile.root_module.addSystemFrameworkPath(directory_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addSystemFrameworkPath(compile: *Compile, directory_path: LazyPath) void { - compile.root_module.addSystemFrameworkPath(directory_path); -} - -/// Deprecated; use `compile.root_module.addFrameworkPath(directory_path)` instead. -/// To be removed after 0.15.0 is tagged. -pub fn addFrameworkPath(compile: *Compile, directory_path: LazyPath) void { - compile.root_module.addFrameworkPath(directory_path); -} - pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void { const b = compile.step.owner; assert(compile.kind == .@"test"); @@ -1758,7 +1625,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { .thin => "-flto=thin", .none => "-fno-lto", }); - } else try addFlag(&zig_args, "lto", compile.want_lto); + } try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard); diff --git a/lib/std/Build/Step/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig index 3f89bf8ec99b..8c0d3032da73 100644 --- a/lib/std/Build/Step/ConfigHeader.zig +++ b/lib/std/Build/Step/ConfigHeader.zig @@ -124,9 +124,6 @@ pub fn getOutputFile(ch: *ConfigHeader) std.Build.LazyPath { return ch.getOutputDir().path(ch.step.owner, ch.include_path); } -/// Deprecated; use `getOutputFile`. -pub const getOutput = getOutputFile; - fn addValueInner(config_header: *ConfigHeader, name: []const u8, comptime T: type, value: T) !void { switch (@typeInfo(T)) { .null => { diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index eb1de3dd3b7b..2671d8317879 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -73,9 +73,6 @@ skip_foreign_checks: bool, /// external executor (such as qemu) but not fail if the executor is unavailable. failing_to_execute_foreign_is_an_error: bool, -/// Deprecated in favor of `stdio_limit`. -max_stdio_size: usize, - /// If stderr or stdout exceeds this amount, the child process is killed and /// the step fails. stdio_limit: std.Io.Limit, @@ -208,7 +205,6 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { .rename_step_with_output_arg = true, .skip_foreign_checks = false, .failing_to_execute_foreign_is_an_error = true, - .max_stdio_size = 10 * 1024 * 1024, .stdio_limit = .unlimited, .captured_stdout = null, .captured_stderr = null, @@ -2145,7 +2141,6 @@ fn evalGeneric(run: *Run, child: *std.process.Child) !EvalGenericResult { var stdout_bytes: ?[]const u8 = null; var stderr_bytes: ?[]const u8 = null; - run.stdio_limit = run.stdio_limit.min(.limited(run.max_stdio_size)); if (child.stdout) |stdout| { if (child.stderr) |stderr| { var poller = std.Io.poll(arena, enum { stdout, stderr }, .{ diff --git a/lib/std/Io/Reader.zig b/lib/std/Io/Reader.zig index e2344e959e69..dfea20099466 100644 --- a/lib/std/Io/Reader.zig +++ b/lib/std/Io/Reader.zig @@ -1246,7 +1246,7 @@ pub const TakeEnumError = Error || error{InvalidEnumTag}; pub fn takeEnum(r: *Reader, comptime Enum: type, endian: std.builtin.Endian) TakeEnumError!Enum { const Tag = @typeInfo(Enum).@"enum".tag_type; const int = try r.takeInt(Tag, endian); - return std.meta.intToEnum(Enum, int); + return std.enums.fromInt(Enum, int) orelse return error.InvalidEnumTag; } /// Reads an integer with the same size as the given nonexhaustive enum's tag type. diff --git a/lib/std/Io/Writer.zig b/lib/std/Io/Writer.zig index b41aa24ccb3c..29f4d5d9b724 100644 --- a/lib/std/Io/Writer.zig +++ b/lib/std/Io/Writer.zig @@ -1201,10 +1201,6 @@ pub fn printValue( } const is_any = comptime std.mem.eql(u8, fmt, ANY); - if (!is_any and std.meta.hasMethod(T, "format") and fmt.len == 0) { - // after 0.15.0 is tagged, delete this compile error and its condition - @compileError("ambiguous format string; specify {f} to call format method, or {any} to skip it"); - } switch (@typeInfo(T)) { .float, .comptime_float => { @@ -1692,7 +1688,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi try w.writeAll("0x"); try w.writeByte(buf[0]); - const trimmed = std.mem.trimRight(u8, buf[1..], "0"); + const trimmed = std.mem.trimEnd(u8, buf[1..], "0"); if (opt_precision) |precision| { if (precision > 0) try w.writeAll("."); } else if (trimmed.len > 0) { diff --git a/lib/std/Io/tty.zig b/lib/std/Io/tty.zig index 8bc44c234805..fdd090fa57ab 100644 --- a/lib/std/Io/tty.zig +++ b/lib/std/Io/tty.zig @@ -5,11 +5,6 @@ const process = std.process; const windows = std.os.windows; const native_os = builtin.os.tag; -/// Deprecated in favor of `Config.detect`. -pub fn detectConfig(file: File) Config { - return .detect(file); -} - pub const Color = enum { black, red, diff --git a/lib/std/crypto/tls/Client.zig b/lib/std/crypto/tls/Client.zig index f6e334af8efc..d3a06819bf93 100644 --- a/lib/std/crypto/tls/Client.zig +++ b/lib/std/crypto/tls/Client.zig @@ -1158,7 +1158,7 @@ fn readIndirect(c: *Client) Reader.Error!usize { P.AEAD.decrypt(cleartext, ciphertext, auth_tag, ad, nonce, pv.server_key) catch return failRead(c, error.TlsBadRecordMac); // TODO use scalar, non-slice version - const msg = mem.trimRight(u8, cleartext, "\x00"); + const msg = mem.trimEnd(u8, cleartext, "\x00"); break :cleartext .{ msg.len - 1, @enumFromInt(msg[msg.len - 1]) }; }, .tls_1_2 => { diff --git a/lib/std/debug.zig b/lib/std/debug.zig index db772de45cc0..c88dd40eabe5 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -328,16 +328,16 @@ pub fn dumpHex(bytes: []const u8) void { } /// Prints a hexadecimal view of the bytes, returning any error that occurs. -pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !void { +pub fn dumpHexFallible(bw: *Writer, tty_config: tty.Config, bytes: []const u8) !void { var chunks = mem.window(u8, bytes, 16, 16); while (chunks.next()) |window| { // 1. Print the address. const address = (@intFromPtr(bytes.ptr) + 0x10 * (std.math.divCeil(usize, chunks.index orelse bytes.len, 16) catch unreachable)) - 0x10; - try ttyconf.setColor(bw, .dim); + try tty_config.setColor(bw, .dim); // We print the address in lowercase and the bytes in uppercase hexadecimal to distinguish them more. // Also, make sure all lines are aligned by padding the address. try bw.print("{x:0>[1]} ", .{ address, @sizeOf(usize) * 2 }); - try ttyconf.setColor(bw, .reset); + try tty_config.setColor(bw, .reset); // 2. Print the bytes. for (window, 0..) |byte, index| { @@ -357,7 +357,7 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: tty.Config, bytes: []const u8) !voi try bw.writeByte(byte); } else { // Related: https://github.com/ziglang/zig/issues/7600 - if (ttyconf == .windows_api) { + if (tty_config == .windows_api) { try bw.writeByte('.'); continue; } diff --git a/lib/std/enums.zig b/lib/std/enums.zig index e47af4aca31b..926d0239aae8 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -216,48 +216,6 @@ test "directEnumArrayDefault slice" { try testing.expectEqualSlices(u8, "default", array[2]); } -/// Deprecated: Use @field(E, @tagName(tag)) or @field(E, string) -pub fn nameCast(comptime E: type, comptime value: anytype) E { - return comptime blk: { - const V = @TypeOf(value); - if (V == E) break :blk value; - const name: ?[]const u8 = switch (@typeInfo(V)) { - .enum_literal, .@"enum" => @tagName(value), - .pointer => value, - else => null, - }; - if (name) |n| { - if (@hasField(E, n)) { - break :blk @field(E, n); - } - @compileError("Enum " ++ @typeName(E) ++ " has no field named " ++ n); - } - @compileError("Cannot cast from " ++ @typeName(@TypeOf(value)) ++ " to " ++ @typeName(E)); - }; -} - -test nameCast { - const A = enum(u1) { a = 0, b = 1 }; - const B = enum(u1) { a = 1, b = 0 }; - try testing.expectEqual(A.a, nameCast(A, .a)); - try testing.expectEqual(A.a, nameCast(A, A.a)); - try testing.expectEqual(A.a, nameCast(A, B.a)); - try testing.expectEqual(A.a, nameCast(A, "a")); - try testing.expectEqual(A.a, nameCast(A, @as(*const [1]u8, "a"))); - try testing.expectEqual(A.a, nameCast(A, @as([:0]const u8, "a"))); - try testing.expectEqual(A.a, nameCast(A, @as([]const u8, "a"))); - - try testing.expectEqual(B.a, nameCast(B, .a)); - try testing.expectEqual(B.a, nameCast(B, A.a)); - try testing.expectEqual(B.a, nameCast(B, B.a)); - try testing.expectEqual(B.a, nameCast(B, "a")); - - try testing.expectEqual(B.b, nameCast(B, .b)); - try testing.expectEqual(B.b, nameCast(B, A.b)); - try testing.expectEqual(B.b, nameCast(B, B.b)); - try testing.expectEqual(B.b, nameCast(B, "b")); -} - test fromInt { const E1 = enum { A, diff --git a/lib/std/heap/debug_allocator.zig b/lib/std/heap/debug_allocator.zig index 44800097815a..3183becd8282 100644 --- a/lib/std/heap/debug_allocator.zig +++ b/lib/std/heap/debug_allocator.zig @@ -460,7 +460,7 @@ pub fn DebugAllocator(comptime config: Config) type { pub fn detectLeaks(self: *Self) usize { var leaks: usize = 0; - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); for (self.buckets, 0..) |init_optional_bucket, size_class_index| { var optional_bucket = init_optional_bucket; @@ -536,7 +536,7 @@ pub fn DebugAllocator(comptime config: Config) type { fn reportDoubleFree(ret_addr: usize, alloc_stack_trace: StackTrace, free_stack_trace: StackTrace) void { var addr_buf: [stack_n]usize = undefined; const second_free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Double free detected. Allocation: {f} First free: {f} Second free: {f}", .{ std.debug.FormatStackTrace{ .stack_trace = alloc_stack_trace, @@ -590,7 +590,7 @@ pub fn DebugAllocator(comptime config: Config) type { if (config.safety and old_mem.len != entry.value_ptr.bytes.len) { var addr_buf: [stack_n]usize = undefined; const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ entry.value_ptr.bytes.len, old_mem.len, @@ -703,7 +703,7 @@ pub fn DebugAllocator(comptime config: Config) type { if (config.safety and old_mem.len != entry.value_ptr.bytes.len) { var addr_buf: [stack_n]usize = undefined; const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = ret_addr }, &addr_buf); - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ entry.value_ptr.bytes.len, old_mem.len, @@ -935,7 +935,7 @@ pub fn DebugAllocator(comptime config: Config) type { var addr_buf: [stack_n]usize = undefined; const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf); if (old_memory.len != requested_size) { - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ requested_size, old_memory.len, @@ -950,7 +950,7 @@ pub fn DebugAllocator(comptime config: Config) type { }); } if (alignment != slot_alignment) { - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{ slot_alignment.toByteUnits(), alignment.toByteUnits(), @@ -1044,7 +1044,7 @@ pub fn DebugAllocator(comptime config: Config) type { var addr_buf: [stack_n]usize = undefined; const free_stack_trace = std.debug.captureCurrentStackTrace(.{ .first_address = return_address }, &addr_buf); if (memory.len != requested_size) { - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {f} Free: {f}", .{ requested_size, memory.len, @@ -1059,7 +1059,7 @@ pub fn DebugAllocator(comptime config: Config) type { }); } if (alignment != slot_alignment) { - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); log.err("Allocation alignment {d} does not match free alignment {d}. Allocation: {f} Free: {f}", .{ slot_alignment.toByteUnits(), alignment.toByteUnits(), diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig index 431f239db30b..fc3b3d3e3560 100644 --- a/lib/std/http/Client.zig +++ b/lib/std/http/Client.zig @@ -529,7 +529,7 @@ pub const Response = struct { }; if (first_line[8] != ' ') return error.HttpHeadersInvalid; const status: http.Status = @enumFromInt(parseInt3(first_line[9..12])); - const reason = mem.trimLeft(u8, first_line[12..], " "); + const reason = mem.trimStart(u8, first_line[12..], " "); res.version = version; res.status = status; diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 01dbac73a074..407292b8817e 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1247,9 +1247,6 @@ test trimStart { try testing.expectEqualSlices(u8, "foo\n ", trimStart(u8, " foo\n ", " \n")); } -/// Deprecated: use `trimStart` instead. -pub const trimLeft = trimStart; - /// Remove a set of values from the end of a slice. pub fn trimEnd(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { var end: usize = slice.len; @@ -1261,9 +1258,6 @@ test trimEnd { try testing.expectEqualSlices(u8, " foo", trimEnd(u8, " foo\n ", " \n")); } -/// Deprecated: use `trimEnd` instead. -pub const trimRight = trimEnd; - /// Remove a set of values from the beginning and end of a slice. pub fn trim(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { var begin: usize = 0; diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 5d022ecffab0..af2eae8dc8a1 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -671,38 +671,6 @@ test activeTag { try testing.expect(activeTag(u) == UE.Float); } -/// Deprecated: Use @FieldType(U, tag_name) -const TagPayloadType = TagPayload; - -/// Deprecated: Use @FieldType(U, tag_name) -pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type { - const info = @typeInfo(U).@"union"; - - inline for (info.fields) |field_info| { - if (comptime mem.eql(u8, field_info.name, tag_name)) - return field_info.type; - } - - @compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'"); -} - -/// Deprecated: Use @FieldType(U, @tagName(tag)) -pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { - return TagPayloadByName(U, @tagName(tag)); -} - -test TagPayload { - const Event = union(enum) { - Moved: struct { - from: i32, - to: i32, - }, - }; - const MovedEvent = TagPayload(Event, Event.Moved); - const e: Event = .{ .Moved = undefined }; - try testing.expect(MovedEvent == @TypeOf(e.Moved)); -} - /// Compares two of any type for equality. Containers that do not support comparison /// on their own are compared on a field-by-field basis. Pointers are not followed. pub fn eql(a: anytype, b: @TypeOf(a)) bool { @@ -831,14 +799,6 @@ test eql { try testing.expect(!eql(v1, v3)); } -/// Deprecated: use `std.enums.fromInt` instead and handle null. -pub const IntToEnumError = error{InvalidEnumTag}; - -/// Deprecated: use `std.enums.fromInt` instead and handle null instead of an error. -pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag { - return std.enums.fromInt(EnumTag, tag_int) orelse return error.InvalidEnumTag; -} - /// Given a type and a name, return the field index according to source order. /// Returns `null` if the field is not found. pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig index 6b658b87c0c0..490d3e233849 100644 --- a/lib/std/os/linux/test.zig +++ b/lib/std/os/linux/test.zig @@ -138,23 +138,23 @@ test "sigset_t" { // See that none are set, then set each one, see that they're all set, then // remove them all, and then see that none are set. for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(SIG, i) catch continue; + const sig = std.enums.fromInt(SIG, i) orelse continue; try expectEqual(false, linux.sigismember(&sigset, sig)); } for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(SIG, i) catch continue; + const sig = std.enums.fromInt(SIG, i) orelse continue; linux.sigaddset(&sigset, sig); } for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(SIG, i) catch continue; + const sig = std.enums.fromInt(SIG, i) orelse continue; try expectEqual(true, linux.sigismember(&sigset, sig)); } for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(SIG, i) catch continue; + const sig = std.enums.fromInt(SIG, i) orelse continue; linux.sigdelset(&sigset, sig); } for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(SIG, i) catch continue; + const sig = std.enums.fromInt(SIG, i) orelse continue; try expectEqual(false, linux.sigismember(&sigset, sig)); } } @@ -163,7 +163,7 @@ test "sigfillset" { // unlike the C library, all the signals are set in the kernel-level fillset const sigset = linux.sigfillset(); for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(linux.SIG, i) catch continue; + const sig = std.enums.fromInt(linux.SIG, i) orelse continue; try expectEqual(true, linux.sigismember(&sigset, sig)); } } @@ -171,7 +171,7 @@ test "sigfillset" { test "sigemptyset" { const sigset = linux.sigemptyset(); for (1..linux.NSIG) |i| { - const sig = std.meta.intToEnum(linux.SIG, i) catch continue; + const sig = std.enums.fromInt(linux.SIG, i) orelse continue; try expectEqual(false, linux.sigismember(&sigset, sig)); } } diff --git a/lib/std/os/uefi/protocol/ip6_config.zig b/lib/std/os/uefi/protocol/ip6_config.zig index bb660a3b8ef6..0ada2a7899fc 100644 --- a/lib/std/os/uefi/protocol/ip6_config.zig +++ b/lib/std/os/uefi/protocol/ip6_config.zig @@ -44,7 +44,7 @@ pub const Ip6Config = extern struct { pub fn setData( self: *const Ip6Config, comptime data_type: std.meta.Tag(DataType), - payload: *const std.meta.TagPayload(DataType, data_type), + payload: *const @FieldType(DataType, @tagName(data_type)), ) SetDataError!void { const data_size = @sizeOf(@TypeOf(payload)); switch (self._set_data(self, data_type, data_size, @ptrCast(payload))) { @@ -64,8 +64,8 @@ pub const Ip6Config = extern struct { pub fn getData( self: *const Ip6Config, comptime data_type: std.meta.Tag(DataType), - ) GetDataError!std.meta.TagPayload(DataType, data_type) { - const DataPayload = std.meta.TagPayload(DataType, data_type); + ) GetDataError!@FieldType(DataType, @tagName(data_type)) { + const DataPayload = @FieldType(DataType, @tagName(data_type)); var payload: DataPayload = undefined; var payload_size: usize = @sizeOf(DataPayload); diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig index 946dd9002745..70ca39bdcfb9 100644 --- a/lib/std/posix/test.zig +++ b/lib/std/posix/test.zig @@ -536,7 +536,7 @@ test "sigset empty/full" { var set: posix.sigset_t = posix.sigemptyset(); for (1..posix.NSIG) |i| { - const sig = std.meta.intToEnum(posix.SIG, i) catch continue; + const sig = std.enums.fromInt(posix.SIG, i) orelse continue; try expectEqual(false, posix.sigismember(&set, sig)); } @@ -565,29 +565,29 @@ test "sigset add/del" { // See that none are set, then set each one, see that they're all set, then // remove them all, and then see that none are set. for (1..posix.NSIG) |i| { - const sig = std.meta.intToEnum(posix.SIG, i) catch continue; + const sig = std.enums.fromInt(posix.SIG, i) orelse continue; try expectEqual(false, posix.sigismember(&sigset, sig)); } for (1..posix.NSIG) |i| { if (!reserved_signo(i)) { - const sig = std.meta.intToEnum(posix.SIG, i) catch continue; + const sig = std.enums.fromInt(posix.SIG, i) orelse continue; posix.sigaddset(&sigset, sig); } } for (1..posix.NSIG) |i| { if (!reserved_signo(i)) { - const sig = std.meta.intToEnum(posix.SIG, i) catch continue; + const sig = std.enums.fromInt(posix.SIG, i) orelse continue; try expectEqual(true, posix.sigismember(&sigset, sig)); } } for (1..posix.NSIG) |i| { if (!reserved_signo(i)) { - const sig = std.meta.intToEnum(posix.SIG, i) catch continue; + const sig = std.enums.fromInt(posix.SIG, i) orelse continue; posix.sigdelset(&sigset, sig); } } for (1..posix.NSIG) |i| { - const sig = std.meta.intToEnum(posix.SIG, i) catch continue; + const sig = std.enums.fromInt(posix.SIG, i) orelse continue; try expectEqual(false, posix.sigismember(&sigset, sig)); } } diff --git a/lib/std/testing.zig b/lib/std/testing.zig index b99542e7e57b..9ccd15b01e71 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -1148,7 +1148,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime } else |err| switch (err) { error.OutOfMemory => { if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) { - const tty_config = std.Io.tty.detectConfig(.stderr()); + const tty_config: std.Io.tty.Config = .detect(.stderr()); print( "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {f}", .{ diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 72ca20a6c0a6..ecb99820df25 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { .@"nosuspend", .asm_simple, .@"asm", - .asm_legacy, .array_type, .array_type_sentinel, .error_value, @@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter } }, - .asm_legacy => { - _, const extra_index = tree.nodeData(n).node_and_extra; - const extra = tree.extraData(extra_index, Node.AsmLegacy); - return extra.rparen + end_offset; - }, .@"asm" => { _, const extra_index = tree.nodeData(n).node_and_extra; const extra = tree.extraData(extra_index, Node.Asm); @@ -1897,18 +1891,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { }); } -pub fn asmLegacy(tree: Ast, node: Node.Index) full.AsmLegacy { - const template, const extra_index = tree.nodeData(node).node_and_extra; - const extra = tree.extraData(extra_index, Node.AsmLegacy); - const items = tree.extraDataSlice(.{ .start = extra.items_start, .end = extra.items_end }, Node.Index); - return tree.legacyAsmComponents(.{ - .asm_token = tree.nodeMainToken(node), - .template = template, - .items = items, - .rparen = extra.rparen, - }); -} - pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { const template, const extra_index = tree.nodeData(node).node_and_extra; const extra = tree.extraData(extra_index, Node.Asm); @@ -2214,67 +2196,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N return result; } -fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy { - var result: full.AsmLegacy = .{ - .ast = info, - .volatile_token = null, - .inputs = &.{}, - .outputs = &.{}, - .first_clobber = null, - }; - if (tree.tokenTag(info.asm_token + 1) == .keyword_volatile) { - result.volatile_token = info.asm_token + 1; - } - const outputs_end: usize = for (info.items, 0..) |item, i| { - switch (tree.nodeTag(item)) { - .asm_output => continue, - else => break i, - } - } else info.items.len; - - result.outputs = info.items[0..outputs_end]; - result.inputs = info.items[outputs_end..]; - - if (info.items.len == 0) { - // asm ("foo" ::: "a", "b"); - const template_token = tree.lastToken(info.template); - if (tree.tokenTag(template_token + 1) == .colon and - tree.tokenTag(template_token + 2) == .colon and - tree.tokenTag(template_token + 3) == .colon and - tree.tokenTag(template_token + 4) == .string_literal) - { - result.first_clobber = template_token + 4; - } - } else if (result.inputs.len != 0) { - // asm ("foo" :: [_] "" (y) : "a", "b"); - const last_input = result.inputs[result.inputs.len - 1]; - const rparen = tree.lastToken(last_input); - var i = rparen + 1; - // Allow a (useless) comma right after the closing parenthesis. - if (tree.tokenTag(i) == .comma) i = i + 1; - if (tree.tokenTag(i) == .colon and - tree.tokenTag(i + 1) == .string_literal) - { - result.first_clobber = i + 1; - } - } else { - // asm ("foo" : [_] "" (x) :: "a", "b"); - const last_output = result.outputs[result.outputs.len - 1]; - const rparen = tree.lastToken(last_output); - var i = rparen + 1; - // Allow a (useless) comma right after the closing parenthesis. - if (tree.tokenTag(i) == .comma) i = i + 1; - if (tree.tokenTag(i) == .colon and - tree.tokenTag(i + 1) == .colon and - tree.tokenTag(i + 2) == .string_literal) - { - result.first_clobber = i + 2; - } - } - - return result; -} - fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { var result: full.Asm = .{ .ast = info, @@ -2492,14 +2413,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm { }; } -/// To be deleted after 0.15.0 is tagged -pub fn legacyAsm(tree: Ast, node: Node.Index) ?full.AsmLegacy { - return switch (tree.nodeTag(node)) { - .asm_legacy => tree.asmLegacy(node), - else => null, - }; -} - pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { return switch (tree.nodeTag(node)) { .call, .call_comma => tree.callFull(node), @@ -2894,21 +2807,6 @@ pub const full = struct { }; }; - pub const AsmLegacy = struct { - ast: Components, - volatile_token: ?TokenIndex, - first_clobber: ?TokenIndex, - outputs: []const Node.Index, - inputs: []const Node.Index, - - pub const Components = struct { - asm_token: TokenIndex, - template: Node.Index, - items: []const Node.Index, - rparen: TokenIndex, - }; - }; - pub const Call = struct { ast: Components, @@ -3905,14 +3803,6 @@ pub const Node = struct { /// /// The `main_token` field is the `asm` token. asm_simple, - /// `asm(lhs, a)`. - /// - /// The `data` field is a `.node_and_extra`: - /// 1. a `Node.Index` to lhs. - /// 2. a `ExtraIndex` to `AsmLegacy`. - /// - /// The `main_token` field is the `asm` token. - asm_legacy, /// `asm(a, b)`. /// /// The `data` field is a `.node_and_extra`: @@ -4089,14 +3979,6 @@ pub const Node = struct { callconv_expr: OptionalIndex, }; - /// To be removed after 0.15.0 is tagged - pub const AsmLegacy = struct { - items_start: ExtraIndex, - items_end: ExtraIndex, - /// Needed to make lastToken() work. - rparen: TokenIndex, - }; - pub const Asm = struct { items_start: ExtraIndex, items_end: ExtraIndex, diff --git a/lib/std/zig/Ast/Render.zig b/lib/std/zig/Ast/Render.zig index b3ba5ffad15f..128d01bc6b45 100644 --- a/lib/std/zig/Ast/Render.zig +++ b/lib/std/zig/Ast/Render.zig @@ -896,9 +896,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void { .@"asm", => return renderAsm(r, tree.fullAsm(node).?, space), - // To be removed after 0.15.0 is tagged - .asm_legacy => return renderAsmLegacy(r, tree.legacyAsm(node).?, space), - .enum_literal => { try renderToken(r, tree.nodeMainToken(node) - 1, .none); // . return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name @@ -2412,185 +2409,6 @@ fn renderContainerDecl( return renderToken(r, rbrace, space); // rbrace } -fn renderAsmLegacy( - r: *Render, - asm_node: Ast.full.AsmLegacy, - space: Space, -) Error!void { - const tree = r.tree; - const ais = r.ais; - - try renderToken(r, asm_node.ast.asm_token, .space); // asm - - if (asm_node.volatile_token) |volatile_token| { - try renderToken(r, volatile_token, .space); // volatile - try renderToken(r, volatile_token + 1, .none); // lparen - } else { - try renderToken(r, asm_node.ast.asm_token + 1, .none); // lparen - } - - if (asm_node.ast.items.len == 0) { - try ais.forcePushIndent(.normal); - if (asm_node.first_clobber) |first_clobber| { - // asm ("foo" ::: "a", "b") - // asm ("foo" ::: "a", "b",) - try renderExpression(r, asm_node.ast.template, .space); - // Render the three colons. - try renderToken(r, first_clobber - 3, .none); - try renderToken(r, first_clobber - 2, .none); - try renderToken(r, first_clobber - 1, .space); - - try ais.writeAll(".{ "); - - var tok_i = first_clobber; - while (true) : (tok_i += 1) { - try ais.writeByte('.'); - _ = try writeStringLiteralAsIdentifier(r, tok_i); - try ais.writeAll(" = true"); - - tok_i += 1; - switch (tree.tokenTag(tok_i)) { - .r_paren => { - try ais.writeAll(" }"); - ais.popIndent(); - return renderToken(r, tok_i, space); - }, - .comma => { - if (tree.tokenTag(tok_i + 1) == .r_paren) { - try ais.writeAll(" }"); - ais.popIndent(); - return renderToken(r, tok_i + 1, space); - } else { - try renderToken(r, tok_i, .space); - } - }, - else => unreachable, - } - } - } else { - unreachable; - } - } - - try ais.forcePushIndent(.normal); - try renderExpression(r, asm_node.ast.template, .newline); - ais.setIndentDelta(asm_indent_delta); - const colon1 = tree.lastToken(asm_node.ast.template) + 1; - - const colon2 = if (asm_node.outputs.len == 0) colon2: { - try renderToken(r, colon1, .newline); // : - break :colon2 colon1 + 1; - } else colon2: { - try renderToken(r, colon1, .space); // : - - try ais.forcePushIndent(.normal); - for (asm_node.outputs, 0..) |asm_output, i| { - if (i + 1 < asm_node.outputs.len) { - const next_asm_output = asm_node.outputs[i + 1]; - try renderAsmOutput(r, asm_output, .none); - - const comma = tree.firstToken(next_asm_output) - 1; - try renderToken(r, comma, .newline); // , - try renderExtraNewlineToken(r, tree.firstToken(next_asm_output)); - } else if (asm_node.inputs.len == 0 and asm_node.first_clobber == null) { - try ais.pushSpace(.comma); - try renderAsmOutput(r, asm_output, .comma); - ais.popSpace(); - ais.popIndent(); - ais.setIndentDelta(indent_delta); - ais.popIndent(); - return renderToken(r, asm_node.ast.rparen, space); // rparen - } else { - try ais.pushSpace(.comma); - try renderAsmOutput(r, asm_output, .comma); - ais.popSpace(); - const comma_or_colon = tree.lastToken(asm_output) + 1; - ais.popIndent(); - break :colon2 switch (tree.tokenTag(comma_or_colon)) { - .comma => comma_or_colon + 1, - else => comma_or_colon, - }; - } - } else unreachable; - }; - - const colon3 = if (asm_node.inputs.len == 0) colon3: { - try renderToken(r, colon2, .newline); // : - break :colon3 colon2 + 1; - } else colon3: { - try renderToken(r, colon2, .space); // : - try ais.forcePushIndent(.normal); - for (asm_node.inputs, 0..) |asm_input, i| { - if (i + 1 < asm_node.inputs.len) { - const next_asm_input = asm_node.inputs[i + 1]; - try renderAsmInput(r, asm_input, .none); - - const first_token = tree.firstToken(next_asm_input); - try renderToken(r, first_token - 1, .newline); // , - try renderExtraNewlineToken(r, first_token); - } else if (asm_node.first_clobber == null) { - try ais.pushSpace(.comma); - try renderAsmInput(r, asm_input, .comma); - ais.popSpace(); - ais.popIndent(); - ais.setIndentDelta(indent_delta); - ais.popIndent(); - return renderToken(r, asm_node.ast.rparen, space); // rparen - } else { - try ais.pushSpace(.comma); - try renderAsmInput(r, asm_input, .comma); - ais.popSpace(); - const comma_or_colon = tree.lastToken(asm_input) + 1; - ais.popIndent(); - break :colon3 switch (tree.tokenTag(comma_or_colon)) { - .comma => comma_or_colon + 1, - else => comma_or_colon, - }; - } - } - unreachable; - }; - - try renderToken(r, colon3, .space); // : - try ais.writeAll(".{ "); - const first_clobber = asm_node.first_clobber.?; - var tok_i = first_clobber; - while (true) { - switch (tree.tokenTag(tok_i + 1)) { - .r_paren => { - ais.setIndentDelta(indent_delta); - try ais.writeByte('.'); - const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i); - try ais.writeAll(" = true }"); - try renderSpace(r, tok_i, lexeme_len, .newline); - ais.popIndent(); - return renderToken(r, tok_i + 1, space); - }, - .comma => { - switch (tree.tokenTag(tok_i + 2)) { - .r_paren => { - ais.setIndentDelta(indent_delta); - try ais.writeByte('.'); - const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i); - try ais.writeAll(" = true }"); - try renderSpace(r, tok_i, lexeme_len, .newline); - ais.popIndent(); - return renderToken(r, tok_i + 2, space); - }, - else => { - try ais.writeByte('.'); - _ = try writeStringLiteralAsIdentifier(r, tok_i); - try ais.writeAll(" = true"); - try renderToken(r, tok_i + 1, .space); - tok_i += 2; - }, - } - }, - else => unreachable, - } - } -} - fn renderAsm( r: *Render, asm_node: Ast.full.Asm, diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index 8a8a88db6f93..016fedaf5e4d 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins .bool_or, .@"asm", .asm_simple, - .asm_legacy, .string_literal, .number_literal, .call, @@ -814,12 +813,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE .@"asm", => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), - .asm_legacy => { - return astgen.failNodeNotes(node, "legacy asm clobbers syntax", .{}, &[_]u32{ - try astgen.errNoteNode(node, "use 'zig fmt' to auto-upgrade", .{}), - }); - }, - .string_literal => return stringLiteral(gz, ri, node), .multiline_string_literal => return multilineStringLiteral(gz, ri, node), @@ -10398,7 +10391,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev .@"asm", .asm_simple, - .asm_legacy, .identifier, .field_access, .deref, @@ -10642,7 +10634,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In .tagged_union_enum_tag_trailing, .@"asm", .asm_simple, - .asm_legacy, .add, .add_wrap, .add_sat, @@ -10881,7 +10872,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { .tagged_union_enum_tag_trailing, .@"asm", .asm_simple, - .asm_legacy, .add, .add_wrap, .add_sat, diff --git a/lib/std/zig/AstRlAnnotate.zig b/lib/std/zig/AstRlAnnotate.zig index 758d329136c6..8b4a1104b849 100644 --- a/lib/std/zig/AstRlAnnotate.zig +++ b/lib/std/zig/AstRlAnnotate.zig @@ -310,7 +310,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI .unreachable_literal, .asm_simple, .@"asm", - .asm_legacy, .enum_literal, .error_value, .anyframe_literal, diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig index 47834681c198..dee6742dca4d 100644 --- a/lib/std/zig/Parse.zig +++ b/lib/std/zig/Parse.zig @@ -2857,32 +2857,6 @@ fn expectAsmExpr(p: *Parse) !Node.Index { _ = p.eatToken(.colon) orelse break :clobbers .none; - // For automatic upgrades; delete after 0.15.0 released. - if (p.tokenTag(p.tok_i) == .string_literal) { - while (p.eatToken(.string_literal)) |_| { - switch (p.tokenTag(p.tok_i)) { - .comma => p.tok_i += 1, - .colon, .r_paren, .r_brace, .r_bracket => break, - // Likely just a missing comma; give error but continue parsing. - else => try p.warnExpected(.comma), - } - } - const rparen = try p.expectToken(.r_paren); - const span = try p.listToSpan(p.scratch.items[scratch_top..]); - return p.addNode(.{ - .tag = .asm_legacy, - .main_token = asm_token, - .data = .{ .node_and_extra = .{ - template, - try p.addExtra(Node.AsmLegacy{ - .items_start = span.start, - .items_end = span.end, - .rparen = rparen, - }), - } }, - }); - } - break :clobbers (try p.expectExpr()).toOptional(); } else .none; diff --git a/lib/std/zig/ZonGen.zig b/lib/std/zig/ZonGen.zig index 4bb299a5e908..791071cfb470 100644 --- a/lib/std/zig/ZonGen.zig +++ b/lib/std/zig/ZonGen.zig @@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}), .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}), - .asm_simple, .@"asm", .asm_legacy => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), + .asm_simple, .@"asm" => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), .builtin_call_two, .builtin_call_two_comma, diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index c3451f523876..8cf5ccbce1b5 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -31,54 +31,16 @@ test "zig fmt: tuple struct" { } test "zig fmt: preserves clobbers in inline asm with stray comma" { - try testTransform( - \\fn foo() void { - \\ asm volatile ("" - \\ : [_] "" (-> type), - \\ : - \\ : "clobber" - \\ ); - \\ asm volatile ("" - \\ : - \\ : [_] "" (type), - \\ : "clobber" - \\ ); - \\} - \\ - , + try testCanonical( \\fn foo() void { \\ asm volatile ("" \\ : [_] "" (-> type), \\ : - \\ : .{ .clobber = true } - \\ ); + \\ : .{ .clobber = true }); \\ asm volatile ("" \\ : \\ : [_] "" (type), - \\ : .{ .clobber = true } - \\ ); - \\} - \\ - ); -} - -test "zig fmt: remove trailing comma at the end of assembly clobber" { - try testTransform( - \\fn foo() void { - \\ asm volatile ("" - \\ : [_] "" (-> type), - \\ : - \\ : "clobber1", "clobber2", - \\ ); - \\} - \\ - , - \\fn foo() void { - \\ asm volatile ("" - \\ : [_] "" (-> type), - \\ : - \\ : .{ .clobber1 = true, .clobber2 = true } - \\ ); + \\ : .{ .clobber = true }); \\} \\ ); @@ -641,27 +603,7 @@ test "zig fmt: builtin call with trailing comma" { } test "zig fmt: asm expression with comptime content" { - try testTransform( - \\comptime { - \\ asm ("foo" ++ "bar"); - \\} - \\pub fn main() void { - \\ asm volatile ("foo" ++ "bar"); - \\ asm volatile ("foo" ++ "bar" - \\ : [_] "" (x), - \\ ); - \\ asm volatile ("foo" ++ "bar" - \\ : [_] "" (x), - \\ : [_] "" (y), - \\ ); - \\ asm volatile ("foo" ++ "bar" - \\ : [_] "" (x), - \\ : [_] "" (y), - \\ : "h", "e", "l", "l", "o" - \\ ); - \\} - \\ - , + try testCanonical( \\comptime { \\ asm ("foo" ++ "bar"); \\} @@ -677,8 +619,7 @@ test "zig fmt: asm expression with comptime content" { \\ asm volatile ("foo" ++ "bar" \\ : [_] "" (x), \\ : [_] "" (y), - \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true } - \\ ); + \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true }); \\} \\ ); @@ -2198,7 +2139,7 @@ test "zig fmt: simple asm" { \\ asm ("not real assembly" \\ :[a] "x" (->i32),:[a] "x" (1),); \\ asm ("still not real assembly" - \\ :::"a","b",); + \\ :::.{.a=true,.b=true}); \\} , \\comptime { @@ -3940,24 +3881,13 @@ test "zig fmt: fn type" { } test "zig fmt: inline asm" { - try testTransform( - \\pub fn syscall1(number: usize, arg1: usize) usize { - \\ return asm volatile ("syscall" - \\ : [ret] "={rax}" (-> usize), - \\ : [number] "{rax}" (number), - \\ [arg1] "{rdi}" (arg1), - \\ : "rcx", "r11" - \\ ); - \\} - \\ - , + try testCanonical( \\pub fn syscall1(number: usize, arg1: usize) usize { \\ return asm volatile ("syscall" \\ : [ret] "={rax}" (-> usize), \\ : [number] "{rax}" (number), \\ [arg1] "{rdi}" (arg1), - \\ : .{ .rcx = true, .r11 = true } - \\ ); + \\ : .{ .rcx = true, .r11 = true }); \\} \\ ); @@ -5779,8 +5709,7 @@ test "zig fmt: canonicalize symbols (asm)" { \\ [@"arg1"] "{rdi}" (arg), \\ [arg2] "{rsi}" (arg), \\ [arg3] "{rdx}" (arg), - \\ : "rcx", "fn" - \\ ); + \\ : .{ .rcx = true, .@"fn" = true }); \\ \\ const @"false": usize = 10; \\ const @"true" = "explode"; @@ -5801,8 +5730,7 @@ test "zig fmt: canonicalize symbols (asm)" { \\ [arg1] "{rdi}" (arg), \\ [arg2] "{rsi}" (arg), \\ [arg3] "{rdx}" (arg), - \\ : .{ .rcx = true, .@"fn" = true } - \\ ); + \\ : .{ .rcx = true, .@"fn" = true }); \\ \\ const @"false": usize = 10; \\ const @"true" = "explode"; diff --git a/test/standalone/config_header/build.zig b/test/standalone/config_header/build.zig index 3432685fceda..733a39690770 100644 --- a/test/standalone/config_header/build.zig +++ b/test/standalone/config_header/build.zig @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void { }, ); - const check_config_header = b.addCheckFile(config_header.getOutput(), .{ .expected_exact = @embedFile("config.h") }); + const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ .expected_exact = @embedFile("config.h") }); const test_step = b.step("test", "Test it"); test_step.dependOn(&check_config_header.step); diff --git a/test/standalone/test_obj_link_run/build.zig b/test/standalone/test_obj_link_run/build.zig index 19d52ce68c3f..24e0e961e7e0 100644 --- a/test/standalone/test_obj_link_run/build.zig +++ b/test/standalone/test_obj_link_run/build.zig @@ -9,9 +9,9 @@ pub fn build(b: *std.Build) void { }), }); if (is_windows) { - test_obj.linkSystemLibrary("ntdll"); - test_obj.linkSystemLibrary("kernel32"); - test_obj.linkSystemLibrary("ws2_32"); + test_obj.root_module.linkSystemLibrary("ntdll", .{}); + test_obj.root_module.linkSystemLibrary("kernel32", .{}); + test_obj.root_module.linkSystemLibrary("ws2_32", .{}); } const test_exe_mod = b.createModule(.{