diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-06-22 18:46:56 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 16:56:39 -0700 |
| commit | f26dda21171e26f44aeec8c59a75bbb3331eeb2e (patch) | |
| tree | c935248861ae2693b314f2c8bc78fe38d9961b6d /lib/std/bit_set.zig | |
| parent | 447ca4e3fff021f471b748187b53f0a4744ad0bc (diff) | |
| download | zig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.tar.gz zig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.zip | |
all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:
* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
Diffstat (limited to 'lib/std/bit_set.zig')
| -rw-r--r-- | lib/std/bit_set.zig | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig index 4b83e8e057..9e5c707b84 100644 --- a/lib/std/bit_set.zig +++ b/lib/std/bit_set.zig @@ -119,19 +119,19 @@ pub fn IntegerBitSet(comptime size: u16) type { if (range.start == range.end) return; if (MaskInt == u0) return; - const start_bit = @intCast(ShiftInt, range.start); + const start_bit = @as(ShiftInt, @intCast(range.start)); var mask = std.math.boolMask(MaskInt, true) << start_bit; if (range.end != bit_length) { - const end_bit = @intCast(ShiftInt, range.end); - mask &= std.math.boolMask(MaskInt, true) >> @truncate(ShiftInt, @as(usize, @bitSizeOf(MaskInt)) - @as(usize, end_bit)); + const end_bit = @as(ShiftInt, @intCast(range.end)); + mask &= std.math.boolMask(MaskInt, true) >> @as(ShiftInt, @truncate(@as(usize, @bitSizeOf(MaskInt)) - @as(usize, end_bit))); } self.mask &= ~mask; mask = std.math.boolMask(MaskInt, value) << start_bit; if (range.end != bit_length) { - const end_bit = @intCast(ShiftInt, range.end); - mask &= std.math.boolMask(MaskInt, value) >> @truncate(ShiftInt, @as(usize, @bitSizeOf(MaskInt)) - @as(usize, end_bit)); + const end_bit = @as(ShiftInt, @intCast(range.end)); + mask &= std.math.boolMask(MaskInt, value) >> @as(ShiftInt, @truncate(@as(usize, @bitSizeOf(MaskInt)) - @as(usize, end_bit))); } self.mask |= mask; } @@ -292,7 +292,7 @@ pub fn IntegerBitSet(comptime size: u16) type { .reverse => { const leading_zeroes = @clz(self.bits_remain); const top_bit = (@bitSizeOf(MaskInt) - 1) - leading_zeroes; - self.bits_remain &= (@as(MaskInt, 1) << @intCast(ShiftInt, top_bit)) - 1; + self.bits_remain &= (@as(MaskInt, 1) << @as(ShiftInt, @intCast(top_bit))) - 1; return top_bit; }, } @@ -302,11 +302,11 @@ pub fn IntegerBitSet(comptime size: u16) type { fn maskBit(index: usize) MaskInt { if (MaskInt == u0) return 0; - return @as(MaskInt, 1) << @intCast(ShiftInt, index); + return @as(MaskInt, 1) << @as(ShiftInt, @intCast(index)); } fn boolMaskBit(index: usize, value: bool) MaskInt { if (MaskInt == u0) return 0; - return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @as(ShiftInt, @intCast(index)); } }; } @@ -442,10 +442,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { if (num_masks == 0) return; const start_mask_index = maskIndex(range.start); - const start_bit = @truncate(ShiftInt, range.start); + const start_bit = @as(ShiftInt, @truncate(range.start)); const end_mask_index = maskIndex(range.end); - const end_bit = @truncate(ShiftInt, range.end); + const end_bit = @as(ShiftInt, @truncate(range.end)); if (start_mask_index == end_mask_index) { var mask1 = std.math.boolMask(MaskInt, true) << start_bit; @@ -634,13 +634,13 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { } fn maskBit(index: usize) MaskInt { - return @as(MaskInt, 1) << @truncate(ShiftInt, index); + return @as(MaskInt, 1) << @as(ShiftInt, @truncate(index)); } fn maskIndex(index: usize) usize { return index >> @bitSizeOf(ShiftInt); } fn boolMaskBit(index: usize, value: bool) MaskInt { - return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @as(ShiftInt, @intCast(index)); } }; } @@ -731,7 +731,7 @@ pub const DynamicBitSetUnmanaged = struct { // set the padding bits in the old last item to 1 if (fill and old_masks > 0) { const old_padding_bits = old_masks * @bitSizeOf(MaskInt) - old_len; - const old_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, old_padding_bits); + const old_mask = (~@as(MaskInt, 0)) >> @as(ShiftInt, @intCast(old_padding_bits)); self.masks[old_masks - 1] |= ~old_mask; } @@ -745,7 +745,7 @@ pub const DynamicBitSetUnmanaged = struct { // Zero out the padding bits if (new_len > 0) { const padding_bits = new_masks * @bitSizeOf(MaskInt) - new_len; - const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits); + const last_item_mask = (~@as(MaskInt, 0)) >> @as(ShiftInt, @intCast(padding_bits)); self.masks[new_masks - 1] &= last_item_mask; } @@ -816,10 +816,10 @@ pub const DynamicBitSetUnmanaged = struct { if (range.start == range.end) return; const start_mask_index = maskIndex(range.start); - const start_bit = @truncate(ShiftInt, range.start); + const start_bit = @as(ShiftInt, @truncate(range.start)); const end_mask_index = maskIndex(range.end); - const end_bit = @truncate(ShiftInt, range.end); + const end_bit = @as(ShiftInt, @truncate(range.end)); if (start_mask_index == end_mask_index) { var mask1 = std.math.boolMask(MaskInt, true) << start_bit; @@ -887,7 +887,7 @@ pub const DynamicBitSetUnmanaged = struct { } const padding_bits = num_masks * @bitSizeOf(MaskInt) - bit_length; - const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits); + const last_item_mask = (~@as(MaskInt, 0)) >> @as(ShiftInt, @intCast(padding_bits)); self.masks[num_masks - 1] &= last_item_mask; } @@ -996,7 +996,7 @@ pub const DynamicBitSetUnmanaged = struct { pub fn iterator(self: *const Self, comptime options: IteratorOptions) Iterator(options) { const num_masks = numMasks(self.bit_length); const padding_bits = num_masks * @bitSizeOf(MaskInt) - self.bit_length; - const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits); + const last_item_mask = (~@as(MaskInt, 0)) >> @as(ShiftInt, @intCast(padding_bits)); return Iterator(options).init(self.masks[0..num_masks], last_item_mask); } @@ -1005,13 +1005,13 @@ pub const DynamicBitSetUnmanaged = struct { } fn maskBit(index: usize) MaskInt { - return @as(MaskInt, 1) << @truncate(ShiftInt, index); + return @as(MaskInt, 1) << @as(ShiftInt, @truncate(index)); } fn maskIndex(index: usize) usize { return index >> @bitSizeOf(ShiftInt); } fn boolMaskBit(index: usize, value: bool) MaskInt { - return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @as(ShiftInt, @intCast(index)); } fn numMasks(bit_length: usize) usize { return (bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt); @@ -1255,7 +1255,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ .reverse => { const leading_zeroes = @clz(self.bits_remain); const top_bit = (@bitSizeOf(MaskInt) - 1) - leading_zeroes; - const no_top_bit_mask = (@as(MaskInt, 1) << @intCast(ShiftInt, top_bit)) - 1; + const no_top_bit_mask = (@as(MaskInt, 1) << @as(ShiftInt, @intCast(top_bit))) - 1; self.bits_remain &= no_top_bit_mask; return top_bit + self.bit_offset; }, |
