Commit 507a8096d2
Changed files (40)
lib
std
crypto
os
valgrind
lib/std/crypto/25519/edwards25519.zig
@@ -238,7 +238,7 @@ pub const Edwards25519 = struct {
pub fn mul(p: Edwards25519, s: [32]u8) Error!Edwards25519 {
const pc = if (p.is_base) basePointPc else pc: {
const xpc = precompute(p, 15);
- xpc[4].rejectIdentity() catch |_| return error.WeakPublicKey;
+ xpc[4].rejectIdentity() catch return error.WeakPublicKey;
break :pc xpc;
};
return pcMul16(pc, s, false);
@@ -251,7 +251,7 @@ pub const Edwards25519 = struct {
return pcMul16(basePointPc, s, true);
} else {
const pc = precompute(p, 8);
- pc[4].rejectIdentity() catch |_| return error.WeakPublicKey;
+ pc[4].rejectIdentity() catch return error.WeakPublicKey;
return pcMul(pc, s, true);
}
}
@@ -266,7 +266,7 @@ pub const Edwards25519 = struct {
pcs[i] = comptime precompute(Edwards25519.basePoint, 8);
} else {
pcs[i] = precompute(p, 8);
- pcs[i][4].rejectIdentity() catch |_| return error.WeakPublicKey;
+ pcs[i][4].rejectIdentity() catch return error.WeakPublicKey;
}
}
var es: [count][2 * 32]i8 = undefined;
lib/std/crypto/utils.zig
@@ -16,9 +16,9 @@ pub fn timingSafeEql(comptime T: type, a: T, b: T) bool {
for (a) |x, i| {
acc |= x ^ b[i];
}
- comptime const s = @typeInfo(C).Int.bits;
- comptime const Cu = std.meta.Int(.unsigned, s);
- comptime const Cext = std.meta.Int(.unsigned, s + 1);
+ const s = @typeInfo(C).Int.bits;
+ const Cu = std.meta.Int(.unsigned, s);
+ const Cext = std.meta.Int(.unsigned, s + 1);
return @bitCast(bool, @truncate(u1, (@as(Cext, @bitCast(Cu, acc)) -% 1) >> s));
},
.Vector => |info| {
@@ -27,9 +27,9 @@ pub fn timingSafeEql(comptime T: type, a: T, b: T) bool {
@compileError("Elements to be compared must be integers");
}
const acc = @reduce(.Or, a ^ b);
- comptime const s = @typeInfo(C).Int.bits;
- comptime const Cu = std.meta.Int(.unsigned, s);
- comptime const Cext = std.meta.Int(.unsigned, s + 1);
+ const s = @typeInfo(C).Int.bits;
+ const Cu = std.meta.Int(.unsigned, s);
+ const Cext = std.meta.Int(.unsigned, s + 1);
return @bitCast(bool, @truncate(u1, (@as(Cext, @bitCast(Cu, acc)) -% 1) >> s));
},
else => {
lib/std/os/bits/linux/arm-eabi.zig
@@ -15,7 +15,7 @@ const uid_t = linux.uid_t;
const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
restart_syscall = 0,
exit = 1,
fork = 2,
lib/std/os/bits/linux/arm64.zig
@@ -16,7 +16,7 @@ const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
io_setup = 0,
io_destroy = 1,
io_submit = 2,
lib/std/os/bits/linux/i386.zig
@@ -17,7 +17,7 @@ const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
restart_syscall = 0,
exit = 1,
fork = 2,
lib/std/os/bits/linux/mips.zig
@@ -12,7 +12,7 @@ const uid_t = linux.uid_t;
const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
pub const Linux = 4000;
syscall = Linux + 0,
lib/std/os/bits/linux/netlink.zig
@@ -126,7 +126,7 @@ pub const NLM_F_CAPPED = 0x100;
/// extended ACK TVLs were included
pub const NLM_F_ACK_TLVS = 0x200;
-pub const NetlinkMessageType = extern enum(u16) {
+pub const NetlinkMessageType = enum(u16) {
/// < 0x10: reserved control messages
pub const MIN_TYPE = 0x10;
@@ -287,7 +287,7 @@ pub const rtattr = extern struct {
pub const ALIGNTO = 4;
};
-pub const IFLA = extern enum(c_ushort) {
+pub const IFLA = enum(c_ushort) {
UNSPEC,
ADDRESS,
BROADCAST,
@@ -351,8 +351,7 @@ pub const IFLA = extern enum(c_ushort) {
EVENT,
NEW_NETNSID,
- IF_NETNSID = 46,
- TARGET_NETNSID = 46, // new alias
+ IF_NETNSID,
CARRIER_UP_COUNT,
CARRIER_DOWN_COUNT,
@@ -361,6 +360,8 @@ pub const IFLA = extern enum(c_ushort) {
MAX_MTU,
_,
+
+ pub const TARGET_NETNSID: IFLA = .IF_NETNSID;
};
pub const rtnl_link_ifmap = extern struct {
lib/std/os/bits/linux/powerpc.zig
@@ -14,7 +14,7 @@ const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
restart_syscall = 0,
exit = 1,
fork = 2,
lib/std/os/bits/linux/powerpc64.zig
@@ -14,7 +14,7 @@ const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
restart_syscall = 0,
exit = 1,
fork = 2,
@@ -295,7 +295,7 @@ pub const SYS = extern enum(usize) {
mknodat = 288,
fchownat = 289,
futimesat = 290,
- newfstatat = 291,
+ fstatat = 291,
unlinkat = 292,
renameat = 293,
linkat = 294,
lib/std/os/bits/linux/prctl.zig
@@ -4,7 +4,7 @@
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
-pub const PR = extern enum(i32) {
+pub const PR = enum(i32) {
SET_PDEATHSIG = 1,
GET_PDEATHSIG = 2,
lib/std/os/bits/linux/riscv64.zig
@@ -9,7 +9,7 @@ const uid_t = std.os.linux.uid_t;
const gid_t = std.os.linux.gid_t;
const pid_t = std.os.linux.pid_t;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
pub const arch_specific_syscall = 244;
io_setup = 0,
lib/std/os/bits/linux/sparc64.zig
@@ -12,7 +12,7 @@ const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
const iovec_const = linux.iovec_const;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
restart_syscall = 0,
exit = 1,
fork = 2,
lib/std/os/bits/linux/x86_64.zig
@@ -21,7 +21,7 @@ const iovec_const = linux.iovec_const;
pub const mode_t = usize;
pub const time_t = isize;
-pub const SYS = extern enum(usize) {
+pub const SYS = enum(usize) {
read = 0,
write = 1,
open = 2,
@@ -284,7 +284,6 @@ pub const SYS = extern enum(usize) {
mknodat = 259,
fchownat = 260,
futimesat = 261,
- newfstatat = 262,
fstatat = 262,
unlinkat = 263,
renameat = 264,
lib/std/os/bits/darwin.zig
@@ -1521,19 +1521,19 @@ pub const rusage = extern struct {
nivcsw: isize,
};
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
CPU = 0,
FSIZE = 1,
DATA = 2,
STACK = 3,
CORE = 4,
- AS = 5,
RSS = 5,
MEMLOCK = 6,
NPROC = 7,
NOFILE = 8,
-
_,
+
+ pub const AS: rlimit_resource = .RSS;
};
pub const rlim_t = u64;
@@ -1669,7 +1669,7 @@ pub const TCSANOW = 0; // make change immediate
pub const TCSADRAIN = 1; // drain output, then change
pub const TCSAFLUSH = 2; // drain output, flush input
pub const TCSASOFT = 0x10; // flag - don't alter h.w. state
-pub const TCSA = extern enum(c_uint) {
+pub const TCSA = enum(c_uint) {
NOW,
DRAIN,
FLUSH,
lib/std/os/bits/dragonfly.zig
@@ -734,7 +734,7 @@ pub const Flock = extern struct {
l_whence: c_short,
};
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
CPU = 0,
FSIZE = 1,
DATA = 2,
@@ -745,11 +745,11 @@ pub const rlimit_resource = extern enum(c_int) {
NPROC = 7,
NOFILE = 8,
SBSIZE = 9,
- AS = 10,
VMEM = 10,
POSIXLOCKS = 11,
-
_,
+
+ pub const AS: rlimit_resource = .VMEM;
};
pub const rlim_t = i64;
lib/std/os/bits/freebsd.zig
@@ -1459,7 +1459,7 @@ pub const IPPROTO_RESERVED_253 = 253;
/// Reserved
pub const IPPROTO_RESERVED_254 = 254;
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
CPU = 0,
FSIZE = 1,
DATA = 2,
@@ -1471,13 +1471,13 @@ pub const rlimit_resource = extern enum(c_int) {
NOFILE = 8,
SBSIZE = 9,
VMEM = 10,
- AS = 10,
NPTS = 11,
SWAP = 12,
KQUEUES = 13,
UMTXP = 14,
-
_,
+
+ pub const AS: rlimit_resource = .VMEM;
};
pub const rlim_t = i64;
lib/std/os/bits/haiku.zig
@@ -1401,7 +1401,7 @@ pub const IPPROTO_RESERVED_253 = 253;
/// Reserved
pub const IPPROTO_RESERVED_254 = 254;
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
CPU = 0,
FSIZE = 1,
DATA = 2,
@@ -1413,13 +1413,13 @@ pub const rlimit_resource = extern enum(c_int) {
NOFILE = 8,
SBSIZE = 9,
VMEM = 10,
- AS = 10,
NPTS = 11,
SWAP = 12,
KQUEUES = 13,
UMTXP = 14,
-
_,
+
+ pub const AS: rlimit_resource = .VMEM;
};
pub const rlim_t = i64;
@@ -1442,7 +1442,7 @@ pub const SHUT_WR = 1;
pub const SHUT_RDWR = 2;
// TODO fill out if needed
-pub const directory_which = extern enum(c_int) {
+pub const directory_which = enum(c_int) {
B_USER_SETTINGS_DIRECTORY = 0xbbe,
_,
lib/std/os/bits/linux.zig
@@ -1487,7 +1487,7 @@ pub const io_uring_sqe = extern struct {
__pad2: [2]u64,
};
-pub const IOSQE_BIT = extern enum(u8) {
+pub const IOSQE_BIT = enum(u8) {
FIXED_FILE,
IO_DRAIN,
IO_LINK,
@@ -1518,7 +1518,7 @@ pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC);
/// select buffer from buf_group
pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT);
-pub const IORING_OP = extern enum(u8) {
+pub const IORING_OP = enum(u8) {
NOP,
READV,
WRITEV,
@@ -1587,7 +1587,7 @@ pub const IORING_ENTER_GETEVENTS = 1 << 0;
pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
// io_uring_register opcodes and arguments
-pub const IORING_REGISTER = extern enum(u8) {
+pub const IORING_REGISTER = enum(u8) {
REGISTER_BUFFERS,
UNREGISTER_BUFFERS,
REGISTER_FILES,
@@ -1654,7 +1654,7 @@ pub const io_uring_restriction = extern struct {
};
/// io_uring_restriction->opcode values
-pub const IORING_RESTRICTION = extern enum(u8) {
+pub const IORING_RESTRICTION = enum(u8) {
/// Allow an io_uring_register(2) opcode
REGISTER_OP = 0,
@@ -1909,7 +1909,7 @@ pub const tcp_repair_window = extern struct {
rcv_wup: u32,
};
-pub const TcpRepairOption = extern enum {
+pub const TcpRepairOption = enum {
TCP_NO_QUEUE,
TCP_RECV_QUEUE,
TCP_SEND_QUEUE,
@@ -1917,7 +1917,7 @@ pub const TcpRepairOption = extern enum {
};
/// why fastopen failed from client perspective
-pub const tcp_fastopen_client_fail = extern enum {
+pub const tcp_fastopen_client_fail = enum {
/// catch-all
TFO_STATUS_UNSPEC,
/// if not in TFO_CLIENT_NO_COOKIE mode
@@ -2184,7 +2184,7 @@ pub const NOFLSH = 128;
pub const TOSTOP = 256;
pub const IEXTEN = 32768;
-pub const TCSA = extern enum(c_uint) {
+pub const TCSA = enum(c_uint) {
NOW,
DRAIN,
FLUSH,
@@ -2235,7 +2235,7 @@ pub const ifreq = extern struct {
};
// doc comments copied from musl
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
/// Per-process CPU limit, in seconds.
CPU,
lib/std/os/bits/netbsd.zig
@@ -60,7 +60,7 @@ pub const addrinfo = extern struct {
next: ?*addrinfo,
};
-pub const EAI = extern enum(c_int) {
+pub const EAI = enum(c_int) {
/// address family for hostname not supported
ADDRFAMILY = 1,
@@ -1179,7 +1179,7 @@ pub const IPPROTO_PFSYNC = 240;
/// raw IP packet
pub const IPPROTO_RAW = 255;
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
CPU = 0,
FSIZE = 1,
DATA = 2,
@@ -1190,11 +1190,11 @@ pub const rlimit_resource = extern enum(c_int) {
NPROC = 7,
NOFILE = 8,
SBSIZE = 9,
- AS = 10,
VMEM = 10,
NTHR = 11,
-
_,
+
+ pub const AS: rlimit_resource = .VMEM;
};
pub const rlim_t = u64;
lib/std/os/bits/openbsd.zig
@@ -76,7 +76,7 @@ pub const addrinfo = extern struct {
next: ?*addrinfo,
};
-pub const EAI = extern enum(c_int) {
+pub const EAI = enum(c_int) {
/// address family for hostname not supported
ADDRFAMILY = -9,
@@ -805,7 +805,7 @@ comptime {
if (@sizeOf(usize) == 4)
std.debug.assert(@sizeOf(siginfo_t) == 128)
else
- // Take into account the padding between errno and data fields.
+ // Take into account the padding between errno and data fields.
std.debug.assert(@sizeOf(siginfo_t) == 136);
}
@@ -1177,7 +1177,7 @@ pub const IPPROTO_PFSYNC = 240;
/// raw IP packet
pub const IPPROTO_RAW = 255;
-pub const rlimit_resource = extern enum(c_int) {
+pub const rlimit_resource = enum(c_int) {
CPU,
FSIZE,
DATA,
lib/std/os/uefi/status.zig
@@ -5,7 +5,7 @@
// and substantial portions of the software.
const high_bit = 1 << @typeInfo(usize).Int.bits - 1;
-pub const Status = extern enum(usize) {
+pub const Status = enum(usize) {
/// The operation completed successfully.
Success = 0,
lib/std/os/windows/bits.zig
@@ -281,7 +281,7 @@ pub const IO_STATUS_BLOCK = extern struct {
Information: ULONG_PTR,
};
-pub const FILE_INFORMATION_CLASS = extern enum {
+pub const FILE_INFORMATION_CLASS = enum(c_int) {
FileDirectoryInformation = 1,
FileFullDirectoryInformation,
FileBothDirectoryInformation,
@@ -901,7 +901,7 @@ pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;
pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;
pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;
pub const COINIT_SPEED_OVER_MEMORY = COINIT.COINIT_SPEED_OVER_MEMORY;
-pub const COINIT = extern enum {
+pub const COINIT = enum(c_int) {
COINIT_APARTMENTTHREADED = 2,
COINIT_MULTITHREADED = 0,
COINIT_DISABLE_OLE1DDE = 4,
@@ -1623,7 +1623,7 @@ pub const SD_RECEIVE = 0;
pub const SD_SEND = 1;
pub const SD_BOTH = 2;
-pub const OBJECT_INFORMATION_CLASS = extern enum {
+pub const OBJECT_INFORMATION_CLASS = enum(c_int) {
ObjectBasicInformation = 0,
ObjectNameInformation = 1,
ObjectTypeInformation = 2,
lib/std/os/windows/ntstatus.zig
@@ -4,7 +4,7 @@
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
// NTSTATUS codes from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55?
-pub const NTSTATUS = extern enum(u32) {
+pub const NTSTATUS = enum(u32) {
/// The operation completed successfully.
SUCCESS = 0x00000000,
lib/std/os/windows/win32error.zig
@@ -4,7 +4,7 @@
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
// Codes are from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d
-pub const Win32Error = extern enum(u16) {
+pub const Win32Error = enum(u16) {
/// The operation completed successfully.
SUCCESS = 0,
lib/std/os/windows/ws2_32.zig
@@ -256,7 +256,7 @@ pub const POLLHUP = 0x0002;
pub const POLLNVAL = 0x0004;
// https://docs.microsoft.com/en-au/windows/win32/winsock/windows-sockets-error-codes-2
-pub const WinsockError = extern enum(u16) {
+pub const WinsockError = enum(u16) {
/// Specified event object handle is invalid.
/// An application attempts to use an event object, but the specified handle is not valid.
WSA_INVALID_HANDLE = 6,
lib/std/os/linux.zig
@@ -1143,8 +1143,6 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *kernel_stat, flags: u32) usize {
if (@hasField(SYS, "fstatat64")) {
return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
- } else if (@hasField(SYS, "newfstatat")) {
- return syscall4(.newfstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
} else {
return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
}
lib/std/valgrind/callgrind.zig
@@ -6,7 +6,7 @@
const std = @import("../std.zig");
const valgrind = std.valgrind;
-pub const CallgrindClientRequest = extern enum {
+pub const CallgrindClientRequest = enum(usize) {
DumpStats = valgrind.ToolBase("CT"),
ZeroStats,
ToggleCollect,
lib/std/valgrind/memcheck.zig
@@ -7,7 +7,7 @@ const std = @import("../std.zig");
const testing = std.testing;
const valgrind = std.valgrind;
-pub const MemCheckClientRequest = extern enum {
+pub const MemCheckClientRequest = enum(usize) {
MakeMemNoAccess = valgrind.ToolBase("MC".*),
MakeMemUndefined,
MakeMemDefined,
@@ -76,7 +76,7 @@ pub fn createBlock(qzz: []u8, desc: [*]u8) usize {
/// Discard a block-description-handle. Returns 1 for an
/// invalid handle, 0 for a valid handle.
-pub fn discard(blkindex) bool {
+pub fn discard(blkindex: usize) bool {
return doMemCheckClientRequestExpr(0, // default return
.Discard, 0, blkindex, 0, 0, 0) != 0;
}
lib/std/array_hash_map.zig
@@ -1310,7 +1310,7 @@ test "reIndex" {
}
test "fromOwnedArrayList" {
- comptime const array_hash_map_type = AutoArrayHashMap(i32, i32);
+ const array_hash_map_type = AutoArrayHashMap(i32, i32);
var al = std.ArrayListUnmanaged(array_hash_map_type.Entry){};
const hash = getAutoHashFn(i32);
lib/std/elf.zig
@@ -311,7 +311,7 @@ pub const VER_FLG_BASE = 0x1;
pub const VER_FLG_WEAK = 0x2;
/// File types
-pub const ET = extern enum(u16) {
+pub const ET = enum(u16) {
/// No file type
NONE = 0,
@@ -991,7 +991,7 @@ pub const Half = switch (@sizeOf(usize)) {
/// See current registered ELF machine architectures at:
/// http://www.uxsglobal.com/developers/gabi/latest/ch4.eheader.html
/// The underscore prefix is because many of these start with numbers.
-pub const EM = extern enum(u16) {
+pub const EM = enum(u16) {
/// No machine
_NONE = 0,
lib/std/fmt.zig
@@ -187,7 +187,7 @@ pub fn format(
comptime var i = 0;
inline while (i < fmt.len) {
- comptime const start_index = i;
+ const start_index = i;
inline while (i < fmt.len) : (i += 1) {
switch (fmt[i]) {
@@ -226,10 +226,10 @@ pub fn format(
comptime assert(fmt[i] == '{');
i += 1;
- comptime const fmt_begin = i;
+ const fmt_begin = i;
// Find the closing brace
inline while (i < fmt.len and fmt[i] != '}') : (i += 1) {}
- comptime const fmt_end = i;
+ const fmt_end = i;
if (i >= fmt.len) {
@compileError("Missing closing }");
@@ -246,23 +246,23 @@ pub fn format(
parser.pos = 0;
// Parse the positional argument number
- comptime const opt_pos_arg = init: {
- if (comptime parser.maybe('[')) {
- comptime const arg_name = parser.until(']');
+ const opt_pos_arg = comptime init: {
+ if (parser.maybe('[')) {
+ const arg_name = parser.until(']');
- if (!comptime parser.maybe(']')) {
+ if (!parser.maybe(']')) {
@compileError("Expected closing ]");
}
- break :init comptime meta.fieldIndex(ArgsType, arg_name) orelse
+ break :init meta.fieldIndex(ArgsType, arg_name) orelse
@compileError("No argument with name '" ++ arg_name ++ "'");
} else {
- break :init comptime parser.number();
+ break :init parser.number();
}
};
// Parse the format specifier
- comptime const specifier_arg = comptime parser.until(':');
+ const specifier_arg = comptime parser.until(':');
// Skip the colon, if present
if (comptime parser.char()) |ch| {
@@ -302,13 +302,13 @@ pub fn format(
// Parse the width parameter
options.width = init: {
if (comptime parser.maybe('[')) {
- comptime const arg_name = parser.until(']');
+ const arg_name = parser.until(']');
if (!comptime parser.maybe(']')) {
@compileError("Expected closing ]");
}
- comptime const index = meta.fieldIndex(ArgsType, arg_name) orelse
+ const index = meta.fieldIndex(ArgsType, arg_name) orelse
@compileError("No argument with name '" ++ arg_name ++ "'");
const arg_index = comptime arg_state.nextArg(index);
@@ -328,13 +328,13 @@ pub fn format(
// Parse the precision parameter
options.precision = init: {
if (comptime parser.maybe('[')) {
- comptime const arg_name = parser.until(']');
+ const arg_name = parser.until(']');
if (!comptime parser.maybe(']')) {
@compileError("Expected closing ]");
}
- comptime const arg_i = meta.fieldIndex(ArgsType, arg_name) orelse
+ const arg_i = meta.fieldIndex(ArgsType, arg_name) orelse
@compileError("No argument with name '" ++ arg_name ++ "'");
const arg_to_use = comptime arg_state.nextArg(arg_i);
lib/std/json.zig
@@ -195,7 +195,7 @@ pub const StreamingParser = struct {
p.number_is_integer = undefined;
}
- pub const State = enum {
+ pub const State = enum(u8) {
// These must be first with these explicit values as we rely on them for indexing the
// bit-stack directly and avoiding a branch.
ObjectSeparator = 0,
@@ -1765,7 +1765,7 @@ test "parse" {
}
test "parse into enum" {
- const T = extern enum {
+ const T = enum(u32) {
Foo = 42,
Bar,
@"with\\escape",
lib/std/macho.zig
@@ -1314,13 +1314,13 @@ pub const BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: u8 = 0x40;
pub const BIND_OPCODE_SET_TYPE_IMM: u8 = 0x50;
pub const BIND_OPCODE_SET_ADDEND_SLEB: u8 = 0x60;
pub const BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: u8 = 0x70;
-pub const BIND_OPCODE_ADD_ADDR_ULEB: 0x80;
+pub const BIND_OPCODE_ADD_ADDR_ULEB: u8 = 0x80;
pub const BIND_OPCODE_DO_BIND: u8 = 0x90;
pub const BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: u8 = 0xa0;
pub const BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: u8 = 0xb0;
-pub const BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: u8 = xc0;
+pub const BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: u8 = 0xc0;
-pub const reloc_type_x86_64 = packed enum(u4) {
+pub const reloc_type_x86_64 = enum(u4) {
/// for absolute addresses
X86_64_RELOC_UNSIGNED = 0,
@@ -1352,9 +1352,9 @@ pub const reloc_type_x86_64 = packed enum(u4) {
X86_64_RELOC_TLV,
};
-pub const reloc_type_arm64 = packed enum(u4) {
+pub const reloc_type_arm64 = enum(u4) {
/// For pointers.
- ARM64_RELOC_UNSIGNED = 0,
+ ARM64_RELOC_UNSIGNED,
/// Must be followed by a ARM64_RELOC_UNSIGNED.
ARM64_RELOC_SUBTRACTOR,
lib/std/mem.zig
@@ -356,7 +356,7 @@ test "mem.zeroes" {
/// If the field is present in the provided initial values, it will have that value instead.
/// Structs are initialized recursively.
pub fn zeroInit(comptime T: type, init: anytype) T {
- comptime const Init = @TypeOf(init);
+ const Init = @TypeOf(init);
switch (@typeInfo(T)) {
.Struct => |struct_info| {
lib/std/meta.zig
@@ -335,9 +335,6 @@ test "std.meta.containerLayout" {
const E1 = enum {
A,
};
- const E2 = packed enum {
- A,
- };
const E3 = extern enum {
A,
};
@@ -355,7 +352,6 @@ test "std.meta.containerLayout" {
};
testing.expect(containerLayout(E1) == .Auto);
- testing.expect(containerLayout(E2) == .Packed);
testing.expect(containerLayout(E3) == .Extern);
testing.expect(containerLayout(S1) == .Auto);
testing.expect(containerLayout(S2) == .Packed);
lib/std/pdb.zig
@@ -115,7 +115,7 @@ pub const StreamType = enum(u16) {
/// Duplicate copy of SymbolRecordKind, but using the official CV names. Useful
/// for reference purposes and when dealing with unknown record types.
-pub const SymbolKind = packed enum(u16) {
+pub const SymbolKind = enum(u16) {
S_COMPILE = 1,
S_REGISTER_16t = 2,
S_CONSTANT_16t = 3,
@@ -426,7 +426,7 @@ pub const FileChecksumEntryHeader = packed struct {
ChecksumKind: u8,
};
-pub const DebugSubsectionKind = packed enum(u32) {
+pub const DebugSubsectionKind = enum(u32) {
None = 0,
Symbols = 0xf1,
Lines = 0xf2,
lib/std/valgrind.zig
@@ -48,7 +48,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
}
}
-pub const ClientRequest = extern enum {
+pub const ClientRequest = enum(u32) {
RunningOnValgrind = 4097,
DiscardTranslations = 4098,
ClientCall0 = 4353,
@@ -156,9 +156,9 @@ pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void {
}
/// Create a memory pool.
-pub const MempoolFlags = extern enum {
- AutoFree = 1,
- MetaPool = 2,
+pub const MempoolFlags = struct {
+ pub const AutoFree = 1;
+ pub const MetaPool = 2;
};
pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void {
doClientRequestStmt(.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0);
src/AstGen.zig
@@ -2658,7 +2658,9 @@ fn fnDecl(
var i: usize = 0;
var it = fn_proto.iterate(tree.*);
while (it.next()) |param| : (i += 1) {
- const name_token = param.name_token.?;
+ const name_token = param.name_token orelse {
+ return astgen.failNode(param.type_expr, "missing parameter name", .{});
+ };
const param_name = try astgen.identifierTokenString(name_token);
const sub_scope = try astgen.arena.create(Scope.LocalVal);
sub_scope.* = .{
src/Compilation.zig
@@ -3220,7 +3220,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) Alloc
\\const std = @import("std");
\\/// Zig version. When writing code that supports multiple versions of Zig, prefer
\\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
- \\pub const zig_version = try std.SemanticVersion.parse("{s}");
+ \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;
\\/// Temporary until self-hosted is feature complete.
\\pub const zig_is_stage2 = {};
\\/// Temporary until self-hosted supports the `cpu.arch` value.
BRANCH_TODO
@@ -32,6 +32,8 @@
compile error for a local shadowing a decl with Sema looking up the decl name.
- this means LocalVal and LocalPtr should use the string table
+ * sort compile errors before presenting them to eliminate nondeterministic error reporting
+
const container_name_hash: Scope.NameHash = if (found_pkg) |pkg|
pkg.namespace_hash
else