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 {
4545 level: u8,
4646
4747 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));
4949 }
5050
5151 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);
5353 }
5454
5555 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
2121const RegisterBitSet = RegisterManager.RegisterBitSet;
2222const RegisterClass = struct {
2323 const gp: RegisterBitSet = blk: {
24 var set = RegisterBitSet.initEmpty();
24 var set: RegisterBitSet = .empty;
2525 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);
2626 break :blk set;
2727 };
2828 const x87: RegisterBitSet = blk: {
29 var set = RegisterBitSet.initEmpty();
29 var set: RegisterBitSet = .empty;
3030 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);
3131 break :blk set;
3232 };
3333 const sse: RegisterBitSet = blk: {
34 var set = RegisterBitSet.initEmpty();
34 var set: RegisterBitSet = .empty;
3535 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);
3636 break :blk set;
3737 };
lib/compiler_rt/float_from_int.zig+1-1
......@@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin
9797 if (limb(x, limb_index) != 0) break true;
9898 } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0;
9999 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),
101101 )), @intCast(exponent));
102102}
103103
lib/compiler_rt/int_from_float.zig+1-1
......@@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul
141141 },
142142 .unsigned => @memset(result, 0),
143143 }
144 std.mem.writePackedIntNative(I, std.mem.sliceAsBytes(result), exponent, int);
144 std.mem.writePackedInt(I, std.mem.sliceAsBytes(result), exponent, int, .native);
145145}
146146
147147test {
lib/std/Io/Threaded.zig+1-1
......@@ -14401,7 +14401,7 @@ pub fn setTimestampToPosix(set_ts: File.SetTimestamp) posix.timespec {
1440114401}
1440214402
1440314403pub 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;
1440514405 // >= rather than > to make room for the null byte
1440614406 if (file_path.len >= buffer.len) return error.NameTooLong;
1440714407 @memcpy(buffer[0..file_path.len], file_path);
lib/std/ascii.zig-9
......@@ -378,17 +378,11 @@ test endsWithIgnoreCase {
378378 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));
379379}
380380
381/// Deprecated in favor of `findIgnoreCase`.
382pub const indexOfIgnoreCase = findIgnoreCase;
383
384381/// Finds `needle` in `haystack`, ignoring case, starting at index 0.
385382pub fn findIgnoreCase(haystack: []const u8, needle: []const u8) ?usize {
386383 return findIgnoreCasePos(haystack, 0, needle);
387384}
388385
389/// Deprecated in favor of `findIgnoreCasePos`.
390pub const indexOfIgnoreCasePos = findIgnoreCasePos;
391
392386/// Finds `needle` in `haystack`, ignoring case, starting at `start_index`.
393387/// Uses Boyer-Moore-Horspool algorithm on large inputs; `findIgnoreCasePosLinear` on small inputs.
394388pub 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
410404 return null;
411405}
412406
413/// Deprecated in favor of `findIgnoreCaseLinear`.
414pub const indexOfIgnoreCasePosLinear = findIgnoreCasePosLinear;
415
416407/// Consider using `findIgnoreCasePos` instead of this, which will automatically use a
417408/// more sophisticated algorithm on larger inputs.
418409pub 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 {
7373 /// The bit mask, as a single integer
7474 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
8876 /// A bit set with no elements present.
8977 pub const empty: Self = .{ .mask = 0 };
9078
......@@ -403,18 +391,6 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type {
403391 /// Padding bits at the end are undefined.
404392 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
418394 /// A bit set with no elements present.
419395 pub const empty: Self = .{ .masks = @splat(0) };
420396
lib/std/enums.zig-12
......@@ -284,18 +284,6 @@ pub fn EnumSet(comptime E: type) type {
284284 /// A set containing all possible keys.
285285 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
299287 /// Returns a set containing multiple keys.
300288 pub fn initMany(keys: []const Key) Self {
301289 var set: Self = .empty;
lib/std/mem.zig+9-38
......@@ -1691,7 +1691,7 @@ test countScalar {
16911691//
16921692/// See also: `containsAtLeastScalar`
16931693pub 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);
16951695 assert(needle.len > 0);
16961696 if (expected_count == 0) return true;
16971697
......@@ -1722,17 +1722,12 @@ test containsAtLeast {
17221722 try testing.expect(!containsAtLeast(u8, " radar radar ", 3, "radar"));
17231723}
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
17301725/// Returns true if `element` appears at least `minimum` number of times in `list`.
17311726//
17321727/// Related:
17331728/// * `containsAtLeast`
17341729/// * `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 {
17361731 const n = list.len;
17371732 var i: usize = 0;
17381733 var found: usize = 0;
......@@ -1760,14 +1755,14 @@ pub fn containsAtLeastScalar2(comptime T: type, list: []const T, element: T, min
17601755 return false;
17611756}
17621757
1763test containsAtLeastScalar2 {
1764 try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 0));
1765 try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 1));
1766 try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 2));
1767 try testing.expect(!containsAtLeastScalar2(u8, "aa", 'a', 3));
1758test containsAtLeastScalar {
1759 try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 0));
1760 try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 1));
1761 try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 2));
1762 try testing.expect(!containsAtLeastScalar(u8, "aa", 'a', 3));
17681763
1769 try testing.expect(containsAtLeastScalar2(u8, "adadda", 'd', 3));
1770 try testing.expect(!containsAtLeastScalar2(u8, "adadda", 'd', 4));
1764 try testing.expect(containsAtLeastScalar(u8, "adadda", 'd', 3));
1765 try testing.expect(!containsAtLeastScalar(u8, "adadda", 'd', 4));
17711766}
17721767
17731768/// 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 {
19731968 } else return @as(T, @bitCast(val));
19741969}
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
19881971/// Loads an integer from packed memory.
19891972/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
19901973pub 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)
21282111 writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big);
21292112}
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
21432114/// Stores an integer to packed memory.
21442115/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
21452116pub 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 {
11511151
11521152 /// Parameter is a content-disposition header value.
11531153 fn fromContentDisposition(cd_header: []const u8) ?FileType {
1154 const attach_end = ascii.indexOfIgnoreCase(cd_header, "attachment;") orelse
1154 const attach_end = ascii.findIgnoreCase(cd_header, "attachment;") orelse
11551155 return null;
11561156
1157 var value_start = ascii.indexOfIgnoreCasePos(cd_header, attach_end + 1, "filename") orelse
1157 var value_start = ascii.findIgnoreCasePos(cd_header, attach_end + 1, "filename") orelse
11581158 return null;
11591159 value_start += "filename".len;
11601160 if (cd_header[value_start] == '*') {
src/codegen/x86_64/CodeGen.zig+1-3
......@@ -187562,9 +187562,7 @@ const Temp = struct {
187562187562 const max = std.math.maxInt(@typeInfo(Index).@"enum".tag_type);
187563187563 const Set = std.bit_set.Static(max);
187564187564 const SafetySet = if (std.debug.runtime_safety) Set else struct {
187565 inline fn initEmpty() @This() {
187566 return .{};
187567 }
187565 pub const empty: @This() = .{};
187568187566
187569187567 inline fn isSet(_: @This(), index: usize) bool {
187570187568 assert(index < max);