diff --git a/lib/compiler/aro/assembly_backend/x86_64.zig b/lib/compiler/aro/assembly_backend/x86_64.zig index ff106e9d8b..247c5bf186 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 = @Int(.unsigned, 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/docs/wasm/markdown.zig b/lib/docs/wasm/markdown.zig index 6e9b7a0603..a15af8869c 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 4f9900ab59..7be41ebbea 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -188,9 +188,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, @@ -540,7 +537,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. @@ -683,18 +680,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, @@ -808,46 +793,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; } @@ -929,84 +874,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"); @@ -1763,7 +1630,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 3f89bf8ec9..8c0d3032da 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 764d2830ff..ff65aa42a7 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -88,9 +88,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, @@ -223,7 +220,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, @@ -2217,7 +2213,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 78963dcdab..591d7d71b4 100644 --- a/lib/std/Io/Reader.zig +++ b/lib/std/Io/Reader.zig @@ -1252,7 +1252,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 1b80b5b4f7..f49ef8eb67 100644 --- a/lib/std/Io/Writer.zig +++ b/lib/std/Io/Writer.zig @@ -1211,10 +1211,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 => { @@ -1702,7 +1698,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 4f5ec8fd2d..3e2bb0969d 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 f6e334af8e..d3a06819bf 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 29c0731f4e..97c2c9055c 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -329,16 +329,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| { @@ -358,7 +358,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 ffc678d772..2b7bdade00 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -202,48 +202,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 4480009781..3183becd82 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 431f239db3..fc3b3d3e35 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 5c1c4f4394..54f44981d1 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1221,9 +1221,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; @@ -1235,9 +1232,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 77e288ecaa..677e359b34 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -614,38 +614,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 { @@ -774,14 +742,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 f5533a54bd..c3ffe82d3f 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 bb660a3b8e..0ada2a7899 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 aaaaa1d948..c9c41dd042 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 d12ac3bf21..2aa282d110 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -1160,7 +1160,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/test/standalone/config_header/build.zig b/test/standalone/config_header/build.zig index 3432685fce..733a396907 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 19d52ce68c..24e0e961e7 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(.{