authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-22 23:52:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-22 23:52:52-07:00
log0262dda9b82ab75c7f35908456e82545a5781b99
treece2d3b5715517209990259e6be89ebccc048022e
parent715abe8ebeebb6d49db1e265748554404c3aab98

std: remove `comptime const`


2 files changed, 12 insertions(+), 12 deletions(-)

lib/std/enums.zig+6-6
...@@ -283,8 +283,8 @@ pub fn EnumSet(comptime E: type) type {...@@ -283,8 +283,8 @@ pub fn EnumSet(comptime E: type) type {
283 var result = Self{};283 var result = Self{};
284 comptime var i: usize = 0;284 comptime var i: usize = 0;
285 inline while (i < Self.len) : (i += 1) {285 inline while (i < Self.len) : (i += 1) {
286 comptime const key = Indexer.keyForIndex(i);286 const key = comptime Indexer.keyForIndex(i);
287 comptime const tag = @tagName(key);287 const tag = comptime @tagName(key);
288 if (@field(init_values, tag)) {288 if (@field(init_values, tag)) {
289 result.bits.set(i);289 result.bits.set(i);
290 }290 }
...@@ -311,8 +311,8 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -311,8 +311,8 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
311 var result = Self{};311 var result = Self{};
312 comptime var i: usize = 0;312 comptime var i: usize = 0;
313 inline while (i < Self.len) : (i += 1) {313 inline while (i < Self.len) : (i += 1) {
314 comptime const key = Indexer.keyForIndex(i);314 const key = comptime Indexer.keyForIndex(i);
315 comptime const tag = @tagName(key);315 const tag = comptime @tagName(key);
316 if (@field(init_values, tag)) |*v| {316 if (@field(init_values, tag)) |*v| {
317 result.bits.set(i);317 result.bits.set(i);
318 result.values[i] = v.*;318 result.values[i] = v.*;
...@@ -344,8 +344,8 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -344,8 +344,8 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
344 };344 };
345 comptime var i: usize = 0;345 comptime var i: usize = 0;
346 inline while (i < Self.len) : (i += 1) {346 inline while (i < Self.len) : (i += 1) {
347 comptime const key = Indexer.keyForIndex(i);347 const key = comptime Indexer.keyForIndex(i);
348 comptime const tag = @tagName(key);348 const tag = comptime @tagName(key);
349 result.values[i] = @field(init_values, tag);349 result.values[i] = @field(init_values, tag);
350 }350 }
351 return result;351 return result;
lib/std/math.zig+6-6
...@@ -986,9 +986,9 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(...@@ -986,9 +986,9 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(
986 comptime assert(@typeInfo(T) == .Int);986 comptime assert(@typeInfo(T) == .Int);
987 comptime assert(@typeInfo(T).Int.signedness == .unsigned);987 comptime assert(@typeInfo(T).Int.signedness == .unsigned);
988 assert(value != 0);988 assert(value != 0);
989 comptime const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1);989 const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1);
990 comptime const shiftType = std.math.Log2Int(PromotedType);990 const ShiftType = std.math.Log2Int(PromotedType);
991 return @as(PromotedType, 1) << @intCast(shiftType, @typeInfo(T).Int.bits - @clz(T, value - 1));991 return @as(PromotedType, 1) << @intCast(ShiftType, @typeInfo(T).Int.bits - @clz(T, value - 1));
992}992}
993993
994/// Returns the next power of two (if the value is not already a power of two).994/// 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) {...@@ -998,8 +998,8 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
998 comptime assert(@typeInfo(T) == .Int);998 comptime assert(@typeInfo(T) == .Int);
999 const info = @typeInfo(T).Int;999 const info = @typeInfo(T).Int;
1000 comptime assert(info.signedness == .unsigned);1000 comptime assert(info.signedness == .unsigned);
1001 comptime const PromotedType = std.meta.Int(info.signedness, info.bits + 1);1001 const PromotedType = std.meta.Int(info.signedness, info.bits + 1);
1002 comptime const overflowBit = @as(PromotedType, 1) << info.bits;1002 const overflowBit = @as(PromotedType, 1) << info.bits;
1003 var x = ceilPowerOfTwoPromote(T, value);1003 var x = ceilPowerOfTwoPromote(T, value);
1004 if (overflowBit & x != 0) {1004 if (overflowBit & x != 0) {
1005 return error.Overflow;1005 return error.Overflow;
...@@ -1327,7 +1327,7 @@ test "order.compare" {...@@ -1327,7 +1327,7 @@ test "order.compare" {
1327}1327}
13281328
1329test "math.comptime" {1329test "math.comptime" {
1330 comptime const v = sin(@as(f32, 1)) + ln(@as(f32, 5));1330 const v = comptime (sin(@as(f32, 1)) + ln(@as(f32, 5)));
1331 testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5)));1331 testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5)));
1332}1332}
13331333