@zigc/lib 0.17.0-dev.633 → 0.17.0-dev.657

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/compiler/Maker/PkgConfig.zig +1 -0
  2. package/compiler/Maker/ScannedConfig.zig +4 -3
  3. package/compiler/Maker/Step/Compile.zig +1 -3
  4. package/compiler/Maker/Step/FindProgram.zig +2 -2
  5. package/compiler/Maker/Step/Run.zig +18 -3
  6. package/compiler/Maker/Step/TranslateC.zig +5 -4
  7. package/compiler/Maker/Watch/FsEvents.zig +3 -2
  8. package/compiler/aro/aro/Attribute.zig +52 -51
  9. package/compiler/aro/aro/Compilation.zig +5 -5
  10. package/compiler/aro/aro/Diagnostics.zig +7 -7
  11. package/compiler/aro/aro/Parser.zig +2 -2
  12. package/compiler/aro/aro/Tree.zig +11 -11
  13. package/compiler/aro/aro/features.zig +4 -4
  14. package/compiler/aro/aro/text_literal.zig +2 -2
  15. package/compiler/aro/backend/Interner.zig +14 -13
  16. package/compiler/configurer.zig +2 -2
  17. package/compiler/resinator/bmp.zig +3 -2
  18. package/compiler/resinator/code_pages.zig +14 -12
  19. package/compiler/resinator/cvtres.zig +11 -10
  20. package/compiler/resinator/errors.zig +18 -22
  21. package/compiler/resinator/lang.zig +7 -7
  22. package/compiler/resinator/parse.zig +1 -1
  23. package/compiler/translate-c/ast.zig +6 -6
  24. package/docs/wasm/markdown/Document.zig +3 -3
  25. package/docs/wasm/markdown/Parser.zig +3 -3
  26. package/package.json +1 -1
  27. package/std/Build/Cache.zig +2 -2
  28. package/std/Build/Configuration.zig +88 -37
  29. package/std/Build/Step/ConfigHeader.zig +3 -2
  30. package/std/Build/Step/Options.zig +28 -22
  31. package/std/Build.zig +85 -56
  32. package/std/Io/Kqueue.zig +2 -2
  33. package/std/Io/Reader.zig +1 -1
  34. package/std/Io/Threaded.zig +18 -15
  35. package/std/Io/Uring.zig +4 -2
  36. package/std/Io/Writer.zig +18 -18
  37. package/std/Io/net.zig +3 -1
  38. package/std/Io.zig +7 -6
  39. package/std/Progress.zig +2 -2
  40. package/std/Target/aarch64.zig +2 -2
  41. package/std/Target/alpha.zig +2 -2
  42. package/std/Target/amdgcn.zig +2 -2
  43. package/std/Target/arc.zig +2 -2
  44. package/std/Target/arm.zig +2 -2
  45. package/std/Target/avr.zig +2 -2
  46. package/std/Target/bpf.zig +2 -2
  47. package/std/Target/csky.zig +2 -2
  48. package/std/Target/hexagon.zig +2 -2
  49. package/std/Target/hppa.zig +2 -2
  50. package/std/Target/kvx.zig +2 -2
  51. package/std/Target/lanai.zig +2 -2
  52. package/std/Target/loongarch.zig +2 -2
  53. package/std/Target/m68k.zig +2 -2
  54. package/std/Target/mips.zig +2 -2
  55. package/std/Target/msp430.zig +2 -2
  56. package/std/Target/nvptx.zig +2 -2
  57. package/std/Target/powerpc.zig +2 -2
  58. package/std/Target/propeller.zig +2 -2
  59. package/std/Target/riscv.zig +2 -2
  60. package/std/Target/s390x.zig +2 -2
  61. package/std/Target/sparc.zig +2 -2
  62. package/std/Target/spirv.zig +2 -2
  63. package/std/Target/ve.zig +2 -2
  64. package/std/Target/wasm.zig +2 -2
  65. package/std/Target/x86.zig +2 -2
  66. package/std/Target/xcore.zig +2 -2
  67. package/std/Target/xtensa.zig +2 -2
  68. package/std/Target.zig +4 -4
  69. package/std/c/darwin.zig +1 -1
  70. package/std/coff.zig +1 -1
  71. package/std/crypto/codecs/asn1/Oid.zig +8 -8
  72. package/std/crypto/codecs/asn1/der/Decoder.zig +7 -7
  73. package/std/crypto/codecs/asn1/der/Encoder.zig +10 -8
  74. package/std/crypto/phc_encoding.zig +23 -20
  75. package/std/crypto/timing_safe.zig +1 -1
  76. package/std/crypto/tls/Client.zig +3 -3
  77. package/std/crypto/tls.zig +1 -1
  78. package/std/debug/Dwarf/Unwind/VirtualMachine.zig +11 -5
  79. package/std/debug/ElfFile.zig +12 -8
  80. package/std/debug/MachOFile.zig +2 -2
  81. package/std/debug/SelfInfo/MachO.zig +2 -2
  82. package/std/debug/SelfInfo/Windows.zig +2 -2
  83. package/std/elf.zig +7 -7
  84. package/std/enums.zig +66 -67
  85. package/std/gpu.zig +1 -1
  86. package/std/hash/auto_hash.zig +8 -8
  87. package/std/hash/verify.zig +3 -3
  88. package/std/http/Client.zig +2 -2
  89. package/std/json/Stringify.zig +14 -14
  90. package/std/json/static.zig +47 -31
  91. package/std/lang.zig +65 -97
  92. package/std/math.zig +2 -2
  93. package/std/mem/Allocator.zig +9 -9
  94. package/std/mem.zig +86 -102
  95. package/std/meta/trailer_flags.zig +26 -19
  96. package/std/meta.zig +131 -171
  97. package/std/multi_array_list.zig +49 -57
  98. package/std/os/uefi/protocol/device_path.zig +8 -7
  99. package/std/os/uefi/tables/boot_services.zig +1 -1
  100. package/std/os/windows.zig +9 -15
  101. package/std/start.zig +6 -6
  102. package/std/testing/Smith.zig +35 -21
  103. package/std/testing.zig +15 -15
  104. package/std/zig/Ast.zig +4 -4
  105. package/std/zig/AstGen.zig +42 -42
  106. package/std/zig/ErrorBundle.zig +16 -13
  107. package/std/zig/LibCInstallation.zig +11 -11
  108. package/std/zig/Parse.zig +6 -6
  109. package/std/zig/Zir.zig +10 -10
  110. package/std/zig/c_translation/helpers.zig +2 -2
  111. package/std/zig/llvm/BitcodeReader.zig +3 -3
  112. package/std/zig/llvm/Builder.zig +124 -93
  113. package/std/zig/llvm/bitcode_writer.zig +4 -4
  114. package/std/zig/system/windows.zig +11 -11
  115. package/std/zig/system.zig +4 -4
  116. package/std/zig.zig +4 -4
  117. package/std/zon/Serializer.zig +28 -23
  118. package/std/zon/parse.zig +58 -61
@@ -44,17 +44,7 @@ pub fn MultiArrayList(comptime T: type) type {
44
44
  const Elem = switch (@typeInfo(T)) {
45
45
  .@"struct" => T,
46
46
  .@"union" => |u| struct {
47
- pub const Bare = Bare: {
48
- var field_names: [u.fields.len][]const u8 = undefined;
49
- var field_types: [u.fields.len]type = undefined;
50
- var field_attrs: [u.fields.len]std.builtin.Type.UnionField.Attributes = undefined;
51
- for (u.fields, &field_names, &field_types, &field_attrs) |field, *name, *Type, *attrs| {
52
- name.* = field.name;
53
- Type.* = field.type;
54
- attrs.* = .{ .@"align" = field.alignment };
55
- }
56
- break :Bare @Union(u.layout, null, &field_names, &field_types, &field_attrs);
57
- };
47
+ pub const Bare = @Union(u.layout, null, u.field_names, u.field_types[0..], u.field_attrs[0..]);
58
48
  pub const Tag =
59
49
  u.tag_type orelse @compileError("MultiArrayList does not support untagged unions");
60
50
  tags: Tag,
@@ -87,7 +77,7 @@ pub fn MultiArrayList(comptime T: type) type {
87
77
  pub const Slice = struct {
88
78
  /// This array is indexed by the field index which can be obtained
89
79
  /// by using @intFromEnum() on the Field enum
90
- ptrs: [fields.len][*]u8,
80
+ ptrs: [field_names.len][*]u8,
91
81
  len: usize,
92
82
  capacity: usize,
93
83
 
@@ -116,15 +106,15 @@ pub fn MultiArrayList(comptime T: type) type {
116
106
  .@"union" => Elem.fromT(elem),
117
107
  else => unreachable,
118
108
  };
119
- inline for (fields, 0..) |field_info, i| {
120
- self.items(@as(Field, @enumFromInt(i)))[index] = @field(e, field_info.name);
109
+ inline for (field_names, 0..) |field_name, i| {
110
+ self.items(@as(Field, @enumFromInt(i)))[index] = @field(e, field_name);
121
111
  }
122
112
  }
123
113
 
124
114
  pub fn get(self: Slice, index: usize) T {
125
115
  var result: Elem = undefined;
126
- inline for (fields, 0..) |field_info, i| {
127
- @field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index];
116
+ inline for (field_names, 0..) |field_name, i| {
117
+ @field(result, field_name) = self.items(@as(Field, @enumFromInt(i)))[index];
128
118
  }
129
119
  return switch (@typeInfo(T)) {
130
120
  .@"struct" => result,
@@ -134,9 +124,9 @@ pub fn MultiArrayList(comptime T: type) type {
134
124
  }
135
125
 
136
126
  pub fn swap(self: Slice, a: usize, b: usize) void {
137
- inline for (@typeInfo(Field).@"enum".fields) |field| {
138
- const its = self.items(@field(Field, field.name));
139
- std.mem.swap(@FieldType(T, field.name), &its[a], &its[b]);
127
+ inline for (@typeInfo(Field).@"enum".field_names) |field_name| {
128
+ const its = self.items(@field(Field, field_name));
129
+ std.mem.swap(@FieldType(T, field_name), &its[a], &its[b]);
140
130
  }
141
131
  }
142
132
 
@@ -162,9 +152,9 @@ pub fn MultiArrayList(comptime T: type) type {
162
152
  /// Asserts that `off + len <= s.len`.
163
153
  pub fn subslice(s: Slice, off: usize, len: usize) Slice {
164
154
  assert(off + len <= s.len);
165
- var ptrs: [fields.len][*]u8 = undefined;
166
- inline for (s.ptrs, &ptrs, fields) |in, *out, field| {
167
- out.* = in + (off * @sizeOf(field.type));
155
+ var ptrs: [field_names.len][*]u8 = undefined;
156
+ inline for (s.ptrs, &ptrs, field_types) |in, *out, field_type| {
157
+ out.* = in + (off * @sizeOf(field_type));
168
158
  }
169
159
  return .{
170
160
  .ptrs = ptrs,
@@ -185,7 +175,9 @@ pub fn MultiArrayList(comptime T: type) type {
185
175
 
186
176
  const Self = @This();
187
177
 
188
- const fields = meta.fields(Elem);
178
+ const field_names = @typeInfo(Elem).@"struct".field_names;
179
+ const field_types = @typeInfo(Elem).@"struct".field_types;
180
+ const field_attrs = @typeInfo(Elem).@"struct".field_attrs;
189
181
  /// `sizes.bytes` is an array of @sizeOf each T field. Sorted by alignment, descending.
190
182
  /// `sizes.fields` is an array mapping from `sizes.bytes` array index to field index.
191
183
  /// `sizes.big_align` is the overall alignment of the allocation, which equals the maximum field alignment.
@@ -195,13 +187,13 @@ pub fn MultiArrayList(comptime T: type) type {
195
187
  size_index: usize,
196
188
  alignment: usize,
197
189
  };
198
- var data: [fields.len]Data = undefined;
190
+ var data: [field_names.len]Data = undefined;
199
191
  var big_align: usize = 1;
200
- for (fields, 0..) |field_info, i| {
192
+ for (field_types, field_attrs, 0..) |f_type, f_attrs, i| {
201
193
  data[i] = .{
202
- .size = @sizeOf(field_info.type),
194
+ .size = @sizeOf(f_type),
203
195
  .size_index = i,
204
- .alignment = field_info.alignment orelse @alignOf(field_info.type),
196
+ .alignment = f_attrs.@"align" orelse @alignOf(f_type),
205
197
  };
206
198
  big_align = @max(big_align, data[i].alignment);
207
199
  }
@@ -211,10 +203,10 @@ pub fn MultiArrayList(comptime T: type) type {
211
203
  return lhs.alignment > rhs.alignment;
212
204
  }
213
205
  };
214
- @setEvalBranchQuota(3 * fields.len * std.math.log2(fields.len));
206
+ @setEvalBranchQuota(3 * field_names.len * std.math.log2(field_names.len));
215
207
  mem.sort(Data, &data, {}, Sort.lessThan);
216
- var sizes_bytes: [fields.len]usize = undefined;
217
- var field_indexes: [fields.len]usize = undefined;
208
+ var sizes_bytes: [field_names.len]usize = undefined;
209
+ var field_indexes: [field_names.len]usize = undefined;
218
210
  for (data, 0..) |elem, i| {
219
211
  sizes_bytes[i] = elem.size;
220
212
  field_indexes[i] = elem.size_index;
@@ -368,13 +360,13 @@ pub fn MultiArrayList(comptime T: type) type {
368
360
  else => unreachable,
369
361
  };
370
362
  const slices = self.slice();
371
- inline for (fields, 0..) |field_info, field_index| {
363
+ inline for (field_names, 0..) |field_name, field_index| {
372
364
  const field_slice = slices.items(@as(Field, @enumFromInt(field_index)));
373
365
  var i: usize = self.len - 1;
374
366
  while (i > index) : (i -= 1) {
375
367
  field_slice[i] = field_slice[i - 1];
376
368
  }
377
- field_slice[index] = @field(entry, field_info.name);
369
+ field_slice[index] = @field(entry, field_name);
378
370
  }
379
371
  }
380
372
 
@@ -394,7 +386,7 @@ pub fn MultiArrayList(comptime T: type) type {
394
386
  /// retain list ordering.
395
387
  pub fn swapRemove(self: *Self, index: usize) void {
396
388
  const slices = self.slice();
397
- inline for (fields, 0..) |_, i| {
389
+ inline for (field_names, 0..) |_, i| {
398
390
  const field_slice = slices.items(@as(Field, @enumFromInt(i)));
399
391
  field_slice[index] = field_slice[self.len - 1];
400
392
  field_slice[self.len - 1] = undefined;
@@ -406,7 +398,7 @@ pub fn MultiArrayList(comptime T: type) type {
406
398
  /// after it to preserve order.
407
399
  pub fn orderedRemove(self: *Self, index: usize) void {
408
400
  const slices = self.slice();
409
- inline for (fields, 0..) |_, field_index| {
401
+ inline for (field_names, 0..) |_, field_index| {
410
402
  const field_slice = slices.items(@as(Field, @enumFromInt(field_index)));
411
403
  var i = index;
412
404
  while (i < self.len - 1) : (i += 1) {
@@ -437,7 +429,7 @@ pub fn MultiArrayList(comptime T: type) type {
437
429
  if (removed == end) continue; // allows duplicates in `sorted_indexes`
438
430
  const start = removed + 1;
439
431
  const len = end - start; // safety checks `sorted_indexes` are sorted
440
- inline for (fields, 0..) |_, field_index| {
432
+ inline for (field_names, 0..) |_, field_index| {
441
433
  const field_slice = slices.items(@enumFromInt(field_index));
442
434
  @memmove(field_slice[start - shift ..][0..len], field_slice[start..][0..len]); // safety checks initial `sorted_indexes` are in range
443
435
  }
@@ -446,7 +438,7 @@ pub fn MultiArrayList(comptime T: type) type {
446
438
  const start = sorted_indexes[sorted_indexes.len - 1] + 1;
447
439
  const end = self.len;
448
440
  const len = end - start; // safety checks final `sorted_indexes` are in range
449
- inline for (fields, 0..) |_, field_index| {
441
+ inline for (field_names, 0..) |_, field_index| {
450
442
  const field_slice = slices.items(@enumFromInt(field_index));
451
443
  @memmove(field_slice[start - shift ..][0..len], field_slice[start..][0..len]);
452
444
  }
@@ -471,8 +463,8 @@ pub fn MultiArrayList(comptime T: type) type {
471
463
 
472
464
  const other_bytes = gpa.alignedAlloc(u8, sizes.big_align, capacityInBytes(new_len)) catch {
473
465
  const self_slice = self.slice();
474
- inline for (fields, 0..) |field_info, i| {
475
- if (@sizeOf(field_info.type) != 0) {
466
+ inline for (field_types, 0..) |field_type, i| {
467
+ if (@sizeOf(field_type) != 0) {
476
468
  const field = @as(Field, @enumFromInt(i));
477
469
  const dest_slice = self_slice.items(field)[new_len..];
478
470
  // We use memset here for more efficient codegen in safety-checked,
@@ -492,8 +484,8 @@ pub fn MultiArrayList(comptime T: type) type {
492
484
  self.len = new_len;
493
485
  const self_slice = self.slice();
494
486
  const other_slice = other.slice();
495
- inline for (fields, 0..) |field_info, i| {
496
- if (@sizeOf(field_info.type) != 0) {
487
+ inline for (field_types, 0..) |field_type, i| {
488
+ if (@sizeOf(field_type) != 0) {
497
489
  const field = @as(Field, @enumFromInt(i));
498
490
  @memcpy(other_slice.items(field), self_slice.items(field));
499
491
  }
@@ -529,7 +521,7 @@ pub fn MultiArrayList(comptime T: type) type {
529
521
 
530
522
  const init_capacity: comptime_int = init: {
531
523
  var max: comptime_int = 1;
532
- for (fields) |field| max = @max(max, @sizeOf(field.type));
524
+ for (field_types) |field_type| max = @max(max, @sizeOf(field_type));
533
525
  break :init @max(1, std.atomic.cache_line / max);
534
526
  };
535
527
 
@@ -564,8 +556,8 @@ pub fn MultiArrayList(comptime T: type) type {
564
556
  };
565
557
  const self_slice = self.slice();
566
558
  const other_slice = other.slice();
567
- inline for (fields, 0..) |field_info, i| {
568
- if (@sizeOf(field_info.type) != 0) {
559
+ inline for (field_types, 0..) |field_type, i| {
560
+ if (@sizeOf(field_type) != 0) {
569
561
  const field = @as(Field, @enumFromInt(i));
570
562
  @memcpy(other_slice.items(field), self_slice.items(field));
571
563
  }
@@ -583,8 +575,8 @@ pub fn MultiArrayList(comptime T: type) type {
583
575
  result.len = self.len;
584
576
  const self_slice = self.slice();
585
577
  const result_slice = result.slice();
586
- inline for (fields, 0..) |field_info, i| {
587
- if (@sizeOf(field_info.type) != 0) {
578
+ inline for (field_types, 0..) |field_type, i| {
579
+ if (@sizeOf(field_type) != 0) {
588
580
  const field = @as(Field, @enumFromInt(i));
589
581
  @memcpy(result_slice.items(field), self_slice.items(field));
590
582
  }
@@ -600,11 +592,11 @@ pub fn MultiArrayList(comptime T: type) type {
600
592
  slice: Slice,
601
593
 
602
594
  pub fn swap(sc: @This(), a_index: usize, b_index: usize) void {
603
- inline for (fields, 0..) |field_info, i| {
604
- if (@sizeOf(field_info.type) != 0) {
595
+ inline for (field_types, 0..) |field_type, i| {
596
+ if (@sizeOf(field_type) != 0) {
605
597
  const field: Field = @enumFromInt(i);
606
598
  const ptr = sc.slice.items(field);
607
- mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]);
599
+ mem.swap(field_type, &ptr[a_index], &ptr[b_index]);
608
600
  }
609
601
  }
610
602
  }
@@ -676,18 +668,18 @@ pub fn MultiArrayList(comptime T: type) type {
676
668
  }
677
669
 
678
670
  const Entry = entry: {
679
- var field_names: [fields.len][]const u8 = undefined;
680
- var field_types: [fields.len]type = undefined;
681
- var field_attrs: [fields.len]std.builtin.Type.StructField.Attributes = undefined;
682
- for (sizes.fields, &field_names, &field_types, &field_attrs) |i, *name, *Type, *attrs| {
683
- name.* = fields[i].name ++ "_ptr";
684
- Type.* = *fields[i].type;
671
+ var entry_field_names: [field_names.len][]const u8 = undefined;
672
+ var entry_field_types: [field_names.len]type = undefined;
673
+ var entry_field_attrs: [field_names.len]std.builtin.Type.Struct.FieldAttributes = undefined;
674
+ for (sizes.fields, &entry_field_names, &entry_field_types, &entry_field_attrs) |i, *name, *Type, *attrs| {
675
+ name.* = field_names[i] ++ "_ptr";
676
+ Type.* = *field_types[i];
685
677
  attrs.* = .{
686
- .@"comptime" = fields[i].is_comptime,
687
- .@"align" = fields[i].alignment,
678
+ .@"comptime" = field_attrs[i].@"comptime",
679
+ .@"align" = field_attrs[i].@"align",
688
680
  };
689
681
  }
690
- break :entry @Struct(.@"extern", null, &field_names, &field_types, &field_attrs);
682
+ break :entry @Struct(.@"extern", null, &entry_field_names, &entry_field_types, &entry_field_attrs);
691
683
  };
692
684
  /// This function is used in the debugger pretty formatters in tools/ to fetch the
693
685
  /// child field order and entry type to facilitate fancy debug printing for this type.
@@ -82,16 +82,17 @@ pub const DevicePath = extern struct {
82
82
  }
83
83
 
84
84
  pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
85
- inline for (@typeInfo(uefi.DevicePath).@"union".fields) |ufield| {
86
- const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name);
85
+ const u_info = @typeInfo(uefi.DevicePath).@"union";
86
+ inline for (u_info.field_names, u_info.field_types) |ufield_name, ufield_type| {
87
+ const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield_name);
87
88
 
88
89
  // Got the associated union type for self.type, now
89
90
  // we need to initialize it and its subtype
90
91
  if (self.type == enum_value) {
91
- const subtype = self.initSubtype(ufield.type);
92
+ const subtype = self.initSubtype(ufield_type);
92
93
  if (subtype) |sb| {
93
94
  // e.g. return .{ .hardware = .{ .pci = @ptrCast(...) } }
94
- return @unionInit(uefi.DevicePath, ufield.name, sb);
95
+ return @unionInit(uefi.DevicePath, ufield_name, sb);
95
96
  }
96
97
  }
97
98
  }
@@ -103,13 +104,13 @@ pub const DevicePath = extern struct {
103
104
  const type_info = @typeInfo(TUnion).@"union";
104
105
  const TTag = type_info.tag_type.?;
105
106
 
106
- inline for (type_info.fields) |subtype| {
107
+ inline for (type_info.field_names, type_info.field_types) |subtype_name, subtype_type| {
107
108
  // The tag names match the union names, so just grab that off the enum
108
- const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name));
109
+ const tag_val: u8 = @intFromEnum(@field(TTag, subtype_name));
109
110
 
110
111
  if (self.subtype == tag_val) {
111
112
  // e.g. expr = .{ .pci = @ptrCast(...) }
112
- return @unionInit(TUnion, subtype.name, @as(subtype.type, @ptrCast(self)));
113
+ return @unionInit(TUnion, subtype_name, @as(subtype_type, @ptrCast(self)));
113
114
  }
114
115
  }
115
116
 
@@ -1271,7 +1271,7 @@ fn ProtocolInterfaces(HandleType: type, Interfaces: type) type {
1271
1271
  @compileError("expected tuple of protocol interfaces, got " ++ @typeName(Interfaces));
1272
1272
  const interfaces_info = interfaces_type_info.@"struct";
1273
1273
 
1274
- var tuple_types: [interfaces_info.fields.len * 2 + 2]type = undefined;
1274
+ var tuple_types: [interfaces_info.field_names.len * 2 + 2]type = undefined;
1275
1275
  tuple_types[0] = HandleType;
1276
1276
  tuple_types[tuple_types.len - 1] = ?*const Guid;
1277
1277
 
@@ -144,7 +144,7 @@ pub const OBJECT = struct {
144
144
  Session = 5,
145
145
  _,
146
146
 
147
- pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".fields.len;
147
+ pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".field_names.len;
148
148
  };
149
149
 
150
150
  pub const NAME_INFORMATION = extern struct {
@@ -575,7 +575,7 @@ pub const FILE = struct {
575
575
  MupProvider = 83,
576
576
  _,
577
577
 
578
- pub const Maximum: @typeInfo(@This()).@"enum".tag_type = 1 + @typeInfo(@This()).@"enum".fields.len;
578
+ pub const Maximum: @typeInfo(@This()).@"enum".tag_type = 1 + @typeInfo(@This()).@"enum".field_names.len;
579
579
  };
580
580
 
581
581
  pub const BASIC_INFORMATION = extern struct {
@@ -881,7 +881,7 @@ pub const DIRECTORY = struct {
881
881
  NotifyFull = 3,
882
882
  _,
883
883
 
884
- pub const Maximum: @typeInfo(@This()).@"enum".tag_type = 1 + @typeInfo(@This()).@"enum".fields.len;
884
+ pub const Maximum: @typeInfo(@This()).@"enum".tag_type = 1 + @typeInfo(@This()).@"enum".field_names.len;
885
885
  };
886
886
  };
887
887
 
@@ -930,14 +930,8 @@ pub const CONSOLE = struct {
930
930
 
931
931
  pub const Tag = @typeInfo(WITH).@"union".tag_type.?;
932
932
  pub const Payload = PAYLOAD: {
933
- const with_fields = @typeInfo(WITH).@"union".fields;
934
- var field_names: [with_fields.len][]const u8 = undefined;
935
- var field_types: [with_fields.len]type = undefined;
936
- for (with_fields, &field_names, &field_types) |field, *field_name, *field_type| {
937
- field_name.* = field.name;
938
- field_type.* = field.type;
939
- }
940
- break :PAYLOAD @Union(.@"extern", null, &field_names, &field_types, &@splat(.{}));
933
+ const with_info = @typeInfo(WITH).@"union";
934
+ break :PAYLOAD @Union(.@"extern", null, with_info.field_names, with_info.field_types[0..], &@splat(.{}));
941
935
  };
942
936
  };
943
937
  };
@@ -2122,7 +2116,7 @@ pub const HEAP = opaque {
2122
2116
  Custom,
2123
2117
  _,
2124
2118
 
2125
- pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".fields.len;
2119
+ pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".field_names.len;
2126
2120
  };
2127
2121
 
2128
2122
  pub const VA_CALLBACKS = extern struct {
@@ -3369,7 +3363,7 @@ pub const FS_INFORMATION_CLASS = enum(c_int) {
3369
3363
  Guid = 15,
3370
3364
  _,
3371
3365
 
3372
- pub const Maximum: @typeInfo(@This()).@"enum".tag_type = 1 + @typeInfo(@This()).@"enum".fields.len;
3366
+ pub const Maximum: @typeInfo(@This()).@"enum".tag_type = 1 + @typeInfo(@This()).@"enum".field_names.len;
3373
3367
  };
3374
3368
 
3375
3369
  pub const SECTION_INHERIT = enum(c_int) {
@@ -3493,7 +3487,7 @@ pub const MEM = struct {
3493
3487
  ImageMachine,
3494
3488
  _,
3495
3489
 
3496
- pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".fields.len;
3490
+ pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".field_names.len;
3497
3491
  };
3498
3492
  };
3499
3493
  };
@@ -4467,7 +4461,7 @@ pub const KEY = struct {
4467
4461
  Layer = 5,
4468
4462
  _,
4469
4463
 
4470
- pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".fields.len;
4464
+ pub const Max: @typeInfo(@This()).@"enum".tag_type = @typeInfo(@This()).@"enum".field_names.len;
4471
4465
  };
4472
4466
 
4473
4467
  pub const PARTIAL_INFORMATION = extern struct {
package/std/start.zig CHANGED
@@ -24,7 +24,7 @@ comptime {
24
24
  if (native_os == .windows and !builtin.link_libc and !@hasDecl(root, dll_main_crt_startup)) {
25
25
  @export(&DllMainCRTStartup, .{ .name = dll_main_crt_startup });
26
26
  } else if (native_os == .windows and builtin.link_libc and @hasDecl(root, "DllMain")) {
27
- if (!@typeInfo(@TypeOf(root.DllMain)).@"fn".calling_convention.eql(.winapi)) {
27
+ if (!@typeInfo(@TypeOf(root.DllMain)).@"fn".attrs.@"callconv".eql(.winapi)) {
28
28
  @export(&DllMain, .{ .name = "DllMain" });
29
29
  }
30
30
  }
@@ -32,11 +32,11 @@ comptime {
32
32
  if (builtin.link_libc and @hasDecl(root, "main")) {
33
33
  if (is_wasm) {
34
34
  @export(&mainWithoutEnv, .{ .name = "__main_argc_argv" });
35
- } else if (!@typeInfo(@TypeOf(root.main)).@"fn".calling_convention.eql(.c)) {
35
+ } else if (!@typeInfo(@TypeOf(root.main)).@"fn".attrs.@"callconv".eql(.c)) {
36
36
  @export(&main, .{ .name = "main" });
37
37
  }
38
38
  } else if (native_os == .windows and builtin.link_libc and @hasDecl(root, "wWinMain")) {
39
- if (!@typeInfo(@TypeOf(root.wWinMain)).@"fn".calling_convention.eql(.c)) {
39
+ if (!@typeInfo(@TypeOf(root.wWinMain)).@"fn".attrs.@"callconv".eql(.c)) {
40
40
  @export(&wWinMain, .{ .name = "wWinMain" });
41
41
  }
42
42
  } else if (native_os == .windows) {
@@ -728,8 +728,8 @@ var safe_allocator: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{})
728
728
 
729
729
  inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.Block) u8 {
730
730
  const fn_info = @typeInfo(@TypeOf(root.main)).@"fn";
731
- if (fn_info.params.len == 0) return wrapMain(root.main());
732
- if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{
731
+ if (fn_info.param_types.len == 0) return wrapMain(root.main());
732
+ if (fn_info.param_types[0].? == std.process.Init.Minimal) return wrapMain(root.main(.{
733
733
  .args = .{ .vector = args },
734
734
  .environ = .{ .block = environ },
735
735
  }));
@@ -809,7 +809,7 @@ inline fn wrapMain(result: anytype) u8 {
809
809
 
810
810
  fn call_wWinMain() std.os.windows.INT {
811
811
  const peb = std.os.windows.peb();
812
- const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).@"fn".params[0].type.?;
812
+ const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).@"fn".param_types[0].?;
813
813
  const hInstance: MAIN_HINSTANCE = @ptrCast(peb.ImageBaseAddress);
814
814
  const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer);
815
815
 
@@ -35,7 +35,12 @@ fn fromExcessK(T: type, x: Backing(T)) T {
35
35
  return @as(T, @bitCast(x)) +% std.math.minInt(T);
36
36
  }
37
37
 
38
- fn enumFieldLessThan(_: void, a: std.builtin.Type.EnumField, b: std.builtin.Type.EnumField) bool {
38
+ const EnumField = struct {
39
+ name: [:0]const u8,
40
+ value: comptime_int,
41
+ };
42
+
43
+ fn enumFieldLessThan(_: void, a: EnumField, b: EnumField) bool {
39
44
  return a.value < b.value;
40
45
  }
41
46
 
@@ -67,17 +72,26 @@ pub inline fn baselineWeights(T: type) []const Weight {
67
72
  baselineWeights(Backing(T))
68
73
  else
69
74
  @compileError("non-packed unions cannot be weighted"),
70
- .@"enum" => |e| if (!e.is_exhaustive)
75
+ .@"enum" => |e| if (e.mode == .nonexhaustive)
71
76
  baselineWeights(e.tag_type)
72
- else if (e.fields.len == 0)
77
+ else if (e.field_names.len == 0)
73
78
  // Cannot be included in below branch due to `log2_int_ceil`
74
79
  @compileError("exhaustive zero-field enums cannot be weighted")
75
80
  else e: {
76
- @setEvalBranchQuota(@intCast(4 * e.fields.len *
77
- std.math.log2_int_ceil(usize, e.fields.len)));
78
-
79
- var sorted_fields = e.fields[0..e.fields.len].*;
80
- std.mem.sortUnstable(std.builtin.Type.EnumField, &sorted_fields, {}, enumFieldLessThan);
81
+ @setEvalBranchQuota(@intCast(4 * e.field_names.len *
82
+ std.math.log2_int_ceil(usize, e.field_names.len)));
83
+
84
+ var sorted_fields = blk: {
85
+ var fields: [e.field_names.len]EnumField = undefined;
86
+ for (e.field_names, e.field_values, &fields) |f_name, f_value, *field| {
87
+ field.* = .{
88
+ .name = f_name,
89
+ .value = f_value,
90
+ };
91
+ }
92
+ break :blk fields;
93
+ };
94
+ std.mem.sortUnstable(EnumField, &sorted_fields, {}, enumFieldLessThan);
81
95
 
82
96
  var weights: []const Weight = &.{};
83
97
  var seq_first: u64 = sorted_fields[0].value;
@@ -316,10 +330,10 @@ fn weightsContain(int: u64, weights: []const Weight) bool {
316
330
  inline fn allBitPatternsValid(T: type) bool {
317
331
  return comptime switch (@typeInfo(T)) {
318
332
  .void, .bool, .int, .float => true,
319
- inline .@"struct", .@"union" => |c| c.layout == .@"packed" and for (c.fields) |f| {
320
- if (!allBitPatternsValid(f.type)) break false;
333
+ inline .@"struct", .@"union" => |c| c.layout == .@"packed" and for (c.field_types) |f_type| {
334
+ if (!allBitPatternsValid(f_type)) break false;
321
335
  } else true,
322
- .@"enum" => |e| !e.is_exhaustive,
336
+ .@"enum" => |e| e.mode == .nonexhaustive,
323
337
  else => unreachable,
324
338
  };
325
339
  }
@@ -346,16 +360,16 @@ fn UnionTagWithoutUninitializable(T: type) type {
346
360
  const u = @typeInfo(T).@"union";
347
361
  const Tag = u.tag_type orelse @compileError("union must have tag");
348
362
  const e = @typeInfo(Tag).@"enum";
349
- var field_names: [e.fields.len][]const u8 = undefined;
350
- var field_values: [e.fields.len]e.tag_type = undefined;
363
+ var field_names: [e.field_names.len][]const u8 = undefined;
364
+ var field_values: [e.field_names.len]e.tag_type = undefined;
351
365
  var n_fields = 0;
352
- for (u.fields) |f| {
353
- switch (f.type) {
366
+ for (u.field_names, u.field_types) |f_name, f_type| {
367
+ switch (f_type) {
354
368
  noreturn => continue,
355
369
  else => {},
356
370
  }
357
- field_names[n_fields] = f.name;
358
- field_values[n_fields] = @intFromEnum(@field(Tag, f.name));
371
+ field_names[n_fields] = f_name;
372
+ field_values[n_fields] = @intFromEnum(@field(Tag, f_name));
359
373
  n_fields += 1;
360
374
  }
361
375
  return @Enum(e.tag_type, .exhaustive, field_names[0..n_fields], field_values[0..n_fields]);
@@ -381,12 +395,12 @@ pub fn valueWithHash(s: *Smith, T: type, hash: u32) T {
381
395
  }
382
396
  break :full @bitCast(int);
383
397
  },
384
- .@"enum" => |e| if (e.is_exhaustive) v: {
398
+ .@"enum" => |e| if (e.mode == .exhaustive) v: {
385
399
  if (@bitSizeOf(e.tag_type) <= 64) {
386
400
  break :v s.valueWeightedWithHash(T, baselineWeights(T), hash);
387
401
  }
388
402
  break :v std.enums.fromInt(T, s.valueWithHash(e.tag_type, hash)) orelse
389
- @enumFromInt(e.fields[0].value);
403
+ @enumFromInt(e.field_values[0]);
390
404
  } else @enumFromInt(s.valueWithHash(e.tag_type, hash)),
391
405
  .optional => |o| if (s.valueWithHash(bool, hash))
392
406
  null
@@ -406,11 +420,11 @@ pub fn valueWithHash(s: *Smith, T: type, hash: u32) T {
406
420
  .@"struct" => |st| if (!allBitPatternsValid(T)) v: {
407
421
  var v: T = undefined;
408
422
  var rhash = hash;
409
- inline for (st.fields) |f| {
423
+ inline for (st.field_names, st.field_types) |f_name, f_type| {
410
424
  // rhash is incremented in the call so our rhash state is not reused (e.g. with
411
425
  // two nested structs. note that xor cannot work for this case as the bit would
412
426
  // be flipped back here)
413
- @field(v, f.name) = s.valueWithHash(f.type, rhash +% 1);
427
+ @field(v, f_name) = s.valueWithHash(f_type, rhash +% 1);
414
428
  rhash = std.hash.int(rhash);
415
429
  }
416
430
  break :v v;
package/std/testing.zig CHANGED
@@ -141,16 +141,16 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
141
141
  },
142
142
 
143
143
  .@"struct" => |structType| {
144
- inline for (structType.fields) |field| {
145
- try expectEqual(@field(expected, field.name), @field(actual, field.name));
144
+ inline for (structType.field_names) |field_name| {
145
+ try expectEqual(@field(expected, field_name), @field(actual, field_name));
146
146
  }
147
147
  },
148
148
 
149
149
  .@"union" => |union_info| {
150
150
  if (union_info.tag_type == null) {
151
- const first_size = @bitSizeOf(union_info.fields[0].type);
152
- inline for (union_info.fields) |field| {
153
- if (@bitSizeOf(field.type) != first_size) {
151
+ const first_size = @bitSizeOf(union_info.field_types[0]);
152
+ inline for (union_info.field_types) |field_type| {
153
+ if (@bitSizeOf(field_type) != first_size) {
154
154
  @compileError("Unable to compare untagged unions with varying field sizes for type " ++ @typeName(@TypeOf(actual)));
155
155
  }
156
156
  }
@@ -840,9 +840,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
840
840
  },
841
841
 
842
842
  .@"struct" => |structType| {
843
- inline for (structType.fields) |field| {
844
- expectEqualDeep(@field(expected, field.name), @field(actual, field.name)) catch |e| {
845
- print("Field {s} incorrect. expected {any}, found {any}\n", .{ field.name, @field(expected, field.name), @field(actual, field.name) });
843
+ inline for (structType.field_names) |field_name| {
844
+ expectEqualDeep(@field(expected, field_name), @field(actual, field_name)) catch |e| {
845
+ print("Field {s} incorrect. expected {any}, found {any}\n", .{ field_name, @field(expected, field_name), @field(actual, field_name) });
846
846
  return e;
847
847
  };
848
848
  }
@@ -1165,14 +1165,14 @@ fn CheckAllAllocationFailuresExtraArgs(comptime TestFn: type) type {
1165
1165
 
1166
1166
  const ArgsTuple = std.meta.ArgsTuple(TestFn);
1167
1167
 
1168
- const fields = @typeInfo(ArgsTuple).@"struct".fields;
1169
- if (fields.len == 0 or fields[0].type != std.mem.Allocator) {
1168
+ const field_types = @typeInfo(ArgsTuple).@"struct".field_types;
1169
+ if (field_types.len == 0 or field_types[0] != std.mem.Allocator) {
1170
1170
  @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");
1171
1171
  }
1172
1172
 
1173
- var extra_args: [fields.len - 1]type = undefined;
1174
- for (&extra_args, fields[1..]) |*arg, field| {
1175
- arg.* = field.type;
1173
+ var extra_args: [field_types.len - 1]type = undefined;
1174
+ for (&extra_args, field_types[1..]) |*arg, field_type| {
1175
+ arg.* = field_type;
1176
1176
  }
1177
1177
 
1178
1178
  return @Tuple(&extra_args);
@@ -1204,8 +1204,8 @@ test "checkAllAllocationFailures provide result type to 'extra_args' argument" {
1204
1204
  /// Given a type, references all the declarations inside, so that the semantic analyzer sees them.
1205
1205
  pub fn refAllDecls(comptime T: type) void {
1206
1206
  if (!builtin.is_test) return;
1207
- inline for (comptime std.meta.declarations(T)) |decl| {
1208
- _ = &@field(T, decl.name);
1207
+ inline for (comptime std.meta.declarations(T)) |decl_name| {
1208
+ _ = &@field(T, decl_name);
1209
1209
  }
1210
1210
  }
1211
1211
 
package/std/zig/Ast.zig CHANGED
@@ -298,17 +298,17 @@ pub fn extraDataSliceWithLen(tree: Ast, start: ExtraIndex, len: u32, comptime T:
298
298
  }
299
299
 
300
300
  pub fn extraData(tree: Ast, index: ExtraIndex, comptime T: type) T {
301
- const fields = std.meta.fields(T);
301
+ const info = @typeInfo(T).@"struct";
302
302
  var result: T = undefined;
303
- inline for (fields, 0..) |field, i| {
304
- @field(result, field.name) = switch (field.type) {
303
+ inline for (info.field_names, info.field_types, 0..) |field_name, field_type, i| {
304
+ @field(result, field_name) = switch (field_type) {
305
305
  Node.Index,
306
306
  Node.OptionalIndex,
307
307
  OptionalTokenIndex,
308
308
  ExtraIndex,
309
309
  => @enumFromInt(tree.extra_data[@intFromEnum(index) + i]),
310
310
  TokenIndex => tree.extra_data[@intFromEnum(index) + i],
311
- else => @compileError("unexpected field type: " ++ @typeName(field.type)),
311
+ else => @compileError("unexpected field type: " ++ @typeName(field_type)),
312
312
  };
313
313
  }
314
314
  return result;