authorgravatar for me@gasinfinity.devGasInfinity <me@gasinfinity.dev> 2026-04-23 14:03:08+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-27 16:46:26+02:00
log1deb029a665399838ca0bfbc451af02bc091200f
tree183f1cff867ea74272083b5698e7fa8357fbc34b
parentc166c49b1917bb682d6949150feb59e54d6c0b2d

std: rename `bit_set` variants and deprecate the managed one.

* aliases and deprecates the previous names. * also update callsites to use the non-deprecated declarations.

19 files changed, 105 insertions(+), 85 deletions(-)

lib/compiler/resinator/compile.zig+1-1
...@@ -3084,7 +3084,7 @@ pub const StringTable = struct {...@@ -3084,7 +3084,7 @@ pub const StringTable = struct {
30843084
3085 pub const Block = struct {3085 pub const Block = struct {
3086 strings: std.ArrayList(Token) = .empty,3086 strings: std.ArrayList(Token) = .empty,
3087 set_indexes: std.bit_set.IntegerBitSet(16) = .{ .mask = 0 },3087 set_indexes: std.bit_set.Integer(16) = .{ .mask = 0 },
3088 memory_flags: MemoryFlags = MemoryFlags.defaults(res.RT.STRING),3088 memory_flags: MemoryFlags = MemoryFlags.defaults(res.RT.STRING),
3089 characteristics: u32,3089 characteristics: u32,
3090 version: u32,3090 version: u32,
lib/std/Build/Step/ConfigHeader.zig+1-1
...@@ -290,7 +290,7 @@ fn render_autoconf_undef(...@@ -290,7 +290,7 @@ fn render_autoconf_undef(
290 const build = step.owner;290 const build = step.owner;
291 const allocator = build.allocator;291 const allocator = build.allocator;
292292
293 var is_used: std.DynamicBitSetUnmanaged = try .initEmpty(allocator, values.count());293 var is_used: std.bit_set.Dynamic = try .initEmpty(allocator, values.count());
294 defer is_used.deinit(allocator);294 defer is_used.deinit(allocator);
295295
296 var any_errors = false;296 var any_errors = false;
lib/std/Io/Kqueue.zig+1-1
...@@ -79,7 +79,7 @@ const Fiber = struct {...@@ -79,7 +79,7 @@ const Fiber = struct {
79 awaiter: ?*Fiber,79 awaiter: ?*Fiber,
80 queue_next: ?*Fiber,80 queue_next: ?*Fiber,
81 cancel_thread: ?*Thread,81 cancel_thread: ?*Thread,
82 awaiting_completions: std.StaticBitSet(3),82 awaiting_completions: std.bit_set.Static(3),
8383
84 const finished: ?*Fiber = @ptrFromInt(@alignOf(Thread));84 const finished: ?*Fiber = @ptrFromInt(@alignOf(Thread));
8585
lib/std/bit_set.zig+76-59
...@@ -8,50 +8,55 @@...@@ -8,50 +8,55 @@
8//!8//!
9//! There are five variants defined here:9//! There are five variants defined here:
10//!10//!
11//! IntegerBitSet:11//! Integer:
12//! A bit set with static size, which is backed by a single integer.12//! A bit set with static size, which is backed by a single integer.
13//! This set is good for sets with a small size, but may generate13//! This set is good for sets with a small size, but may generate
14//! inefficient code for larger sets, especially in debug mode.14//! inefficient code for larger sets, especially in debug mode.
15//!15//!
16//! ArrayBitSet:16//! Array:
17//! A bit set with static size, which is backed by an array of usize.17//! A bit set with static size, which is backed by an array of usize.
18//! This set is good for sets with a larger size, but may use18//! This set is good for sets with a larger size, but may use
19//! more bytes than necessary if your set is small.19//! more bytes than necessary if your set is small.
20//!20//!
21//! StaticBitSet:21//! Static:
22//! Picks either IntegerBitSet or ArrayBitSet depending on the requested22//! Picks either Integer or Array depending on the requested
23//! size. The interfaces of these two types match exactly, except for fields.23//! size. The interfaces of these two types match exactly, except for fields.
24//!24//!
25//! DynamicBitSet:25//! Dynamic:
26//! A bit set with runtime-known size, backed by an allocated slice26//! A bit set with runtime-known size, backed by an allocated slice
27//! of usize.27//! of usize.
28//!28//!
29//! DynamicBitSetUnmanaged:29//! DynamicManaged:
30//! A variant of DynamicBitSet which does not store a pointer to its30//! A variant of Dynamic which stores an allocator, using it when needed.
31//! allocator, in order to save space.
3231
33const std = @import("std.zig");32const std = @import("std.zig");
34const assert = std.debug.assert;33const assert = std.debug.assert;
35const Allocator = std.mem.Allocator;34const Allocator = std.mem.Allocator;
36const builtin = @import("builtin");35const builtin = @import("builtin");
3736
37/// Deprecated: use `Static`.
38pub const StaticBitSet = Static;
39
38/// Returns the optimal static bit set type for the specified number40/// Returns the optimal static bit set type for the specified number
39/// of elements: either `IntegerBitSet` or `ArrayBitSet`,41/// of elements: either `IntegerBitSet` or `ArrayBitSet`,
40/// both of which fulfill the same interface.42/// both of which fulfill the same interface.
41/// The returned type will perform no allocations,43/// The returned type will perform no allocations,
42/// can be copied by value, and does not require deinitialization.44/// can be copied by value, and does not require deinitialization.
43pub fn StaticBitSet(comptime size: usize) type {45pub fn Static(comptime size: usize) type {
44 if (size <= @bitSizeOf(usize)) {46 if (size <= @bitSizeOf(usize)) {
45 return IntegerBitSet(size);47 return Integer(size);
46 } else {48 } else {
47 return ArrayBitSet(usize, size);49 return Array(usize, size);
48 }50 }
49}51}
5052
53/// Deprecated: use `Integer`.
54pub const IntegerBitSet = Integer;
55
51/// A bit set with static size, which is backed by a single integer.56/// A bit set with static size, which is backed by a single integer.
52/// This set is good for sets with a small size, but may generate57/// This set is good for sets with a small size, but may generate
53/// inefficient code for larger sets, especially in debug mode.58/// inefficient code for larger sets, especially in debug mode.
54pub fn IntegerBitSet(comptime size: u16) type {59pub fn Integer(comptime size: u16) type {
55 return packed struct(MaskInt) {60 return packed struct(MaskInt) {
56 const Self = @This();61 const Self = @This();
5762
...@@ -328,21 +333,24 @@ pub fn IntegerBitSet(comptime size: u16) type {...@@ -328,21 +333,24 @@ pub fn IntegerBitSet(comptime size: u16) type {
328 };333 };
329}334}
330335
336/// Deprecated: use `Array`.
337pub const ArrayBitSet = Array;
338
331/// A bit set with static size, which is backed by an array of usize.339/// A bit set with static size, which is backed by an array of usize.
332/// This set is good for sets with a larger size, but may use340/// This set is good for sets with a larger size, but may use
333/// more bytes than necessary if your set is small.341/// more bytes than necessary if your set is small.
334pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {342pub fn Array(comptime MaskIntType: type, comptime size: usize) type {
335 const mask_info: std.builtin.Type = @typeInfo(MaskIntType);343 const mask_info: std.builtin.Type = @typeInfo(MaskIntType);
336344
337 // Make sure the mask int is indeed an int345 // Make sure the mask int is indeed an int
338 if (mask_info != .int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));346 if (mask_info != .int) @compileError("Array can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
339347
340 // It must also be unsigned.348 // It must also be unsigned.
341 if (mask_info.int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));349 if (mask_info.int.signedness != .unsigned) @compileError("Array requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));
342350
343 // And it must not be empty.351 // And it must not be empty.
344 if (MaskIntType == u0)352 if (MaskIntType == u0)
345 @compileError("ArrayBitSet requires a sized integer for its mask int. u0 does not work.");353 @compileError("Array requires a sized integer for its mask int. u0 does not work.");
346354
347 const byte_size = std.mem.byte_size_in_bits;355 const byte_size = std.mem.byte_size_in_bits;
348356
...@@ -352,7 +360,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -352,7 +360,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
352 var desired_bits = std.math.ceilPowerOfTwoAssert(usize, @bitSizeOf(MaskIntType));360 var desired_bits = std.math.ceilPowerOfTwoAssert(usize, @bitSizeOf(MaskIntType));
353 if (desired_bits < byte_size) desired_bits = byte_size;361 if (desired_bits < byte_size) desired_bits = byte_size;
354 const FixedMaskType = std.meta.Int(.unsigned, desired_bits);362 const FixedMaskType = std.meta.Int(.unsigned, desired_bits);
355 @compileError("ArrayBitSet was passed integer type " ++ @typeName(MaskIntType) ++363 @compileError("Array was passed integer type " ++ @typeName(MaskIntType) ++
356 ", which is not a power of two. Please round this up to a power of two integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");364 ", which is not a power of two. Please round this up to a power of two integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
357 }365 }
358366
...@@ -363,7 +371,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -363,7 +371,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
363 var desired_bits = @sizeOf(MaskIntType) * byte_size;371 var desired_bits = @sizeOf(MaskIntType) * byte_size;
364 desired_bits = std.math.ceilPowerOfTwoAssert(usize, desired_bits);372 desired_bits = std.math.ceilPowerOfTwoAssert(usize, desired_bits);
365 const FixedMaskType = std.meta.Int(.unsigned, desired_bits);373 const FixedMaskType = std.meta.Int(.unsigned, desired_bits);
366 @compileError("ArrayBitSet was passed integer type " ++ @typeName(MaskIntType) ++374 @compileError("Array was passed integer type " ++ @typeName(MaskIntType) ++
367 ", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");375 ", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
368 }376 }
369377
...@@ -673,7 +681,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -673,7 +681,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
673 }681 }
674682
675 pub fn Iterator(comptime options: IteratorOptions) type {683 pub fn Iterator(comptime options: IteratorOptions) type {
676 return BitSetIterator(MaskInt, options);684 return GenericIterator(MaskInt, options);
677 }685 }
678686
679 fn maskBit(index: usize) MaskInt {687 fn maskBit(index: usize) MaskInt {
...@@ -688,9 +696,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -688,9 +696,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
688 };696 };
689}697}
690698
699/// Deprecated: use `Dynamic`.
700pub const DynamicBitSetUnmanaged = Dynamic;
701
691/// A bit set with runtime-known size, backed by an allocated slice702/// A bit set with runtime-known size, backed by an allocated slice
692/// of usize. The allocator must be tracked externally by the user.703/// of usize. The allocator must be tracked externally by the user.
693pub const DynamicBitSetUnmanaged = struct {704pub const Dynamic = struct {
694 const Self = @This();705 const Self = @This();
695706
696 /// The integer type used to represent a mask in this bit set707 /// The integer type used to represent a mask in this bit set
...@@ -1074,7 +1085,7 @@ pub const DynamicBitSetUnmanaged = struct {...@@ -1074,7 +1085,7 @@ pub const DynamicBitSetUnmanaged = struct {
1074 }1085 }
10751086
1076 pub fn Iterator(comptime options: IteratorOptions) type {1087 pub fn Iterator(comptime options: IteratorOptions) type {
1077 return BitSetIterator(MaskInt, options);1088 return GenericIterator(MaskInt, options);
1078 }1089 }
10791090
1080 fn maskBit(index: usize) MaskInt {1091 fn maskBit(index: usize) MaskInt {
...@@ -1091,10 +1102,16 @@ pub const DynamicBitSetUnmanaged = struct {...@@ -1091,10 +1102,16 @@ pub const DynamicBitSetUnmanaged = struct {
1091 }1102 }
1092};1103};
10931104
1105/// Deprecated: use `DynamicManaged` or `Dynamic` (will need to update callsites).
1106pub const DynamicBitSet = DynamicManaged;
1107
1094/// A bit set with runtime-known size, backed by an allocated slice1108/// A bit set with runtime-known size, backed by an allocated slice
1095/// of usize. Thin wrapper around DynamicBitSetUnmanaged which keeps1109/// of usize. Thin wrapper around Dynamic which keeps
1096/// track of the allocator instance.1110/// track of the allocator instance.
1097pub const DynamicBitSet = struct {1111///
1112/// Deprecated in favor of `Dynamic` which accepts an `Allocator`
1113/// as a parameter when needed instead of storing it.
1114pub const DynamicManaged = struct {
1098 const Self = @This();1115 const Self = @This();
10991116
1100 /// The integer type used to represent a mask in this bit set1117 /// The integer type used to represent a mask in this bit set
...@@ -1104,12 +1121,12 @@ pub const DynamicBitSet = struct {...@@ -1104,12 +1121,12 @@ pub const DynamicBitSet = struct {
1104 pub const ShiftInt = std.math.Log2Int(MaskInt);1121 pub const ShiftInt = std.math.Log2Int(MaskInt);
11051122
1106 allocator: Allocator,1123 allocator: Allocator,
1107 unmanaged: DynamicBitSetUnmanaged = .{},1124 unmanaged: Dynamic = .{},
11081125
1109 /// Creates a bit set with no elements present.1126 /// Creates a bit set with no elements present.
1110 pub fn initEmpty(allocator: Allocator, bit_length: usize) !Self {1127 pub fn initEmpty(allocator: Allocator, bit_length: usize) !Self {
1111 return Self{1128 return Self{
1112 .unmanaged = try DynamicBitSetUnmanaged.initEmpty(allocator, bit_length),1129 .unmanaged = try .initEmpty(allocator, bit_length),
1113 .allocator = allocator,1130 .allocator = allocator,
1114 };1131 };
1115 }1132 }
...@@ -1117,7 +1134,7 @@ pub const DynamicBitSet = struct {...@@ -1117,7 +1134,7 @@ pub const DynamicBitSet = struct {
1117 /// Creates a bit set with all elements present.1134 /// Creates a bit set with all elements present.
1118 pub fn initFull(allocator: Allocator, bit_length: usize) !Self {1135 pub fn initFull(allocator: Allocator, bit_length: usize) !Self {
1119 return Self{1136 return Self{
1120 .unmanaged = try DynamicBitSetUnmanaged.initFull(allocator, bit_length),1137 .unmanaged = try .initFull(allocator, bit_length),
1121 .allocator = allocator,1138 .allocator = allocator,
1122 };1139 };
1123 }1140 }
...@@ -1247,7 +1264,7 @@ pub const DynamicBitSet = struct {...@@ -1247,7 +1264,7 @@ pub const DynamicBitSet = struct {
1247 return self.unmanaged.iterator(options);1264 return self.unmanaged.iterator(options);
1248 }1265 }
12491266
1250 pub const Iterator = DynamicBitSetUnmanaged.Iterator;1267 pub const Iterator = Dynamic.Iterator;
1251};1268};
12521269
1253/// Options for configuring an iterator over a bit set1270/// Options for configuring an iterator over a bit set
...@@ -1274,7 +1291,7 @@ pub const IteratorOptions = struct {...@@ -1274,7 +1291,7 @@ pub const IteratorOptions = struct {
1274};1291};
12751292
1276// The iterator is reusable between several bit set types1293// The iterator is reusable between several bit set types
1277fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) type {1294fn GenericIterator(comptime MaskInt: type, comptime options: IteratorOptions) type {
1278 const ShiftInt = std.math.Log2Int(MaskInt);1295 const ShiftInt = std.math.Log2Int(MaskInt);
1279 const kind = options.kind;1296 const kind = options.kind;
1280 const direction = options.direction;1297 const direction = options.direction;
...@@ -1713,37 +1730,37 @@ fn testStaticBitSet(comptime Set: type) !void {...@@ -1713,37 +1730,37 @@ fn testStaticBitSet(comptime Set: type) !void {
1713 try testPureBitSet(Set);1730 try testPureBitSet(Set);
1714}1731}
17151732
1716test IntegerBitSet {1733test Integer {
1717 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;1734 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1718 if (comptime builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/243001735 if (comptime builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24300
17191736
1720 try testStaticBitSet(IntegerBitSet(0));1737 try testStaticBitSet(Integer(0));
1721 try testStaticBitSet(IntegerBitSet(1));1738 try testStaticBitSet(Integer(1));
1722 try testStaticBitSet(IntegerBitSet(2));1739 try testStaticBitSet(Integer(2));
1723 try testStaticBitSet(IntegerBitSet(5));1740 try testStaticBitSet(Integer(5));
1724 try testStaticBitSet(IntegerBitSet(8));1741 try testStaticBitSet(Integer(8));
1725 try testStaticBitSet(IntegerBitSet(32));1742 try testStaticBitSet(Integer(32));
1726 try testStaticBitSet(IntegerBitSet(64));1743 try testStaticBitSet(Integer(64));
1727 try testStaticBitSet(IntegerBitSet(127));1744 try testStaticBitSet(Integer(127));
1728}1745}
17291746
1730test ArrayBitSet {1747test Array {
1731 inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| {1748 inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| {
1732 try testStaticBitSet(ArrayBitSet(u8, size));1749 try testStaticBitSet(Array(u8, size));
1733 try testStaticBitSet(ArrayBitSet(u16, size));1750 try testStaticBitSet(Array(u16, size));
1734 try testStaticBitSet(ArrayBitSet(u32, size));1751 try testStaticBitSet(Array(u32, size));
1735 try testStaticBitSet(ArrayBitSet(u64, size));1752 try testStaticBitSet(Array(u64, size));
1736 try testStaticBitSet(ArrayBitSet(u128, size));1753 try testStaticBitSet(Array(u128, size));
1737 }1754 }
1738}1755}
17391756
1740test DynamicBitSetUnmanaged {1757test Dynamic {
1741 const allocator = std.testing.allocator;1758 const allocator = std.testing.allocator;
1742 var a = try DynamicBitSetUnmanaged.initEmpty(allocator, 300);1759 var a: Dynamic = try .initEmpty(allocator, 300);
1743 try testing.expectEqual(@as(usize, 0), a.count());1760 try testing.expectEqual(@as(usize, 0), a.count());
1744 a.deinit(allocator);1761 a.deinit(allocator);
17451762
1746 a = try DynamicBitSetUnmanaged.initEmpty(allocator, 0);1763 a = try .initEmpty(allocator, 0);
1747 defer a.deinit(allocator);1764 defer a.deinit(allocator);
1748 for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {1765 for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {
1749 const old_len = a.capacity();1766 const old_len = a.capacity();
...@@ -1769,17 +1786,17 @@ test DynamicBitSetUnmanaged {...@@ -1769,17 +1786,17 @@ test DynamicBitSetUnmanaged {
1769 }1786 }
1770 try testing.expectEqual(@as(usize, 0), empty.count());1787 try testing.expectEqual(@as(usize, 0), empty.count());
17711788
1772 var full = try DynamicBitSetUnmanaged.initFull(allocator, size);1789 var full: Dynamic = try .initFull(allocator, size);
1773 defer full.deinit(allocator);1790 defer full.deinit(allocator);
1774 try testing.expectEqual(@as(usize, size), full.count());1791 try testing.expectEqual(@as(usize, size), full.count());
17751792
1776 try testEql(empty, full, size);1793 try testEql(empty, full, size);
1777 {1794 {
1778 var even = try DynamicBitSetUnmanaged.initEmpty(allocator, size);1795 var even: Dynamic = try .initEmpty(allocator, size);
1779 defer even.deinit(allocator);1796 defer even.deinit(allocator);
1780 fillEven(&even, size);1797 fillEven(&even, size);
17811798
1782 var odd = try DynamicBitSetUnmanaged.initEmpty(allocator, size);1799 var odd: Dynamic = try .initEmpty(allocator, size);
1783 defer odd.deinit(allocator);1800 defer odd.deinit(allocator);
1784 fillOdd(&odd, size);1801 fillOdd(&odd, size);
17851802
...@@ -1790,13 +1807,13 @@ test DynamicBitSetUnmanaged {...@@ -1790,13 +1807,13 @@ test DynamicBitSetUnmanaged {
1790 }1807 }
1791}1808}
17921809
1793test DynamicBitSet {1810test DynamicManaged {
1794 const allocator = std.testing.allocator;1811 const allocator = std.testing.allocator;
1795 var a = try DynamicBitSet.initEmpty(allocator, 300);1812 var a: DynamicManaged = try .initEmpty(allocator, 300);
1796 try testing.expectEqual(@as(usize, 0), a.count());1813 try testing.expectEqual(@as(usize, 0), a.count());
1797 a.deinit();1814 a.deinit();
17981815
1799 a = try DynamicBitSet.initEmpty(allocator, 0);1816 a = try .initEmpty(allocator, 0);
1800 defer a.deinit();1817 defer a.deinit();
1801 for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {1818 for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {
1802 const old_len = a.capacity();1819 const old_len = a.capacity();
...@@ -1822,7 +1839,7 @@ test DynamicBitSet {...@@ -1822,7 +1839,7 @@ test DynamicBitSet {
1822 }1839 }
1823 try testing.expectEqual(@as(usize, 0), tmp.count());1840 try testing.expectEqual(@as(usize, 0), tmp.count());
18241841
1825 var b = try DynamicBitSet.initFull(allocator, size);1842 var b: DynamicManaged = try .initFull(allocator, size);
1826 defer b.deinit();1843 defer b.deinit();
1827 try testing.expectEqual(@as(usize, size), b.count());1844 try testing.expectEqual(@as(usize, size), b.count());
18281845
...@@ -1831,10 +1848,10 @@ test DynamicBitSet {...@@ -1831,10 +1848,10 @@ test DynamicBitSet {
1831 }1848 }
1832}1849}
18331850
1834test StaticBitSet {1851test Static {
1835 try testing.expectEqual(IntegerBitSet(0), StaticBitSet(0));1852 try testing.expectEqual(Integer(0), Static(0));
1836 try testing.expectEqual(IntegerBitSet(5), StaticBitSet(5));1853 try testing.expectEqual(Integer(5), Static(5));
1837 try testing.expectEqual(IntegerBitSet(@bitSizeOf(usize)), StaticBitSet(@bitSizeOf(usize)));1854 try testing.expectEqual(Integer(@bitSizeOf(usize)), Static(@bitSizeOf(usize)));
1838 try testing.expectEqual(ArrayBitSet(usize, @bitSizeOf(usize) + 1), StaticBitSet(@bitSizeOf(usize) + 1));1855 try testing.expectEqual(Array(usize, @bitSizeOf(usize) + 1), Static(@bitSizeOf(usize) + 1));
1839 try testing.expectEqual(ArrayBitSet(usize, 500), StaticBitSet(500));1856 try testing.expectEqual(Array(usize, 500), Static(500));
1840}1857}
lib/std/crypto/codecs/base64_hex_ct.zig+1-1
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3//! This is designed to be used in cryptographic applications where timing attacks are a concern.3//! This is designed to be used in cryptographic applications where timing attacks are a concern.
4const std = @import("std");4const std = @import("std");
5const testing = std.testing;5const testing = std.testing;
6const StaticBitSet = std.StaticBitSet;6const StaticBitSet = std.bit_set.Static;
77
8pub const Error = error{8pub const Error = error{
9 /// An invalid character was found in the input.9 /// An invalid character was found in the input.
lib/std/enums.zig+2-2
...@@ -247,7 +247,7 @@ pub fn EnumSet(comptime E: type) type {...@@ -247,7 +247,7 @@ pub fn EnumSet(comptime E: type) type {
247 /// The element type for this set.247 /// The element type for this set.
248 pub const Key = Indexer.Key;248 pub const Key = Indexer.Key;
249249
250 const BitSet = std.StaticBitSet(Indexer.count);250 const BitSet = std.bit_set.Static(Indexer.count);
251251
252 /// The maximum number of items in this set.252 /// The maximum number of items in this set.
253 pub const len = Indexer.count;253 pub const len = Indexer.count;
...@@ -445,7 +445,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -445,7 +445,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
445 /// The number of possible keys in the map445 /// The number of possible keys in the map
446 pub const len = Indexer.count;446 pub const len = Indexer.count;
447447
448 const BitSet = std.StaticBitSet(Indexer.count);448 const BitSet = std.bit_set.Static(Indexer.count);
449449
450 /// Bits determining whether items are in the map450 /// Bits determining whether items are in the map
451 bits: BitSet = .empty,451 bits: BitSet = .empty,
lib/std/fs/path.zig+1-1
...@@ -897,7 +897,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) Allocator...@@ -897,7 +897,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) Allocator
897 var buf: [3]usize = undefined;897 var buf: [3]usize = undefined;
898 var bit_set_allocator_state: std.heap.BufferFirstAllocator = .init(@ptrCast(&buf), allocator);898 var bit_set_allocator_state: std.heap.BufferFirstAllocator = .init(@ptrCast(&buf), allocator);
899 const bit_set_allocator = bit_set_allocator_state.allocator();899 const bit_set_allocator = bit_set_allocator_state.allocator();
900 var relevant_paths = try std.bit_set.DynamicBitSetUnmanaged.initEmpty(bit_set_allocator, paths.len);900 var relevant_paths: std.bit_set.Dynamic = try .initEmpty(bit_set_allocator, paths.len);
901 defer relevant_paths.deinit(bit_set_allocator);901 defer relevant_paths.deinit(bit_set_allocator);
902902
903 // Iterate the paths backwards, marking the relevant paths along the way.903 // Iterate the paths backwards, marking the relevant paths along the way.
lib/std/std.zig+3
...@@ -9,7 +9,9 @@ pub const StaticStringMapWithEql = static_string_map.StaticStringMapWithEql;...@@ -9,7 +9,9 @@ pub const StaticStringMapWithEql = static_string_map.StaticStringMapWithEql;
9pub const Deque = @import("deque.zig").Deque;9pub const Deque = @import("deque.zig").Deque;
10pub const DoublyLinkedList = @import("DoublyLinkedList.zig");10pub const DoublyLinkedList = @import("DoublyLinkedList.zig");
11pub const DynLib = @import("dynamic_library.zig").DynLib;11pub const DynLib = @import("dynamic_library.zig").DynLib;
12/// Deprecated: use `bit_set.DynamicManaged`.
12pub const DynamicBitSet = bit_set.DynamicBitSet;13pub const DynamicBitSet = bit_set.DynamicBitSet;
14/// Deprecated: use `bit_set.Dynamic`.
13pub const DynamicBitSetUnmanaged = bit_set.DynamicBitSetUnmanaged;15pub const DynamicBitSetUnmanaged = bit_set.DynamicBitSetUnmanaged;
14pub const EnumArray = enums.EnumArray;16pub const EnumArray = enums.EnumArray;
15pub const EnumMap = enums.EnumMap;17pub const EnumMap = enums.EnumMap;
...@@ -24,6 +26,7 @@ pub const Progress = @import("Progress.zig");...@@ -24,6 +26,7 @@ pub const Progress = @import("Progress.zig");
24pub const Random = @import("Random.zig");26pub const Random = @import("Random.zig");
25pub const SemanticVersion = @import("SemanticVersion.zig");27pub const SemanticVersion = @import("SemanticVersion.zig");
26pub const SinglyLinkedList = @import("SinglyLinkedList.zig");28pub const SinglyLinkedList = @import("SinglyLinkedList.zig");
29/// Deprecated: use `bit_set.Static`.
27pub const StaticBitSet = bit_set.StaticBitSet;30pub const StaticBitSet = bit_set.StaticBitSet;
28pub const StringHashMap = hash_map.StringHashMap;31pub const StringHashMap = hash_map.StringHashMap;
29pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged;32pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged;
lib/std/testing.zig+1-1
...@@ -501,7 +501,7 @@ const BytesDiffer = struct {...@@ -501,7 +501,7 @@ const BytesDiffer = struct {
501 var row: usize = 0;501 var row: usize = 0;
502 while (expected_iterator.next()) |chunk| {502 while (expected_iterator.next()) |chunk| {
503 // to avoid having to calculate diffs twice per chunk503 // to avoid having to calculate diffs twice per chunk
504 var diffs: std.bit_set.IntegerBitSet(16) = .{ .mask = 0 };504 var diffs: std.bit_set.Integer(16) = .{ .mask = 0 };
505 for (chunk, 0..) |byte, col| {505 for (chunk, 0..) |byte, col| {
506 const absolute_byte_index = col + row * 16;506 const absolute_byte_index = col + row * 16;
507 const diff = if (absolute_byte_index < self.actual.len) self.actual[absolute_byte_index] != byte else true;507 const diff = if (absolute_byte_index < self.actual.len) self.actual[absolute_byte_index] != byte else true;
src/Sema.zig+1-1
...@@ -12319,7 +12319,7 @@ fn analyzeSwitchPayloadCapture(...@@ -12319,7 +12319,7 @@ fn analyzeSwitchPayloadCapture(
12319 // be several, and we can squash all of these cases into the same switch prong using12319 // be several, and we can squash all of these cases into the same switch prong using
12320 // a simple bitcast. We'll make this the 'else' prong.12320 // a simple bitcast. We'll make this the 'else' prong.
1232112321
12322 var in_mem_coercible: std.DynamicBitSet = try .initFull(sema.arena, field_indices.len);12322 var in_mem_coercible: std.bit_set.Dynamic = try .initFull(sema.arena, field_indices.len);
12323 in_mem_coercible.unset(first_non_imc);12323 in_mem_coercible.unset(first_non_imc);
12324 {12324 {
12325 const next = first_non_imc + 1;12325 const next = first_non_imc + 1;
src/codegen/riscv64/CodeGen.zig+1-1
...@@ -92,7 +92,7 @@ scope_generation: u32,...@@ -92,7 +92,7 @@ scope_generation: u32,
92/// which is a relative jump, based on the address following the reloc.92/// which is a relative jump, based on the address following the reloc.
93exitlude_jump_relocs: std.ArrayList(usize) = .empty,93exitlude_jump_relocs: std.ArrayList(usize) = .empty,
9494
95reused_operands: std.StaticBitSet(Air.Liveness.bpi - 1) = undefined,95reused_operands: std.bit_set.Static(Air.Liveness.bpi - 1) = undefined,
9696
97/// Whenever there is a runtime branch, we push a Branch onto this stack,97/// Whenever there is a runtime branch, we push a Branch onto this stack,
98/// and pop it off when the runtime branch joins. This provides an "overlay"98/// and pop it off when the runtime branch joins. This provides an "overlay"
src/codegen/riscv64/Mir.zig+1-1
...@@ -238,7 +238,7 @@ const Immediate = bits.Immediate;...@@ -238,7 +238,7 @@ const Immediate = bits.Immediate;
238const Memory = bits.Memory;238const Memory = bits.Memory;
239const FrameIndex = bits.FrameIndex;239const FrameIndex = bits.FrameIndex;
240const FrameAddr = @import("CodeGen.zig").FrameAddr;240const FrameAddr = @import("CodeGen.zig").FrameAddr;
241const IntegerBitSet = std.bit_set.IntegerBitSet;241const IntegerBitSet = std.bit_set.Integer;
242const Mnemonic = @import("mnem.zig").Mnemonic;242const Mnemonic = @import("mnem.zig").Mnemonic;
243243
244const InternPool = @import("../../InternPool.zig");244const InternPool = @import("../../InternPool.zig");
src/codegen/sparc64/CodeGen.zig+1-1
...@@ -79,7 +79,7 @@ end_di_column: u32,...@@ -79,7 +79,7 @@ end_di_column: u32,
79/// which is a relative jump, based on the address following the reloc.79/// which is a relative jump, based on the address following the reloc.
80exitlude_jump_relocs: std.ArrayList(usize) = .empty,80exitlude_jump_relocs: std.ArrayList(usize) = .empty,
8181
82reused_operands: std.StaticBitSet(Air.Liveness.bpi - 1) = undefined,82reused_operands: std.bit_set.Static(Air.Liveness.bpi - 1) = undefined,
8383
84/// Whenever there is a runtime branch, we push a Branch onto this stack,84/// Whenever there is a runtime branch, we push a Branch onto this stack,
85/// and pop it off when the runtime branch joins. This provides an "overlay"85/// and pop it off when the runtime branch joins. This provides an "overlay"
src/codegen/spirv/Module.zig+2-2
...@@ -280,7 +280,7 @@ pub fn idBound(module: Module) Word {...@@ -280,7 +280,7 @@ pub fn idBound(module: Module) Word {
280pub fn addEntryPointDeps(280pub fn addEntryPointDeps(
281 module: *Module,281 module: *Module,
282 decl_index: Decl.Index,282 decl_index: Decl.Index,
283 seen: *std.DynamicBitSetUnmanaged,283 seen: *std.bit_set.Dynamic,
284 interface: *std.array_list.Managed(Id),284 interface: *std.array_list.Managed(Id),
285) !void {285) !void {
286 const decl = module.declPtr(decl_index);286 const decl = module.declPtr(decl_index);
...@@ -310,7 +310,7 @@ fn entryPoints(module: *Module) !Section {...@@ -310,7 +310,7 @@ fn entryPoints(module: *Module) !Section {
310 var interface = std.array_list.Managed(Id).init(module.gpa);310 var interface = std.array_list.Managed(Id).init(module.gpa);
311 defer interface.deinit();311 defer interface.deinit();
312312
313 var seen = try std.DynamicBitSetUnmanaged.initEmpty(module.gpa, module.decls.items.len);313 var seen: std.bit_set.Dynamic = try .initEmpty(module.gpa, module.decls.items.len);
314 defer seen.deinit(module.gpa);314 defer seen.deinit(module.gpa);
315315
316 for (module.entry_points.keys(), module.entry_points.values()) |entry_point_id, entry_point| {316 for (module.entry_points.keys(), module.entry_points.values()) |entry_point_id, entry_point| {
src/codegen/x86_64/CodeGen.zig+4-4
...@@ -129,7 +129,7 @@ mir_table: std.ArrayList(Mir.Inst.Index) = .empty,...@@ -129,7 +129,7 @@ mir_table: std.ArrayList(Mir.Inst.Index) = .empty,
129/// which is a relative jump, based on the address following the reloc.129/// which is a relative jump, based on the address following the reloc.
130epilogue_relocs: std.ArrayList(Mir.Inst.Index) = .empty,130epilogue_relocs: std.ArrayList(Mir.Inst.Index) = .empty,
131131
132reused_operands: std.StaticBitSet(Air.Liveness.bpi - 1) = undefined,132reused_operands: std.bit_set.Static(Air.Liveness.bpi - 1) = undefined,
133inst_tracking: InstTrackingMap = .empty,133inst_tracking: InstTrackingMap = .empty,
134134
135// Key is the block instruction135// Key is the block instruction
...@@ -177439,7 +177439,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177439,7 +177439,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177439 }177439 }
177440177440
177441 var mnem_size: struct {177441 var mnem_size: struct {
177442 op_has_size: std.StaticBitSet(4),177442 op_has_size: std.bit_set.Static(4),
177443 size: Memory.Size,177443 size: Memory.Size,
177444 used: bool,177444 used: bool,
177445 fn init(size: ?Memory.Size) @This() {177445 fn init(size: ?Memory.Size) @This() {
...@@ -178378,7 +178378,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C...@@ -178378,7 +178378,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C
178378 else => unreachable,178378 else => unreachable,
178379 },178379 },
178380 dst_tag => |src_regs| {178380 dst_tag => |src_regs| {
178381 var remaining: std.StaticBitSet(dst_regs.len) = .full;178381 var remaining: std.bit_set.Static(dst_regs.len) = .full;
178382 var hazard_regs = src_regs;178382 var hazard_regs = src_regs;
178383 while (!remaining.eql(.empty)) {178383 while (!remaining.eql(.empty)) {
178384 var remaining_it = remaining.iterator(.{});178384 var remaining_it = remaining.iterator(.{});
...@@ -187560,7 +187560,7 @@ const Temp = struct {...@@ -187560,7 +187560,7 @@ const Temp = struct {
187560 }187560 }
187561187561
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.StaticBitSet(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 inline fn initEmpty() @This() {
187566 return .{};187566 return .{};
src/codegen/x86_64/Mir.zig+1-1
...@@ -1777,7 +1777,7 @@ pub const Inst = struct {...@@ -1777,7 +1777,7 @@ pub const Inst = struct {
1777pub const RegisterList = struct {1777pub const RegisterList = struct {
1778 bitset: BitSet,1778 bitset: BitSet,
17791779
1780 const BitSet = std.bit_set.IntegerBitSet(32);1780 const BitSet = std.bit_set.Integer(32);
1781 const Self = @This();1781 const Self = @This();
17821782
1783 pub const empty: RegisterList = .{ .bitset = .empty };1783 pub const empty: RegisterList = .{ .bitset = .empty };
src/libs/freebsd.zig+2-2
...@@ -541,8 +541,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -541,8 +541,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
541 var sym_i: usize = 0;541 var sym_i: usize = 0;
542 var sym_name_buf: std.Io.Writer.Allocating = .init(arena);542 var sym_name_buf: std.Io.Writer.Allocating = .init(arena);
543 var opt_symbol_name: ?[]const u8 = null;543 var opt_symbol_name: ?[]const u8 = null;
544 var versions = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len);544 var versions: std.bit_set.Dynamic = try .initEmpty(arena, metadata.all_versions.len);
545 var weak_linkages = try std.DynamicBitSetUnmanaged.initEmpty(arena, metadata.all_versions.len);545 var weak_linkages: std.bit_set.Dynamic = try .initEmpty(arena, metadata.all_versions.len);
546546
547 var inc_reader: std.Io.Reader = .fixed(metadata.inclusions);547 var inc_reader: std.Io.Reader = .fixed(metadata.inclusions);
548548
src/link/SpirV/lower_invocation_globals.zig+4-4
...@@ -208,7 +208,7 @@ const ModuleInfo = struct {...@@ -208,7 +208,7 @@ const ModuleInfo = struct {
208 /// For each function, extend the list of `invocation_globals` with the208 /// For each function, extend the list of `invocation_globals` with the
209 /// invocation globals that ALL of its dependencies use.209 /// invocation globals that ALL of its dependencies use.
210 fn resolveInvocationGlobalUsage(self: *ModuleInfo, arena: Allocator) !void {210 fn resolveInvocationGlobalUsage(self: *ModuleInfo, arena: Allocator) !void {
211 var seen = try std.DynamicBitSetUnmanaged.initEmpty(arena, self.functions.count());211 var seen: std.bit_set.Dynamic = try .initEmpty(arena, self.functions.count());
212212
213 for (self.functions.keys()) |id| {213 for (self.functions.keys()) |id| {
214 try self.resolveInvocationGlobalUsageStep(arena, id, &seen);214 try self.resolveInvocationGlobalUsageStep(arena, id, &seen);
...@@ -219,7 +219,7 @@ const ModuleInfo = struct {...@@ -219,7 +219,7 @@ const ModuleInfo = struct {
219 self: *ModuleInfo,219 self: *ModuleInfo,
220 arena: Allocator,220 arena: Allocator,
221 id: ResultId,221 id: ResultId,
222 seen: *std.DynamicBitSetUnmanaged,222 seen: *std.bit_set.Dynamic,
223 ) !void {223 ) !void {
224 const index = self.functions.getIndex(id) orelse {224 const index = self.functions.getIndex(id) orelse {
225 log.err("function calls invalid function {f}", .{id});225 log.err("function calls invalid function {f}", .{id});
...@@ -247,7 +247,7 @@ const ModuleInfo = struct {...@@ -247,7 +247,7 @@ const ModuleInfo = struct {
247 self: *ModuleInfo,247 self: *ModuleInfo,
248 arena: Allocator,248 arena: Allocator,
249 ) !void {249 ) !void {
250 var seen = try std.DynamicBitSetUnmanaged.initEmpty(arena, self.invocation_globals.count());250 var seen: std.bit_set.Dynamic = try .initEmpty(arena, self.invocation_globals.count());
251251
252 for (self.invocation_globals.keys()) |id| {252 for (self.invocation_globals.keys()) |id| {
253 try self.resolveInvocationGlobalDependenciesStep(arena, id, &seen);253 try self.resolveInvocationGlobalDependenciesStep(arena, id, &seen);
...@@ -258,7 +258,7 @@ const ModuleInfo = struct {...@@ -258,7 +258,7 @@ const ModuleInfo = struct {
258 self: *ModuleInfo,258 self: *ModuleInfo,
259 arena: Allocator,259 arena: Allocator,
260 id: ResultId,260 id: ResultId,
261 seen: *std.DynamicBitSetUnmanaged,261 seen: *std.bit_set.Dynamic,
262 ) !void {262 ) !void {
263 const index = self.invocation_globals.getIndex(id) orelse {263 const index = self.invocation_globals.getIndex(id) orelse {
264 log.err("invalid invocation global {f}", .{id});264 log.err("invalid invocation global {f}", .{id});
src/register_manager.zig+1-1
...@@ -4,7 +4,7 @@ const mem = std.mem;...@@ -4,7 +4,7 @@ const mem = std.mem;
4const assert = std.debug.assert;4const assert = std.debug.assert;
5const Allocator = std.mem.Allocator;5const Allocator = std.mem.Allocator;
6const Air = @import("Air.zig");6const Air = @import("Air.zig");
7const StaticBitSet = std.bit_set.StaticBitSet;7const StaticBitSet = std.bit_set.Static;
8const Type = @import("Type.zig");8const Type = @import("Type.zig");
9const Zcu = @import("Zcu.zig");9const Zcu = @import("Zcu.zig");
10const expect = std.testing.expect;10const expect = std.testing.expect;