From 3e62cb5c90608580558fff1af24af68735778392 Mon Sep 17 00:00:00 2001 From: PauloCampana <101306295+PauloCampana@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:50:25 -0300 Subject: [PATCH] Remove old deprecated symbols in std (#21584) Also, actually run tests inside std/tar/writer.zig --- doc/langref.html.in | 12 +++++++----- lib/std/heap.zig | 2 -- lib/std/mem.zig | 4 ---- lib/std/meta.zig | 6 ------ lib/std/tar.zig | 1 + lib/std/tar/writer.zig | 10 +++++----- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 9f12829349..8a280387d2 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -4766,10 +4766,10 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val Converts an integer into an {#link|enum#} value. The return type is the inferred result type.

- Attempting to convert an integer with no corresponding value in the enum invokes + Attempting to convert an integer with no corresponding value in the enum invokes safety-checked {#link|Undefined Behavior#}. Note that a {#link|non-exhaustive enum|Non-exhaustive enum#} has corresponding values for all - integers in the enum's integer tag type: the {#syntax#}_{#endsyntax#} value represents all + integers in the enum's integer tag type: the {#syntax#}_{#endsyntax#} value represents all the remaining unnamed integers in the enum's tag type.

{#see_also|@intFromEnum#} @@ -6241,11 +6241,13 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
  • Are you linking libc? In this case, {#syntax#}std.heap.c_allocator{#endsyntax#} is likely the right choice, at least for your main allocator.
  • +
  • + Need to use the same allocator in multiple threads? Use one of your choice + wrapped around {#syntax#}std.heap.ThreadSafeAllocator{#endsyntax#} +
  • Is the maximum number of bytes that you will need bounded by a number known at - {#link|comptime#}? In this case, use {#syntax#}std.heap.FixedBufferAllocator{#endsyntax#} or - {#syntax#}std.heap.ThreadSafeFixedBufferAllocator{#endsyntax#} depending on whether you need - thread-safety or not. + {#link|comptime#}? In this case, use {#syntax#}std.heap.FixedBufferAllocator{#endsyntax#}.
  • Is your program a command line application which runs from start to end without any fundamental diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 18332c79a8..3d19d8daa6 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -501,8 +501,6 @@ pub const FixedBufferAllocator = struct { } }; -pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `threadSafeAllocator` on FixedBufferAllocator"); - /// Returns a `StackFallbackAllocator` allocating using either a /// `FixedBufferAllocator` on an array of size `size` and falling back to /// `fallback_allocator` if that fails. diff --git a/lib/std/mem.zig b/lib/std/mem.zig index b4580b1aa4..d458e26989 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -4334,8 +4334,6 @@ pub fn alignForwardLog2(addr: usize, log2_alignment: u8) usize { return alignForward(usize, addr, alignment); } -pub const alignForwardGeneric = @compileError("renamed to alignForward"); - /// Force an evaluation of the expression; this tries to prevent /// the compiler from optimizing the computation away even if the /// result eventually gets discarded. @@ -4459,8 +4457,6 @@ pub fn alignBackward(comptime T: type, addr: T, alignment: T) T { return addr & ~(alignment - 1); } -pub const alignBackwardGeneric = @compileError("renamed to alignBackward"); - /// Returns whether `alignment` is a valid alignment, meaning it is /// a positive power of 2. pub fn isValidAlign(alignment: usize) bool { diff --git a/lib/std/meta.zig b/lib/std/meta.zig index e7ea5b5f0e..ff0cec1b18 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -240,8 +240,6 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { @compileError("Unable to derive a sentinel pointer type from " ++ @typeName(T)); } -pub const assumeSentinel = @compileError("This function has been removed, consider using std.mem.sliceTo() or if needed a @ptrCast()"); - pub fn containerLayout(comptime T: type) Type.ContainerLayout { return switch (@typeInfo(T)) { .@"struct" => |info| info.layout, @@ -930,8 +928,6 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { return null; } -pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta to std.testing"); - /// Returns a slice of pointers to public declarations of a namespace. pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl { const S = struct { @@ -951,8 +947,6 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De } } -pub const IntType = @compileError("replaced by std.meta.Int"); - pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type { return @Type(.{ .int = .{ diff --git a/lib/std/tar.zig b/lib/std/tar.zig index f15a5e8c8a..060b802f19 100644 --- a/lib/std/tar.zig +++ b/lib/std/tar.zig @@ -848,6 +848,7 @@ test PaxIterator { test { _ = @import("tar/test.zig"); + _ = @import("tar/writer.zig"); _ = Diagnostics; } diff --git a/lib/std/tar/writer.zig b/lib/std/tar/writer.zig index e75e6c42d6..4ced287eec 100644 --- a/lib/std/tar/writer.zig +++ b/lib/std/tar/writer.zig @@ -84,7 +84,7 @@ pub fn Writer(comptime WriterType: type) type { /// Writes fs.Dir.WalkerEntry. Uses `mtime` from file system entry and /// default for entry mode . - pub fn writeEntry(self: *Self, entry: std.fs.Dir.Walker.WalkerEntry) !void { + pub fn writeEntry(self: *Self, entry: std.fs.Dir.Walker.Entry) !void { switch (entry.kind) { .directory => { try self.writeDir(entry.path, .{ .mtime = try entryMtime(entry) }); @@ -95,7 +95,7 @@ pub fn Writer(comptime WriterType: type) type { try self.writeFile(entry.path, file); }, .sym_link => { - var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; + var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined; const link_name = try entry.dir.readLink(entry.basename, &link_name_buffer); try self.writeLink(entry.path, link_name, .{ .mtime = try entryMtime(entry) }); }, @@ -133,7 +133,7 @@ pub fn Writer(comptime WriterType: type) type { return self.mtime_now; } - fn entryMtime(entry: std.fs.Dir.Walker.WalkerEntry) !u64 { + fn entryMtime(entry: std.fs.Dir.Walker.Entry) !u64 { const stat = try entry.dir.statFile(entry.basename); return @intCast(@divFloor(stat.mtime, std.time.ns_per_s)); } @@ -424,8 +424,8 @@ test "write files" { .{ .path = "e123456789" ** 11, .content = "e" }, }; - var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; - var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; + var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined; + var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined; // with root {