Commit c60d8f017e

Andrew Kelley <andrew@ziglang.org>
2021-04-29 07:58:12
std: remove redundant comptime keyword
@g-w1's fancy new compile error in action
1 parent 0c71d2f
lib/std/crypto/25519/edwards25519.zig
@@ -226,12 +226,12 @@ pub const Edwards25519 = struct {
         return pc;
     }
 
-    const basePointPc = comptime pc: {
+    const basePointPc = pc: {
         @setEvalBranchQuota(10000);
         break :pc precompute(Edwards25519.basePoint, 15);
     };
 
-    const basePointPc8 = comptime pc: {
+    const basePointPc8 = pc: {
         @setEvalBranchQuota(10000);
         break :pc precompute(Edwards25519.basePoint, 8);
     };
lib/std/crypto/25519/field.zig
@@ -292,7 +292,7 @@ pub const Fe = struct {
         return _carry128(&r);
     }
 
-    fn _sq(a: Fe, double: comptime bool) callconv(.Inline) Fe {
+    fn _sq(a: Fe, double: bool) callconv(.Inline) Fe {
         var ax: [5]u128 = undefined;
         var r: [5]u128 = undefined;
         comptime var i = 0;
lib/std/crypto/aes.zig
@@ -8,9 +8,9 @@ const std = @import("../std.zig");
 const testing = std.testing;
 const builtin = std.builtin;
 
-const has_aesni = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
-const has_avx = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
-const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
+const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
+const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
+const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
 const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
     break :impl @import("aes/aesni.zig");
 } else if (std.Target.current.cpu.arch == .aarch64 and has_armaes)
lib/std/crypto/aes_ocb.zig
@@ -106,8 +106,8 @@ fn AesOcb(comptime Aes: anytype) type {
             return offset;
         }
 
-        const has_aesni = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
-        const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
+        const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
+        const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
         const wb: usize = if ((std.Target.current.cpu.arch == .x86_64 and has_aesni) or (std.Target.current.cpu.arch == .aarch64 and has_armaes)) 4 else 0;
 
         /// c: ciphertext: output buffer should be of size m.len
lib/std/crypto/ghash.zig
@@ -137,9 +137,9 @@ pub const Ghash = struct {
         return z0 | z1 | z2 | z3;
     }
 
-    const has_pclmul = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .pclmul);
-    const has_avx = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
-    const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
+    const has_pclmul = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .pclmul);
+    const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
+    const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
     const clmul = if (std.Target.current.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
         break :impl clmul_pclmul;
     } else if (std.Target.current.cpu.arch == .aarch64 and has_armaes) impl: {
lib/std/crypto/modes.zig
@@ -16,7 +16,7 @@ const debug = std.debug;
 ///
 /// Important: the counter mode doesn't provide authenticated encryption: the ciphertext can be trivially modified without this being detected.
 /// As a result, applications should generally never use it directly, but only in a construction that includes a MAC.
-pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: comptime builtin.Endian) void {
+pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: builtin.Endian) void {
     debug.assert(dst.len >= src.len);
     const block_length = BlockCipher.block_length;
     var counter: [BlockCipher.block_length]u8 = undefined;
lib/std/crypto/poly1305.zig
@@ -39,7 +39,7 @@ pub const Poly1305 = struct {
         };
     }
 
-    fn blocks(st: *Poly1305, m: []const u8, last: comptime bool) void {
+    fn blocks(st: *Poly1305, m: []const u8, last: bool) void {
         const hibit: u64 = if (last) 0 else 1 << 40;
         const r0 = st.r[0];
         const r1 = st.r[1];
lib/std/hash/crc.zig
@@ -28,7 +28,7 @@ pub const Crc32 = Crc32WithPoly(.IEEE);
 pub fn Crc32WithPoly(comptime poly: Polynomial) type {
     return struct {
         const Self = @This();
-        const lookup_tables = comptime block: {
+        const lookup_tables = block: {
             @setEvalBranchQuota(20000);
             var tables: [8][256]u32 = undefined;
 
@@ -128,7 +128,7 @@ test "crc32 castagnoli" {
 pub fn Crc32SmallWithPoly(comptime poly: Polynomial) type {
     return struct {
         const Self = @This();
-        const lookup_table = comptime block: {
+        const lookup_table = block: {
             var table: [16]u32 = undefined;
 
             for (table) |*e, i| {
lib/std/io/bit_reader.zig
@@ -23,9 +23,9 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
         pub const Reader = io.Reader(*Self, Error, read);
 
         const Self = @This();
-        const u8_bit_count = comptime meta.bitCount(u8);
-        const u7_bit_count = comptime meta.bitCount(u7);
-        const u4_bit_count = comptime meta.bitCount(u4);
+        const u8_bit_count = meta.bitCount(u8);
+        const u7_bit_count = meta.bitCount(u7);
+        const u4_bit_count = meta.bitCount(u4);
 
         pub fn init(forward_reader: ReaderType) Self {
             return Self{
lib/std/io/bit_writer.zig
@@ -23,8 +23,8 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
         pub const Writer = io.Writer(*Self, Error, write);
 
         const Self = @This();
-        const u8_bit_count = comptime meta.bitCount(u8);
-        const u4_bit_count = comptime meta.bitCount(u4);
+        const u8_bit_count = meta.bitCount(u8);
+        const u4_bit_count = meta.bitCount(u4);
 
         pub fn init(forward_writer: WriterType) Self {
             return Self{
lib/std/debug.zig
@@ -353,18 +353,18 @@ pub const StackIterator = struct {
     }
 
     // Offset of the saved BP wrt the frame pointer.
-    const fp_offset = if (comptime native_arch.isRISCV())
+    const fp_offset = if (native_arch.isRISCV())
         // On RISC-V the frame pointer points to the top of the saved register
         // area, on pretty much every other architecture it points to the stack
         // slot where the previous frame pointer is saved.
         2 * @sizeOf(usize)
-    else if (comptime native_arch.isSPARC())
+    else if (native_arch.isSPARC())
         // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS.
         14 * @sizeOf(usize)
     else
         0;
 
-    const fp_bias = if (comptime native_arch.isSPARC())
+    const fp_bias = if (native_arch.isSPARC())
         // On SPARC frame pointers are biased by a constant.
         2047
     else
lib/std/heap.zig
@@ -28,17 +28,17 @@ const CAllocator = struct {
         }
     }
 
-    usingnamespace if (comptime @hasDecl(c, "malloc_size"))
+    usingnamespace if (@hasDecl(c, "malloc_size"))
         struct {
             pub const supports_malloc_size = true;
             pub const malloc_size = c.malloc_size;
         }
-    else if (comptime @hasDecl(c, "malloc_usable_size"))
+    else if (@hasDecl(c, "malloc_usable_size"))
         struct {
             pub const supports_malloc_size = true;
             pub const malloc_size = c.malloc_usable_size;
         }
-    else if (comptime @hasDecl(c, "_msize"))
+    else if (@hasDecl(c, "_msize"))
         struct {
             pub const supports_malloc_size = true;
             pub const malloc_size = c._msize;