From 0262dda9b82ab75c7f35908456e82545a5781b99 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 22 Apr 2021 23:52:52 -0700 Subject: [PATCH] std: remove `comptime const` --- lib/std/enums.zig | 12 ++++++------ lib/std/math.zig | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/std/enums.zig b/lib/std/enums.zig index a868bdeb26..45eafdb9a9 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -283,8 +283,8 @@ pub fn EnumSet(comptime E: type) type { var result = Self{}; comptime var i: usize = 0; inline while (i < Self.len) : (i += 1) { - comptime const key = Indexer.keyForIndex(i); - comptime const tag = @tagName(key); + const key = comptime Indexer.keyForIndex(i); + const tag = comptime @tagName(key); if (@field(init_values, tag)) { result.bits.set(i); } @@ -311,8 +311,8 @@ pub fn EnumMap(comptime E: type, comptime V: type) type { var result = Self{}; comptime var i: usize = 0; inline while (i < Self.len) : (i += 1) { - comptime const key = Indexer.keyForIndex(i); - comptime const tag = @tagName(key); + const key = comptime Indexer.keyForIndex(i); + const tag = comptime @tagName(key); if (@field(init_values, tag)) |*v| { result.bits.set(i); result.values[i] = v.*; @@ -344,8 +344,8 @@ pub fn EnumMap(comptime E: type, comptime V: type) type { }; comptime var i: usize = 0; inline while (i < Self.len) : (i += 1) { - comptime const key = Indexer.keyForIndex(i); - comptime const tag = @tagName(key); + const key = comptime Indexer.keyForIndex(i); + const tag = comptime @tagName(key); result.values[i] = @field(init_values, tag); } return result; diff --git a/lib/std/math.zig b/lib/std/math.zig index d71cafe5ef..cb6f3cec1f 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -986,9 +986,9 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo( comptime assert(@typeInfo(T) == .Int); comptime assert(@typeInfo(T).Int.signedness == .unsigned); assert(value != 0); - comptime const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1); - comptime const shiftType = std.math.Log2Int(PromotedType); - return @as(PromotedType, 1) << @intCast(shiftType, @typeInfo(T).Int.bits - @clz(T, value - 1)); + const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1); + const ShiftType = std.math.Log2Int(PromotedType); + return @as(PromotedType, 1) << @intCast(ShiftType, @typeInfo(T).Int.bits - @clz(T, value - 1)); } /// Returns the next power of two (if the value is not already a power of two). @@ -998,8 +998,8 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { comptime assert(@typeInfo(T) == .Int); const info = @typeInfo(T).Int; comptime assert(info.signedness == .unsigned); - comptime const PromotedType = std.meta.Int(info.signedness, info.bits + 1); - comptime const overflowBit = @as(PromotedType, 1) << info.bits; + const PromotedType = std.meta.Int(info.signedness, info.bits + 1); + const overflowBit = @as(PromotedType, 1) << info.bits; var x = ceilPowerOfTwoPromote(T, value); if (overflowBit & x != 0) { return error.Overflow; @@ -1327,7 +1327,7 @@ test "order.compare" { } test "math.comptime" { - comptime const v = sin(@as(f32, 1)) + ln(@as(f32, 5)); + const v = comptime (sin(@as(f32, 1)) + ln(@as(f32, 5))); testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5))); }