authorgravatar for mail@linusgroh.delinus <mail@linusgroh.de> 2026-05-19 11:41:52+02:00
committergravatar for mail@linusgroh.delinus <mail@linusgroh.de> 2026-05-19 11:41:52+02:00
log30698b03c0420e897244441a60a8a8d1a4ade9f4
tree3c64315414e67080f7b45957cba7799e5e6ad56e
parent71f23402bcbb8554d5663ac5aa870abd69fda10f
parent75c717bd064ac8cd21ee32b57b73b2a8673f1e41

Merge pull request 'std: Remove more deprecated functions' (#35253) from linus/zig:more-deprecations into master

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

11 files changed, 20 insertions(+), 96 deletions(-)

lib/compiler/aro/aro/Preprocessor.zig+2-2
...@@ -45,11 +45,11 @@ const IfContext = struct {...@@ -45,11 +45,11 @@ const IfContext = struct {
45 level: u8,45 level: u8,
4646
47 fn get(self: *const IfContext) Nesting {47 fn get(self: *const IfContext) Nesting {
48 return @enumFromInt(std.mem.readPackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2));48 return @enumFromInt(std.mem.readPackedInt(Backing, &self.kind, @as(usize, self.level) * 2, .native));
49 }49 }
5050
51 fn set(self: *IfContext, context: Nesting) void {51 fn set(self: *IfContext, context: Nesting) void {
52 std.mem.writePackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context));52 std.mem.writePackedInt(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context), .native);
53 }53 }
5454
55 fn increment(self: *IfContext) bool {55 fn increment(self: *IfContext) bool {
lib/compiler/aro/backend/Ir/x86/Renderer.zig+3-3
...@@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo...@@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo
21const RegisterBitSet = RegisterManager.RegisterBitSet;21const RegisterBitSet = RegisterManager.RegisterBitSet;
22const RegisterClass = struct {22const RegisterClass = struct {
23 const gp: RegisterBitSet = blk: {23 const gp: RegisterBitSet = blk: {
24 var set = RegisterBitSet.initEmpty();24 var set: RegisterBitSet = .empty;
25 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);25 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);
26 break :blk set;26 break :blk set;
27 };27 };
28 const x87: RegisterBitSet = blk: {28 const x87: RegisterBitSet = blk: {
29 var set = RegisterBitSet.initEmpty();29 var set: RegisterBitSet = .empty;
30 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);30 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);
31 break :blk set;31 break :blk set;
32 };32 };
33 const sse: RegisterBitSet = blk: {33 const sse: RegisterBitSet = blk: {
34 var set = RegisterBitSet.initEmpty();34 var set: RegisterBitSet = .empty;
35 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);35 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);
36 break :blk set;36 break :blk set;
37 };37 };
lib/compiler_rt/float_from_int.zig+1-1
...@@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin...@@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin
97 if (limb(x, limb_index) != 0) break true;97 if (limb(x, limb_index) != 0) break true;
98 } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0;98 } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0;
99 return math.ldexp(@as(T, @floatFromInt(99 return math.ldexp(@as(T, @floatFromInt(
100 std.mem.readPackedIntNative(I, std.mem.sliceAsBytes(x), exponent) | @intFromBool(sticky),100 std.mem.readPackedInt(I, std.mem.sliceAsBytes(x), exponent, .native) | @intFromBool(sticky),
101 )), @intCast(exponent));101 )), @intCast(exponent));
102}102}
103103
lib/compiler_rt/int_from_float.zig+1-1
...@@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul...@@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul
141 },141 },
142 .unsigned => @memset(result, 0),142 .unsigned => @memset(result, 0),
143 }143 }
144 std.mem.writePackedIntNative(I, std.mem.sliceAsBytes(result), exponent, int);144 std.mem.writePackedInt(I, std.mem.sliceAsBytes(result), exponent, int, .native);
145}145}
146146
147test {147test {
lib/std/Io/Threaded.zig+1-1
...@@ -14401,7 +14401,7 @@ pub fn setTimestampToPosix(set_ts: File.SetTimestamp) posix.timespec {...@@ -14401,7 +14401,7 @@ pub fn setTimestampToPosix(set_ts: File.SetTimestamp) posix.timespec {
14401}14401}
1440214402
14403pub fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Dir.PathNameError![:0]u8 {14403pub fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Dir.PathNameError![:0]u8 {
14404 if (std.mem.containsAtLeastScalar2(u8, file_path, 0, 1)) return error.BadPathName;14404 if (std.mem.containsAtLeastScalar(u8, file_path, 0, 1)) return error.BadPathName;
14405 // >= rather than > to make room for the null byte14405 // >= rather than > to make room for the null byte
14406 if (file_path.len >= buffer.len) return error.NameTooLong;14406 if (file_path.len >= buffer.len) return error.NameTooLong;
14407 @memcpy(buffer[0..file_path.len], file_path);14407 @memcpy(buffer[0..file_path.len], file_path);
lib/std/ascii.zig-9
...@@ -378,17 +378,11 @@ test endsWithIgnoreCase {...@@ -378,17 +378,11 @@ test endsWithIgnoreCase {
378 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));378 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));
379}379}
380380
381/// Deprecated in favor of `findIgnoreCase`.
382pub const indexOfIgnoreCase = findIgnoreCase;
383
384/// Finds `needle` in `haystack`, ignoring case, starting at index 0.381/// Finds `needle` in `haystack`, ignoring case, starting at index 0.
385pub fn findIgnoreCase(haystack: []const u8, needle: []const u8) ?usize {382pub fn findIgnoreCase(haystack: []const u8, needle: []const u8) ?usize {
386 return findIgnoreCasePos(haystack, 0, needle);383 return findIgnoreCasePos(haystack, 0, needle);
387}384}
388385
389/// Deprecated in favor of `findIgnoreCasePos`.
390pub const indexOfIgnoreCasePos = findIgnoreCasePos;
391
392/// Finds `needle` in `haystack`, ignoring case, starting at `start_index`.386/// Finds `needle` in `haystack`, ignoring case, starting at `start_index`.
393/// Uses Boyer-Moore-Horspool algorithm on large inputs; `findIgnoreCasePosLinear` on small inputs.387/// Uses Boyer-Moore-Horspool algorithm on large inputs; `findIgnoreCasePosLinear` on small inputs.
394pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {388pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {
...@@ -410,9 +404,6 @@ pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []con...@@ -410,9 +404,6 @@ pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []con
410 return null;404 return null;
411}405}
412406
413/// Deprecated in favor of `findIgnoreCaseLinear`.
414pub const indexOfIgnoreCasePosLinear = findIgnoreCasePosLinear;
415
416/// Consider using `findIgnoreCasePos` instead of this, which will automatically use a407/// Consider using `findIgnoreCasePos` instead of this, which will automatically use a
417/// more sophisticated algorithm on larger inputs.408/// more sophisticated algorithm on larger inputs.
418pub fn findIgnoreCasePosLinear(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {409pub fn findIgnoreCasePosLinear(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {
lib/std/bit_set.zig-24
...@@ -73,18 +73,6 @@ pub fn Integer(comptime size: u16) type {...@@ -73,18 +73,6 @@ pub fn Integer(comptime size: u16) type {
73 /// The bit mask, as a single integer73 /// The bit mask, as a single integer
74 mask: MaskInt,74 mask: MaskInt,
7575
76 /// Deprecated: use `.empty`.
77 /// Creates a bit set with no elements present.
78 pub fn initEmpty() Self {
79 return .{ .mask = 0 };
80 }
81
82 /// Deprecated: use `.full`.
83 /// Creates a bit set with all elements present.
84 pub fn initFull() Self {
85 return .{ .mask = ~@as(MaskInt, 0) };
86 }
87
88 /// A bit set with no elements present.76 /// A bit set with no elements present.
89 pub const empty: Self = .{ .mask = 0 };77 pub const empty: Self = .{ .mask = 0 };
9078
...@@ -403,18 +391,6 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type {...@@ -403,18 +391,6 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type {
403 /// Padding bits at the end are undefined.391 /// Padding bits at the end are undefined.
404 masks: [num_masks]MaskInt,392 masks: [num_masks]MaskInt,
405393
406 /// Deprecated: use `.empty`.
407 /// Creates a bit set with no elements present.
408 pub fn initEmpty() Self {
409 return .empty;
410 }
411
412 /// Deprecated: use `.full`.
413 /// Creates a bit set with all elements present.
414 pub fn initFull() Self {
415 return .full;
416 }
417
418 /// A bit set with no elements present.394 /// A bit set with no elements present.
419 pub const empty: Self = .{ .masks = @splat(0) };395 pub const empty: Self = .{ .masks = @splat(0) };
420396
lib/std/enums.zig-12
...@@ -284,18 +284,6 @@ pub fn EnumSet(comptime E: type) type {...@@ -284,18 +284,6 @@ pub fn EnumSet(comptime E: type) type {
284 /// A set containing all possible keys.284 /// A set containing all possible keys.
285 pub const full: Self = .{ .bits = .full };285 pub const full: Self = .{ .bits = .full };
286286
287 /// Deprecated: use `.empty`.
288 /// Returns a set containing no keys.
289 pub fn initEmpty() Self {
290 return .empty;
291 }
292
293 /// Deprecated: use `.full`.
294 /// Returns a set containing all possible keys.
295 pub fn initFull() Self {
296 return .full;
297 }
298
299 /// Returns a set containing multiple keys.287 /// Returns a set containing multiple keys.
300 pub fn initMany(keys: []const Key) Self {288 pub fn initMany(keys: []const Key) Self {
301 var set: Self = .empty;289 var set: Self = .empty;
lib/std/mem.zig+9-38
...@@ -1691,7 +1691,7 @@ test countScalar {...@@ -1691,7 +1691,7 @@ test countScalar {
1691//1691//
1692/// See also: `containsAtLeastScalar`1692/// See also: `containsAtLeastScalar`
1693pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: usize, needle: []const T) bool {1693pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: usize, needle: []const T) bool {
1694 if (needle.len == 1) return containsAtLeastScalar(T, haystack, expected_count, needle[0]);1694 if (needle.len == 1) return containsAtLeastScalar(T, haystack, needle[0], expected_count);
1695 assert(needle.len > 0);1695 assert(needle.len > 0);
1696 if (expected_count == 0) return true;1696 if (expected_count == 0) return true;
16971697
...@@ -1722,17 +1722,12 @@ test containsAtLeast {...@@ -1722,17 +1722,12 @@ test containsAtLeast {
1722 try testing.expect(!containsAtLeast(u8, " radar radar ", 3, "radar"));1722 try testing.expect(!containsAtLeast(u8, " radar radar ", 3, "radar"));
1723}1723}
17241724
1725/// Deprecated in favor of `containsAtLeastScalar2`.
1726pub fn containsAtLeastScalar(comptime T: type, list: []const T, minimum: usize, element: T) bool {
1727 return containsAtLeastScalar2(T, list, element, minimum);
1728}
1729
1730/// Returns true if `element` appears at least `minimum` number of times in `list`.1725/// Returns true if `element` appears at least `minimum` number of times in `list`.
1731//1726//
1732/// Related:1727/// Related:
1733/// * `containsAtLeast`1728/// * `containsAtLeast`
1734/// * `countScalar`1729/// * `countScalar`
1735pub fn containsAtLeastScalar2(comptime T: type, list: []const T, element: T, minimum: usize) bool {1730pub fn containsAtLeastScalar(comptime T: type, list: []const T, element: T, minimum: usize) bool {
1736 const n = list.len;1731 const n = list.len;
1737 var i: usize = 0;1732 var i: usize = 0;
1738 var found: usize = 0;1733 var found: usize = 0;
...@@ -1760,14 +1755,14 @@ pub fn containsAtLeastScalar2(comptime T: type, list: []const T, element: T, min...@@ -1760,14 +1755,14 @@ pub fn containsAtLeastScalar2(comptime T: type, list: []const T, element: T, min
1760 return false;1755 return false;
1761}1756}
17621757
1763test containsAtLeastScalar2 {1758test containsAtLeastScalar {
1764 try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 0));1759 try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 0));
1765 try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 1));1760 try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 1));
1766 try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 2));1761 try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 2));
1767 try testing.expect(!containsAtLeastScalar2(u8, "aa", 'a', 3));1762 try testing.expect(!containsAtLeastScalar(u8, "aa", 'a', 3));
17681763
1769 try testing.expect(containsAtLeastScalar2(u8, "adadda", 'd', 3));1764 try testing.expect(containsAtLeastScalar(u8, "adadda", 'd', 3));
1770 try testing.expect(!containsAtLeastScalar2(u8, "adadda", 'd', 4));1765 try testing.expect(!containsAtLeastScalar(u8, "adadda", 'd', 4));
1771}1766}
17721767
1773/// Reads an integer from memory with size equal to bytes.len.1768/// Reads an integer from memory with size equal to bytes.len.
...@@ -1973,18 +1968,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {...@@ -1973,18 +1968,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {
1973 } else return @as(T, @bitCast(val));1968 } else return @as(T, @bitCast(val));
1974}1969}
19751970
1976/// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .native)
1977pub const readPackedIntNative = switch (native_endian) {
1978 .little => readPackedIntLittle,
1979 .big => readPackedIntBig,
1980};
1981
1982/// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .foreign)
1983pub const readPackedIntForeign = switch (native_endian) {
1984 .little => readPackedIntBig,
1985 .big => readPackedIntLittle,
1986};
1987
1988/// Loads an integer from packed memory.1971/// Loads an integer from packed memory.
1989/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.1972/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
1990pub fn readPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, endian: Endian) T {1973pub fn readPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, endian: Endian) T {
...@@ -2128,18 +2111,6 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T)...@@ -2128,18 +2111,6 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T)
2128 writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big);2111 writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big);
2129}2112}
21302113
2131/// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .native)
2132pub const writePackedIntNative = switch (native_endian) {
2133 .little => writePackedIntLittle,
2134 .big => writePackedIntBig,
2135};
2136
2137/// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .foreign)
2138pub const writePackedIntForeign = switch (native_endian) {
2139 .little => writePackedIntBig,
2140 .big => writePackedIntLittle,
2141};
2142
2143/// Stores an integer to packed memory.2114/// Stores an integer to packed memory.
2144/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.2115/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
2145pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void {2116pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void {
src/Package/Fetch.zig+2-2
...@@ -1151,10 +1151,10 @@ const FileType = enum {...@@ -1151,10 +1151,10 @@ const FileType = enum {
11511151
1152 /// Parameter is a content-disposition header value.1152 /// Parameter is a content-disposition header value.
1153 fn fromContentDisposition(cd_header: []const u8) ?FileType {1153 fn fromContentDisposition(cd_header: []const u8) ?FileType {
1154 const attach_end = ascii.indexOfIgnoreCase(cd_header, "attachment;") orelse1154 const attach_end = ascii.findIgnoreCase(cd_header, "attachment;") orelse
1155 return null;1155 return null;
11561156
1157 var value_start = ascii.indexOfIgnoreCasePos(cd_header, attach_end + 1, "filename") orelse1157 var value_start = ascii.findIgnoreCasePos(cd_header, attach_end + 1, "filename") orelse
1158 return null;1158 return null;
1159 value_start += "filename".len;1159 value_start += "filename".len;
1160 if (cd_header[value_start] == '*') {1160 if (cd_header[value_start] == '*') {
src/codegen/x86_64/CodeGen.zig+1-3
...@@ -187562,9 +187562,7 @@ const Temp = struct {...@@ -187562,9 +187562,7 @@ const Temp = struct {
187562 const max = std.math.maxInt(@typeInfo(Index).@"enum".tag_type);187562 const max = std.math.maxInt(@typeInfo(Index).@"enum".tag_type);
187563 const Set = std.bit_set.Static(max);187563 const Set = std.bit_set.Static(max);
187564 const SafetySet = if (std.debug.runtime_safety) Set else struct {187564 const SafetySet = if (std.debug.runtime_safety) Set else struct {
187565 inline fn initEmpty() @This() {187565 pub const empty: @This() = .{};
187566 return .{};
187567 }
187568187566
187569 inline fn isSet(_: @This(), index: usize) bool {187567 inline fn isSet(_: @This(), index: usize) bool {
187570 assert(index < max);187568 assert(index < max);