authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-22 18:07:46-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-22 18:07:46-07:00
log507a8096d2f9624bafaf963c3e189a477ef6b7bf
treec21e3d54e1389fe44ecc7d5f230e792e26ab322d
parent7c453b91b85bab6800d24feb57c4f35b8ce48d57

std: fix compile errors caught by stage2 AstGen

* `comptime const` is redundant * don't use `extern enum`; specify a tag type. `extern enum` is only when you need tags to alias. But aliasing tags is a smell. I will be making a proposal shortly to remove `extern enum` from the language. * there is no such thing as `packed enum`. * instead of `catch |_|`, omit the capture entirely. * unused function definition with missing parameter name * using `try` outside of a function or test

40 files changed, 101 insertions(+), 103 deletions(-)

BRANCH_TODO+2
......@@ -32,6 +32,8 @@
3232 compile error for a local shadowing a decl with Sema looking up the decl name.
3333 - this means LocalVal and LocalPtr should use the string table
3434
35 * sort compile errors before presenting them to eliminate nondeterministic error reporting
36
3537 const container_name_hash: Scope.NameHash = if (found_pkg) |pkg|
3638 pkg.namespace_hash
3739 else
lib/std/array_hash_map.zig+1-1
......@@ -1310,7 +1310,7 @@ test "reIndex" {
13101310}
13111311
13121312test "fromOwnedArrayList" {
1313 comptime const array_hash_map_type = AutoArrayHashMap(i32, i32);
1313 const array_hash_map_type = AutoArrayHashMap(i32, i32);
13141314 var al = std.ArrayListUnmanaged(array_hash_map_type.Entry){};
13151315 const hash = getAutoHashFn(i32);
13161316
lib/std/crypto/25519/edwards25519.zig+3-3
......@@ -238,7 +238,7 @@ pub const Edwards25519 = struct {
238238 pub fn mul(p: Edwards25519, s: [32]u8) Error!Edwards25519 {
239239 const pc = if (p.is_base) basePointPc else pc: {
240240 const xpc = precompute(p, 15);
241 xpc[4].rejectIdentity() catch |_| return error.WeakPublicKey;
241 xpc[4].rejectIdentity() catch return error.WeakPublicKey;
242242 break :pc xpc;
243243 };
244244 return pcMul16(pc, s, false);
......@@ -251,7 +251,7 @@ pub const Edwards25519 = struct {
251251 return pcMul16(basePointPc, s, true);
252252 } else {
253253 const pc = precompute(p, 8);
254 pc[4].rejectIdentity() catch |_| return error.WeakPublicKey;
254 pc[4].rejectIdentity() catch return error.WeakPublicKey;
255255 return pcMul(pc, s, true);
256256 }
257257 }
......@@ -266,7 +266,7 @@ pub const Edwards25519 = struct {
266266 pcs[i] = comptime precompute(Edwards25519.basePoint, 8);
267267 } else {
268268 pcs[i] = precompute(p, 8);
269 pcs[i][4].rejectIdentity() catch |_| return error.WeakPublicKey;
269 pcs[i][4].rejectIdentity() catch return error.WeakPublicKey;
270270 }
271271 }
272272 var es: [count][2 * 32]i8 = undefined;
lib/std/crypto/utils.zig+6-6
......@@ -16,9 +16,9 @@ pub fn timingSafeEql(comptime T: type, a: T, b: T) bool {
1616 for (a) |x, i| {
1717 acc |= x ^ b[i];
1818 }
19 comptime const s = @typeInfo(C).Int.bits;
20 comptime const Cu = std.meta.Int(.unsigned, s);
21 comptime const Cext = std.meta.Int(.unsigned, s + 1);
19 const s = @typeInfo(C).Int.bits;
20 const Cu = std.meta.Int(.unsigned, s);
21 const Cext = std.meta.Int(.unsigned, s + 1);
2222 return @bitCast(bool, @truncate(u1, (@as(Cext, @bitCast(Cu, acc)) -% 1) >> s));
2323 },
2424 .Vector => |info| {
......@@ -27,9 +27,9 @@ pub fn timingSafeEql(comptime T: type, a: T, b: T) bool {
2727 @compileError("Elements to be compared must be integers");
2828 }
2929 const acc = @reduce(.Or, a ^ b);
30 comptime const s = @typeInfo(C).Int.bits;
31 comptime const Cu = std.meta.Int(.unsigned, s);
32 comptime const Cext = std.meta.Int(.unsigned, s + 1);
30 const s = @typeInfo(C).Int.bits;
31 const Cu = std.meta.Int(.unsigned, s);
32 const Cext = std.meta.Int(.unsigned, s + 1);
3333 return @bitCast(bool, @truncate(u1, (@as(Cext, @bitCast(Cu, acc)) -% 1) >> s));
3434 },
3535 else => {
lib/std/elf.zig+2-2
......@@ -311,7 +311,7 @@ pub const VER_FLG_BASE = 0x1;
311311pub const VER_FLG_WEAK = 0x2;
312312
313313/// File types
314pub const ET = extern enum(u16) {
314pub const ET = enum(u16) {
315315 /// No file type
316316 NONE = 0,
317317
......@@ -991,7 +991,7 @@ pub const Half = switch (@sizeOf(usize)) {
991991/// See current registered ELF machine architectures at:
992992/// http://www.uxsglobal.com/developers/gabi/latest/ch4.eheader.html
993993/// The underscore prefix is because many of these start with numbers.
994pub const EM = extern enum(u16) {
994pub const EM = enum(u16) {
995995 /// No machine
996996 _NONE = 0,
997997
lib/std/fmt.zig+14-14
......@@ -187,7 +187,7 @@ pub fn format(
187187
188188 comptime var i = 0;
189189 inline while (i < fmt.len) {
190 comptime const start_index = i;
190 const start_index = i;
191191
192192 inline while (i < fmt.len) : (i += 1) {
193193 switch (fmt[i]) {
......@@ -226,10 +226,10 @@ pub fn format(
226226 comptime assert(fmt[i] == '{');
227227 i += 1;
228228
229 comptime const fmt_begin = i;
229 const fmt_begin = i;
230230 // Find the closing brace
231231 inline while (i < fmt.len and fmt[i] != '}') : (i += 1) {}
232 comptime const fmt_end = i;
232 const fmt_end = i;
233233
234234 if (i >= fmt.len) {
235235 @compileError("Missing closing }");
......@@ -246,23 +246,23 @@ pub fn format(
246246 parser.pos = 0;
247247
248248 // Parse the positional argument number
249 comptime const opt_pos_arg = init: {
250 if (comptime parser.maybe('[')) {
251 comptime const arg_name = parser.until(']');
249 const opt_pos_arg = comptime init: {
250 if (parser.maybe('[')) {
251 const arg_name = parser.until(']');
252252
253 if (!comptime parser.maybe(']')) {
253 if (!parser.maybe(']')) {
254254 @compileError("Expected closing ]");
255255 }
256256
257 break :init comptime meta.fieldIndex(ArgsType, arg_name) orelse
257 break :init meta.fieldIndex(ArgsType, arg_name) orelse
258258 @compileError("No argument with name '" ++ arg_name ++ "'");
259259 } else {
260 break :init comptime parser.number();
260 break :init parser.number();
261261 }
262262 };
263263
264264 // Parse the format specifier
265 comptime const specifier_arg = comptime parser.until(':');
265 const specifier_arg = comptime parser.until(':');
266266
267267 // Skip the colon, if present
268268 if (comptime parser.char()) |ch| {
......@@ -302,13 +302,13 @@ pub fn format(
302302 // Parse the width parameter
303303 options.width = init: {
304304 if (comptime parser.maybe('[')) {
305 comptime const arg_name = parser.until(']');
305 const arg_name = parser.until(']');
306306
307307 if (!comptime parser.maybe(']')) {
308308 @compileError("Expected closing ]");
309309 }
310310
311 comptime const index = meta.fieldIndex(ArgsType, arg_name) orelse
311 const index = meta.fieldIndex(ArgsType, arg_name) orelse
312312 @compileError("No argument with name '" ++ arg_name ++ "'");
313313 const arg_index = comptime arg_state.nextArg(index);
314314
......@@ -328,13 +328,13 @@ pub fn format(
328328 // Parse the precision parameter
329329 options.precision = init: {
330330 if (comptime parser.maybe('[')) {
331 comptime const arg_name = parser.until(']');
331 const arg_name = parser.until(']');
332332
333333 if (!comptime parser.maybe(']')) {
334334 @compileError("Expected closing ]");
335335 }
336336
337 comptime const arg_i = meta.fieldIndex(ArgsType, arg_name) orelse
337 const arg_i = meta.fieldIndex(ArgsType, arg_name) orelse
338338 @compileError("No argument with name '" ++ arg_name ++ "'");
339339 const arg_to_use = comptime arg_state.nextArg(arg_i);
340340
lib/std/json.zig+2-2
......@@ -195,7 +195,7 @@ pub const StreamingParser = struct {
195195 p.number_is_integer = undefined;
196196 }
197197
198 pub const State = enum {
198 pub const State = enum(u8) {
199199 // These must be first with these explicit values as we rely on them for indexing the
200200 // bit-stack directly and avoiding a branch.
201201 ObjectSeparator = 0,
......@@ -1765,7 +1765,7 @@ test "parse" {
17651765}
17661766
17671767test "parse into enum" {
1768 const T = extern enum {
1768 const T = enum(u32) {
17691769 Foo = 42,
17701770 Bar,
17711771 @"with\\escape",
lib/std/macho.zig+5-5
......@@ -1314,13 +1314,13 @@ pub const BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: u8 = 0x40;
13141314pub const BIND_OPCODE_SET_TYPE_IMM: u8 = 0x50;
13151315pub const BIND_OPCODE_SET_ADDEND_SLEB: u8 = 0x60;
13161316pub const BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: u8 = 0x70;
1317pub const BIND_OPCODE_ADD_ADDR_ULEB: 0x80;
1317pub const BIND_OPCODE_ADD_ADDR_ULEB: u8 = 0x80;
13181318pub const BIND_OPCODE_DO_BIND: u8 = 0x90;
13191319pub const BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: u8 = 0xa0;
13201320pub const BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: u8 = 0xb0;
1321pub const BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: u8 = xc0;
1321pub const BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: u8 = 0xc0;
13221322
1323pub const reloc_type_x86_64 = packed enum(u4) {
1323pub const reloc_type_x86_64 = enum(u4) {
13241324 /// for absolute addresses
13251325 X86_64_RELOC_UNSIGNED = 0,
13261326
......@@ -1352,9 +1352,9 @@ pub const reloc_type_x86_64 = packed enum(u4) {
13521352 X86_64_RELOC_TLV,
13531353};
13541354
1355pub const reloc_type_arm64 = packed enum(u4) {
1355pub const reloc_type_arm64 = enum(u4) {
13561356 /// For pointers.
1357 ARM64_RELOC_UNSIGNED = 0,
1357 ARM64_RELOC_UNSIGNED,
13581358
13591359 /// Must be followed by a ARM64_RELOC_UNSIGNED.
13601360 ARM64_RELOC_SUBTRACTOR,
lib/std/mem.zig+1-1
......@@ -356,7 +356,7 @@ test "mem.zeroes" {
356356/// If the field is present in the provided initial values, it will have that value instead.
357357/// Structs are initialized recursively.
358358pub fn zeroInit(comptime T: type, init: anytype) T {
359 comptime const Init = @TypeOf(init);
359 const Init = @TypeOf(init);
360360
361361 switch (@typeInfo(T)) {
362362 .Struct => |struct_info| {
lib/std/meta.zig-4
......@@ -335,9 +335,6 @@ test "std.meta.containerLayout" {
335335 const E1 = enum {
336336 A,
337337 };
338 const E2 = packed enum {
339 A,
340 };
341338 const E3 = extern enum {
342339 A,
343340 };
......@@ -355,7 +352,6 @@ test "std.meta.containerLayout" {
355352 };
356353
357354 testing.expect(containerLayout(E1) == .Auto);
358 testing.expect(containerLayout(E2) == .Packed);
359355 testing.expect(containerLayout(E3) == .Extern);
360356 testing.expect(containerLayout(S1) == .Auto);
361357 testing.expect(containerLayout(S2) == .Packed);
lib/std/os/bits/darwin.zig+4-4
......@@ -1521,19 +1521,19 @@ pub const rusage = extern struct {
15211521 nivcsw: isize,
15221522};
15231523
1524pub const rlimit_resource = extern enum(c_int) {
1524pub const rlimit_resource = enum(c_int) {
15251525 CPU = 0,
15261526 FSIZE = 1,
15271527 DATA = 2,
15281528 STACK = 3,
15291529 CORE = 4,
1530 AS = 5,
15311530 RSS = 5,
15321531 MEMLOCK = 6,
15331532 NPROC = 7,
15341533 NOFILE = 8,
1535
15361534 _,
1535
1536 pub const AS: rlimit_resource = .RSS;
15371537};
15381538
15391539pub const rlim_t = u64;
......@@ -1669,7 +1669,7 @@ pub const TCSANOW = 0; // make change immediate
16691669pub const TCSADRAIN = 1; // drain output, then change
16701670pub const TCSAFLUSH = 2; // drain output, flush input
16711671pub const TCSASOFT = 0x10; // flag - don't alter h.w. state
1672pub const TCSA = extern enum(c_uint) {
1672pub const TCSA = enum(c_uint) {
16731673 NOW,
16741674 DRAIN,
16751675 FLUSH,
lib/std/os/bits/dragonfly.zig+3-3
......@@ -734,7 +734,7 @@ pub const Flock = extern struct {
734734 l_whence: c_short,
735735};
736736
737pub const rlimit_resource = extern enum(c_int) {
737pub const rlimit_resource = enum(c_int) {
738738 CPU = 0,
739739 FSIZE = 1,
740740 DATA = 2,
......@@ -745,11 +745,11 @@ pub const rlimit_resource = extern enum(c_int) {
745745 NPROC = 7,
746746 NOFILE = 8,
747747 SBSIZE = 9,
748 AS = 10,
749748 VMEM = 10,
750749 POSIXLOCKS = 11,
751
752750 _,
751
752 pub const AS: rlimit_resource = .VMEM;
753753};
754754
755755pub const rlim_t = i64;
lib/std/os/bits/freebsd.zig+3-3
......@@ -1459,7 +1459,7 @@ pub const IPPROTO_RESERVED_253 = 253;
14591459/// Reserved
14601460pub const IPPROTO_RESERVED_254 = 254;
14611461
1462pub const rlimit_resource = extern enum(c_int) {
1462pub const rlimit_resource = enum(c_int) {
14631463 CPU = 0,
14641464 FSIZE = 1,
14651465 DATA = 2,
......@@ -1471,13 +1471,13 @@ pub const rlimit_resource = extern enum(c_int) {
14711471 NOFILE = 8,
14721472 SBSIZE = 9,
14731473 VMEM = 10,
1474 AS = 10,
14751474 NPTS = 11,
14761475 SWAP = 12,
14771476 KQUEUES = 13,
14781477 UMTXP = 14,
1479
14801478 _,
1479
1480 pub const AS: rlimit_resource = .VMEM;
14811481};
14821482
14831483pub const rlim_t = i64;
lib/std/os/bits/haiku.zig+4-4
......@@ -1401,7 +1401,7 @@ pub const IPPROTO_RESERVED_253 = 253;
14011401/// Reserved
14021402pub const IPPROTO_RESERVED_254 = 254;
14031403
1404pub const rlimit_resource = extern enum(c_int) {
1404pub const rlimit_resource = enum(c_int) {
14051405 CPU = 0,
14061406 FSIZE = 1,
14071407 DATA = 2,
......@@ -1413,13 +1413,13 @@ pub const rlimit_resource = extern enum(c_int) {
14131413 NOFILE = 8,
14141414 SBSIZE = 9,
14151415 VMEM = 10,
1416 AS = 10,
14171416 NPTS = 11,
14181417 SWAP = 12,
14191418 KQUEUES = 13,
14201419 UMTXP = 14,
1421
14221420 _,
1421
1422 pub const AS: rlimit_resource = .VMEM;
14231423};
14241424
14251425pub const rlim_t = i64;
......@@ -1442,7 +1442,7 @@ pub const SHUT_WR = 1;
14421442pub const SHUT_RDWR = 2;
14431443
14441444// TODO fill out if needed
1445pub const directory_which = extern enum(c_int) {
1445pub const directory_which = enum(c_int) {
14461446 B_USER_SETTINGS_DIRECTORY = 0xbbe,
14471447
14481448 _,
lib/std/os/bits/linux.zig+8-8
......@@ -1487,7 +1487,7 @@ pub const io_uring_sqe = extern struct {
14871487 __pad2: [2]u64,
14881488};
14891489
1490pub const IOSQE_BIT = extern enum(u8) {
1490pub const IOSQE_BIT = enum(u8) {
14911491 FIXED_FILE,
14921492 IO_DRAIN,
14931493 IO_LINK,
......@@ -1518,7 +1518,7 @@ pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC);
15181518/// select buffer from buf_group
15191519pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT);
15201520
1521pub const IORING_OP = extern enum(u8) {
1521pub const IORING_OP = enum(u8) {
15221522 NOP,
15231523 READV,
15241524 WRITEV,
......@@ -1587,7 +1587,7 @@ pub const IORING_ENTER_GETEVENTS = 1 << 0;
15871587pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
15881588
15891589// io_uring_register opcodes and arguments
1590pub const IORING_REGISTER = extern enum(u8) {
1590pub const IORING_REGISTER = enum(u8) {
15911591 REGISTER_BUFFERS,
15921592 UNREGISTER_BUFFERS,
15931593 REGISTER_FILES,
......@@ -1654,7 +1654,7 @@ pub const io_uring_restriction = extern struct {
16541654};
16551655
16561656/// io_uring_restriction->opcode values
1657pub const IORING_RESTRICTION = extern enum(u8) {
1657pub const IORING_RESTRICTION = enum(u8) {
16581658 /// Allow an io_uring_register(2) opcode
16591659 REGISTER_OP = 0,
16601660
......@@ -1909,7 +1909,7 @@ pub const tcp_repair_window = extern struct {
19091909 rcv_wup: u32,
19101910};
19111911
1912pub const TcpRepairOption = extern enum {
1912pub const TcpRepairOption = enum {
19131913 TCP_NO_QUEUE,
19141914 TCP_RECV_QUEUE,
19151915 TCP_SEND_QUEUE,
......@@ -1917,7 +1917,7 @@ pub const TcpRepairOption = extern enum {
19171917};
19181918
19191919/// why fastopen failed from client perspective
1920pub const tcp_fastopen_client_fail = extern enum {
1920pub const tcp_fastopen_client_fail = enum {
19211921 /// catch-all
19221922 TFO_STATUS_UNSPEC,
19231923 /// if not in TFO_CLIENT_NO_COOKIE mode
......@@ -2184,7 +2184,7 @@ pub const NOFLSH = 128;
21842184pub const TOSTOP = 256;
21852185pub const IEXTEN = 32768;
21862186
2187pub const TCSA = extern enum(c_uint) {
2187pub const TCSA = enum(c_uint) {
21882188 NOW,
21892189 DRAIN,
21902190 FLUSH,
......@@ -2235,7 +2235,7 @@ pub const ifreq = extern struct {
22352235};
22362236
22372237// doc comments copied from musl
2238pub const rlimit_resource = extern enum(c_int) {
2238pub const rlimit_resource = enum(c_int) {
22392239 /// Per-process CPU limit, in seconds.
22402240 CPU,
22412241
lib/std/os/bits/linux/arm-eabi.zig+1-1
......@@ -15,7 +15,7 @@ const uid_t = linux.uid_t;
1515const gid_t = linux.gid_t;
1616const pid_t = linux.pid_t;
1717
18pub const SYS = extern enum(usize) {
18pub const SYS = enum(usize) {
1919 restart_syscall = 0,
2020 exit = 1,
2121 fork = 2,
lib/std/os/bits/linux/arm64.zig+1-1
......@@ -16,7 +16,7 @@ const gid_t = linux.gid_t;
1616const pid_t = linux.pid_t;
1717const stack_t = linux.stack_t;
1818const sigset_t = linux.sigset_t;
19pub const SYS = extern enum(usize) {
19pub const SYS = enum(usize) {
2020 io_setup = 0,
2121 io_destroy = 1,
2222 io_submit = 2,
lib/std/os/bits/linux/i386.zig+1-1
......@@ -17,7 +17,7 @@ const pid_t = linux.pid_t;
1717const stack_t = linux.stack_t;
1818const sigset_t = linux.sigset_t;
1919
20pub const SYS = extern enum(usize) {
20pub const SYS = enum(usize) {
2121 restart_syscall = 0,
2222 exit = 1,
2323 fork = 2,
lib/std/os/bits/linux/mips.zig+1-1
......@@ -12,7 +12,7 @@ const uid_t = linux.uid_t;
1212const gid_t = linux.gid_t;
1313const pid_t = linux.pid_t;
1414
15pub const SYS = extern enum(usize) {
15pub const SYS = enum(usize) {
1616 pub const Linux = 4000;
1717
1818 syscall = Linux + 0,
lib/std/os/bits/linux/netlink.zig+5-4
......@@ -126,7 +126,7 @@ pub const NLM_F_CAPPED = 0x100;
126126/// extended ACK TVLs were included
127127pub const NLM_F_ACK_TLVS = 0x200;
128128
129pub const NetlinkMessageType = extern enum(u16) {
129pub const NetlinkMessageType = enum(u16) {
130130 /// < 0x10: reserved control messages
131131 pub const MIN_TYPE = 0x10;
132132
......@@ -287,7 +287,7 @@ pub const rtattr = extern struct {
287287 pub const ALIGNTO = 4;
288288};
289289
290pub const IFLA = extern enum(c_ushort) {
290pub const IFLA = enum(c_ushort) {
291291 UNSPEC,
292292 ADDRESS,
293293 BROADCAST,
......@@ -351,8 +351,7 @@ pub const IFLA = extern enum(c_ushort) {
351351 EVENT,
352352
353353 NEW_NETNSID,
354 IF_NETNSID = 46,
355 TARGET_NETNSID = 46, // new alias
354 IF_NETNSID,
356355
357356 CARRIER_UP_COUNT,
358357 CARRIER_DOWN_COUNT,
......@@ -361,6 +360,8 @@ pub const IFLA = extern enum(c_ushort) {
361360 MAX_MTU,
362361
363362 _,
363
364 pub const TARGET_NETNSID: IFLA = .IF_NETNSID;
364365};
365366
366367pub const rtnl_link_ifmap = extern struct {
lib/std/os/bits/linux/powerpc.zig+1-1
......@@ -14,7 +14,7 @@ const gid_t = linux.gid_t;
1414const pid_t = linux.pid_t;
1515const stack_t = linux.stack_t;
1616const sigset_t = linux.sigset_t;
17pub const SYS = extern enum(usize) {
17pub const SYS = enum(usize) {
1818 restart_syscall = 0,
1919 exit = 1,
2020 fork = 2,
lib/std/os/bits/linux/powerpc64.zig+2-2
......@@ -14,7 +14,7 @@ const gid_t = linux.gid_t;
1414const pid_t = linux.pid_t;
1515const stack_t = linux.stack_t;
1616const sigset_t = linux.sigset_t;
17pub const SYS = extern enum(usize) {
17pub const SYS = enum(usize) {
1818 restart_syscall = 0,
1919 exit = 1,
2020 fork = 2,
......@@ -295,7 +295,7 @@ pub const SYS = extern enum(usize) {
295295 mknodat = 288,
296296 fchownat = 289,
297297 futimesat = 290,
298 newfstatat = 291,
298 fstatat = 291,
299299 unlinkat = 292,
300300 renameat = 293,
301301 linkat = 294,
lib/std/os/bits/linux/prctl.zig+1-1
......@@ -4,7 +4,7 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66
7pub const PR = extern enum(i32) {
7pub const PR = enum(i32) {
88 SET_PDEATHSIG = 1,
99 GET_PDEATHSIG = 2,
1010
lib/std/os/bits/linux/riscv64.zig+1-1
......@@ -9,7 +9,7 @@ const uid_t = std.os.linux.uid_t;
99const gid_t = std.os.linux.gid_t;
1010const pid_t = std.os.linux.pid_t;
1111
12pub const SYS = extern enum(usize) {
12pub const SYS = enum(usize) {
1313 pub const arch_specific_syscall = 244;
1414
1515 io_setup = 0,
lib/std/os/bits/linux/sparc64.zig+1-1
......@@ -12,7 +12,7 @@ const socklen_t = linux.socklen_t;
1212const iovec = linux.iovec;
1313const iovec_const = linux.iovec_const;
1414
15pub const SYS = extern enum(usize) {
15pub const SYS = enum(usize) {
1616 restart_syscall = 0,
1717 exit = 1,
1818 fork = 2,
lib/std/os/bits/linux/x86_64.zig+1-2
......@@ -21,7 +21,7 @@ const iovec_const = linux.iovec_const;
2121pub const mode_t = usize;
2222pub const time_t = isize;
2323
24pub const SYS = extern enum(usize) {
24pub const SYS = enum(usize) {
2525 read = 0,
2626 write = 1,
2727 open = 2,
......@@ -284,7 +284,6 @@ pub const SYS = extern enum(usize) {
284284 mknodat = 259,
285285 fchownat = 260,
286286 futimesat = 261,
287 newfstatat = 262,
288287 fstatat = 262,
289288 unlinkat = 263,
290289 renameat = 264,
lib/std/os/bits/netbsd.zig+4-4
......@@ -60,7 +60,7 @@ pub const addrinfo = extern struct {
6060 next: ?*addrinfo,
6161};
6262
63pub const EAI = extern enum(c_int) {
63pub const EAI = enum(c_int) {
6464 /// address family for hostname not supported
6565 ADDRFAMILY = 1,
6666
......@@ -1179,7 +1179,7 @@ pub const IPPROTO_PFSYNC = 240;
11791179/// raw IP packet
11801180pub const IPPROTO_RAW = 255;
11811181
1182pub const rlimit_resource = extern enum(c_int) {
1182pub const rlimit_resource = enum(c_int) {
11831183 CPU = 0,
11841184 FSIZE = 1,
11851185 DATA = 2,
......@@ -1190,11 +1190,11 @@ pub const rlimit_resource = extern enum(c_int) {
11901190 NPROC = 7,
11911191 NOFILE = 8,
11921192 SBSIZE = 9,
1193 AS = 10,
11941193 VMEM = 10,
11951194 NTHR = 11,
1196
11971195 _,
1196
1197 pub const AS: rlimit_resource = .VMEM;
11981198};
11991199
12001200pub const rlim_t = u64;
lib/std/os/bits/openbsd.zig+3-3
......@@ -76,7 +76,7 @@ pub const addrinfo = extern struct {
7676 next: ?*addrinfo,
7777};
7878
79pub const EAI = extern enum(c_int) {
79pub const EAI = enum(c_int) {
8080 /// address family for hostname not supported
8181 ADDRFAMILY = -9,
8282
......@@ -805,7 +805,7 @@ comptime {
805805 if (@sizeOf(usize) == 4)
806806 std.debug.assert(@sizeOf(siginfo_t) == 128)
807807 else
808 // Take into account the padding between errno and data fields.
808 // Take into account the padding between errno and data fields.
809809 std.debug.assert(@sizeOf(siginfo_t) == 136);
810810}
811811
......@@ -1177,7 +1177,7 @@ pub const IPPROTO_PFSYNC = 240;
11771177/// raw IP packet
11781178pub const IPPROTO_RAW = 255;
11791179
1180pub const rlimit_resource = extern enum(c_int) {
1180pub const rlimit_resource = enum(c_int) {
11811181 CPU,
11821182 FSIZE,
11831183 DATA,
lib/std/os/linux.zig-2
......@@ -1143,8 +1143,6 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
11431143pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *kernel_stat, flags: u32) usize {
11441144 if (@hasField(SYS, "fstatat64")) {
11451145 return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
1146 } else if (@hasField(SYS, "newfstatat")) {
1147 return syscall4(.newfstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
11481146 } else {
11491147 return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
11501148 }
lib/std/os/uefi/status.zig+1-1
......@@ -5,7 +5,7 @@
55// and substantial portions of the software.
66const high_bit = 1 << @typeInfo(usize).Int.bits - 1;
77
8pub const Status = extern enum(usize) {
8pub const Status = enum(usize) {
99 /// The operation completed successfully.
1010 Success = 0,
1111
lib/std/os/windows/bits.zig+3-3
......@@ -281,7 +281,7 @@ pub const IO_STATUS_BLOCK = extern struct {
281281 Information: ULONG_PTR,
282282};
283283
284pub const FILE_INFORMATION_CLASS = extern enum {
284pub const FILE_INFORMATION_CLASS = enum(c_int) {
285285 FileDirectoryInformation = 1,
286286 FileFullDirectoryInformation,
287287 FileBothDirectoryInformation,
......@@ -901,7 +901,7 @@ pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;
901901pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;
902902pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;
903903pub const COINIT_SPEED_OVER_MEMORY = COINIT.COINIT_SPEED_OVER_MEMORY;
904pub const COINIT = extern enum {
904pub const COINIT = enum(c_int) {
905905 COINIT_APARTMENTTHREADED = 2,
906906 COINIT_MULTITHREADED = 0,
907907 COINIT_DISABLE_OLE1DDE = 4,
......@@ -1623,7 +1623,7 @@ pub const SD_RECEIVE = 0;
16231623pub const SD_SEND = 1;
16241624pub const SD_BOTH = 2;
16251625
1626pub const OBJECT_INFORMATION_CLASS = extern enum {
1626pub const OBJECT_INFORMATION_CLASS = enum(c_int) {
16271627 ObjectBasicInformation = 0,
16281628 ObjectNameInformation = 1,
16291629 ObjectTypeInformation = 2,
lib/std/os/windows/ntstatus.zig+1-1
......@@ -4,7 +4,7 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66// NTSTATUS codes from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55?
7pub const NTSTATUS = extern enum(u32) {
7pub const NTSTATUS = enum(u32) {
88 /// The operation completed successfully.
99 SUCCESS = 0x00000000,
1010
lib/std/os/windows/win32error.zig+1-1
......@@ -4,7 +4,7 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66// Codes are from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d
7pub const Win32Error = extern enum(u16) {
7pub const Win32Error = enum(u16) {
88 /// The operation completed successfully.
99 SUCCESS = 0,
1010
lib/std/os/windows/ws2_32.zig+1-1
......@@ -256,7 +256,7 @@ pub const POLLHUP = 0x0002;
256256pub const POLLNVAL = 0x0004;
257257
258258// https://docs.microsoft.com/en-au/windows/win32/winsock/windows-sockets-error-codes-2
259pub const WinsockError = extern enum(u16) {
259pub const WinsockError = enum(u16) {
260260 /// Specified event object handle is invalid.
261261 /// An application attempts to use an event object, but the specified handle is not valid.
262262 WSA_INVALID_HANDLE = 6,
lib/std/pdb.zig+2-2
......@@ -115,7 +115,7 @@ pub const StreamType = enum(u16) {
115115
116116/// Duplicate copy of SymbolRecordKind, but using the official CV names. Useful
117117/// for reference purposes and when dealing with unknown record types.
118pub const SymbolKind = packed enum(u16) {
118pub const SymbolKind = enum(u16) {
119119 S_COMPILE = 1,
120120 S_REGISTER_16t = 2,
121121 S_CONSTANT_16t = 3,
......@@ -426,7 +426,7 @@ pub const FileChecksumEntryHeader = packed struct {
426426 ChecksumKind: u8,
427427};
428428
429pub const DebugSubsectionKind = packed enum(u32) {
429pub const DebugSubsectionKind = enum(u32) {
430430 None = 0,
431431 Symbols = 0xf1,
432432 Lines = 0xf2,
lib/std/valgrind.zig+4-4
......@@ -48,7 +48,7 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3:
4848 }
4949}
5050
51pub const ClientRequest = extern enum {
51pub const ClientRequest = enum(u32) {
5252 RunningOnValgrind = 4097,
5353 DiscardTranslations = 4098,
5454 ClientCall0 = 4353,
......@@ -156,9 +156,9 @@ pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void {
156156}
157157
158158/// Create a memory pool.
159pub const MempoolFlags = extern enum {
160 AutoFree = 1,
161 MetaPool = 2,
159pub const MempoolFlags = struct {
160 pub const AutoFree = 1;
161 pub const MetaPool = 2;
162162};
163163pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void {
164164 doClientRequestStmt(.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0);
lib/std/valgrind/callgrind.zig+1-1
......@@ -6,7 +6,7 @@
66const std = @import("../std.zig");
77const valgrind = std.valgrind;
88
9pub const CallgrindClientRequest = extern enum {
9pub const CallgrindClientRequest = enum(usize) {
1010 DumpStats = valgrind.ToolBase("CT"),
1111 ZeroStats,
1212 ToggleCollect,
lib/std/valgrind/memcheck.zig+2-2
......@@ -7,7 +7,7 @@ const std = @import("../std.zig");
77const testing = std.testing;
88const valgrind = std.valgrind;
99
10pub const MemCheckClientRequest = extern enum {
10pub const MemCheckClientRequest = enum(usize) {
1111 MakeMemNoAccess = valgrind.ToolBase("MC".*),
1212 MakeMemUndefined,
1313 MakeMemDefined,
......@@ -76,7 +76,7 @@ pub fn createBlock(qzz: []u8, desc: [*]u8) usize {
7676
7777/// Discard a block-description-handle. Returns 1 for an
7878/// invalid handle, 0 for a valid handle.
79pub fn discard(blkindex) bool {
79pub fn discard(blkindex: usize) bool {
8080 return doMemCheckClientRequestExpr(0, // default return
8181 .Discard, 0, blkindex, 0, 0, 0) != 0;
8282}
src/AstGen.zig+3-1
......@@ -2658,7 +2658,9 @@ fn fnDecl(
26582658 var i: usize = 0;
26592659 var it = fn_proto.iterate(tree.*);
26602660 while (it.next()) |param| : (i += 1) {
2661 const name_token = param.name_token.?;
2661 const name_token = param.name_token orelse {
2662 return astgen.failNode(param.type_expr, "missing parameter name", .{});
2663 };
26622664 const param_name = try astgen.identifierTokenString(name_token);
26632665 const sub_scope = try astgen.arena.create(Scope.LocalVal);
26642666 sub_scope.* = .{
src/Compilation.zig+1-1
......@@ -3220,7 +3220,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) Alloc
32203220 \\const std = @import("std");
32213221 \\/// Zig version. When writing code that supports multiple versions of Zig, prefer
32223222 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
3223 \\pub const zig_version = try std.SemanticVersion.parse("{s}");
3223 \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;
32243224 \\/// Temporary until self-hosted is feature complete.
32253225 \\pub const zig_is_stage2 = {};
32263226 \\/// Temporary until self-hosted supports the `cpu.arch` value.