Commit 0262dda9b8

Andrew Kelley <andrew@ziglang.org>
2021-04-23 08:52:52
std: remove `comptime const`
1 parent 715abe8
Changed files (2)
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;
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)));
 }