@zigc/lib 0.17.0-dev.644 → 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 (114) hide show
  1. package/compiler/Maker/ScannedConfig.zig +4 -3
  2. package/compiler/Maker/Step/FindProgram.zig +2 -2
  3. package/compiler/Maker/Watch/FsEvents.zig +3 -2
  4. package/compiler/aro/aro/Attribute.zig +52 -51
  5. package/compiler/aro/aro/Compilation.zig +5 -5
  6. package/compiler/aro/aro/Diagnostics.zig +7 -7
  7. package/compiler/aro/aro/Parser.zig +2 -2
  8. package/compiler/aro/aro/Tree.zig +11 -11
  9. package/compiler/aro/aro/features.zig +4 -4
  10. package/compiler/aro/aro/text_literal.zig +2 -2
  11. package/compiler/aro/backend/Interner.zig +14 -13
  12. package/compiler/configurer.zig +2 -2
  13. package/compiler/resinator/bmp.zig +3 -2
  14. package/compiler/resinator/code_pages.zig +14 -12
  15. package/compiler/resinator/cvtres.zig +11 -10
  16. package/compiler/resinator/errors.zig +18 -22
  17. package/compiler/resinator/lang.zig +7 -7
  18. package/compiler/resinator/parse.zig +1 -1
  19. package/compiler/translate-c/ast.zig +6 -6
  20. package/docs/wasm/markdown/Document.zig +3 -3
  21. package/docs/wasm/markdown/Parser.zig +3 -3
  22. package/package.json +1 -1
  23. package/std/Build/Cache.zig +2 -2
  24. package/std/Build/Configuration.zig +19 -16
  25. package/std/Build/Step/ConfigHeader.zig +3 -2
  26. package/std/Build/Step/Options.zig +28 -22
  27. package/std/Build.zig +52 -53
  28. package/std/Io/Kqueue.zig +2 -2
  29. package/std/Io/Reader.zig +1 -1
  30. package/std/Io/Threaded.zig +18 -15
  31. package/std/Io/Uring.zig +2 -2
  32. package/std/Io/Writer.zig +18 -18
  33. package/std/Io/net.zig +3 -1
  34. package/std/Io.zig +7 -6
  35. package/std/Progress.zig +2 -2
  36. package/std/Target/aarch64.zig +2 -2
  37. package/std/Target/alpha.zig +2 -2
  38. package/std/Target/amdgcn.zig +2 -2
  39. package/std/Target/arc.zig +2 -2
  40. package/std/Target/arm.zig +2 -2
  41. package/std/Target/avr.zig +2 -2
  42. package/std/Target/bpf.zig +2 -2
  43. package/std/Target/csky.zig +2 -2
  44. package/std/Target/hexagon.zig +2 -2
  45. package/std/Target/hppa.zig +2 -2
  46. package/std/Target/kvx.zig +2 -2
  47. package/std/Target/lanai.zig +2 -2
  48. package/std/Target/loongarch.zig +2 -2
  49. package/std/Target/m68k.zig +2 -2
  50. package/std/Target/mips.zig +2 -2
  51. package/std/Target/msp430.zig +2 -2
  52. package/std/Target/nvptx.zig +2 -2
  53. package/std/Target/powerpc.zig +2 -2
  54. package/std/Target/propeller.zig +2 -2
  55. package/std/Target/riscv.zig +2 -2
  56. package/std/Target/s390x.zig +2 -2
  57. package/std/Target/sparc.zig +2 -2
  58. package/std/Target/spirv.zig +2 -2
  59. package/std/Target/ve.zig +2 -2
  60. package/std/Target/wasm.zig +2 -2
  61. package/std/Target/x86.zig +2 -2
  62. package/std/Target/xcore.zig +2 -2
  63. package/std/Target/xtensa.zig +2 -2
  64. package/std/Target.zig +4 -4
  65. package/std/c/darwin.zig +1 -1
  66. package/std/coff.zig +1 -1
  67. package/std/crypto/codecs/asn1/Oid.zig +8 -8
  68. package/std/crypto/codecs/asn1/der/Decoder.zig +7 -7
  69. package/std/crypto/codecs/asn1/der/Encoder.zig +10 -8
  70. package/std/crypto/phc_encoding.zig +23 -20
  71. package/std/crypto/timing_safe.zig +1 -1
  72. package/std/crypto/tls/Client.zig +3 -3
  73. package/std/crypto/tls.zig +1 -1
  74. package/std/debug/Dwarf/Unwind/VirtualMachine.zig +11 -5
  75. package/std/debug/ElfFile.zig +12 -8
  76. package/std/debug/MachOFile.zig +2 -2
  77. package/std/debug/SelfInfo/MachO.zig +2 -2
  78. package/std/debug/SelfInfo/Windows.zig +2 -2
  79. package/std/elf.zig +7 -7
  80. package/std/enums.zig +66 -67
  81. package/std/gpu.zig +1 -1
  82. package/std/hash/auto_hash.zig +8 -8
  83. package/std/hash/verify.zig +3 -3
  84. package/std/http/Client.zig +2 -2
  85. package/std/json/Stringify.zig +14 -14
  86. package/std/json/static.zig +47 -31
  87. package/std/lang.zig +65 -97
  88. package/std/math.zig +2 -2
  89. package/std/mem/Allocator.zig +9 -9
  90. package/std/mem.zig +86 -102
  91. package/std/meta/trailer_flags.zig +26 -19
  92. package/std/meta.zig +131 -171
  93. package/std/multi_array_list.zig +49 -57
  94. package/std/os/uefi/protocol/device_path.zig +8 -7
  95. package/std/os/uefi/tables/boot_services.zig +1 -1
  96. package/std/os/windows.zig +9 -15
  97. package/std/start.zig +6 -6
  98. package/std/testing/Smith.zig +35 -21
  99. package/std/testing.zig +15 -15
  100. package/std/zig/Ast.zig +4 -4
  101. package/std/zig/AstGen.zig +42 -42
  102. package/std/zig/ErrorBundle.zig +16 -13
  103. package/std/zig/LibCInstallation.zig +11 -11
  104. package/std/zig/Parse.zig +6 -6
  105. package/std/zig/Zir.zig +10 -10
  106. package/std/zig/c_translation/helpers.zig +2 -2
  107. package/std/zig/llvm/BitcodeReader.zig +3 -3
  108. package/std/zig/llvm/Builder.zig +124 -93
  109. package/std/zig/llvm/bitcode_writer.zig +4 -4
  110. package/std/zig/system/windows.zig +11 -11
  111. package/std/zig/system.zig +4 -4
  112. package/std/zig.zig +4 -4
  113. package/std/zon/Serializer.zig +28 -23
  114. package/std/zon/parse.zig +58 -61
package/std/meta.zig CHANGED
@@ -8,7 +8,7 @@ const root = @import("root");
8
8
 
9
9
  pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags;
10
10
 
11
- const Type = std.builtin.Type;
11
+ const Type = std.lang.Type;
12
12
 
13
13
  test {
14
14
  _ = TrailerFlags;
@@ -22,21 +22,21 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
22
22
  // TODO The '100' here is arbitrary and should be increased when possible:
23
23
  // - https://github.com/ziglang/zig/issues/4055
24
24
  // - https://github.com/ziglang/zig/issues/3863
25
- if (@typeInfo(T).@"enum".fields.len <= 100) {
25
+ if (@typeInfo(T).@"enum".field_names.len <= 100) {
26
26
  const kvs = comptime build_kvs: {
27
27
  const EnumKV = struct { []const u8, T };
28
- var kvs_array: [@typeInfo(T).@"enum".fields.len]EnumKV = undefined;
29
- for (@typeInfo(T).@"enum".fields, 0..) |enumField, i| {
30
- kvs_array[i] = .{ enumField.name, @field(T, enumField.name) };
28
+ var kvs_array: [@typeInfo(T).@"enum".field_names.len]EnumKV = undefined;
29
+ for (@typeInfo(T).@"enum".field_names, 0..) |name, i| {
30
+ kvs_array[i] = .{ name, @field(T, name) };
31
31
  }
32
32
  break :build_kvs kvs_array[0..];
33
33
  };
34
34
  const map = std.StaticStringMap(T).initComptime(kvs);
35
35
  return map.get(str);
36
36
  } else {
37
- inline for (@typeInfo(T).@"enum".fields) |enumField| {
38
- if (mem.eql(u8, str, enumField.name)) {
39
- return @field(T, enumField.name);
37
+ inline for (@typeInfo(T).@"enum".field_names) |name| {
38
+ if (mem.eql(u8, str, name)) {
39
+ return @field(T, name);
40
40
  }
41
41
  }
42
42
  return null;
@@ -63,7 +63,7 @@ pub fn alignment(comptime T: type) comptime_int {
63
63
  .pointer, .@"fn" => alignment(info.child),
64
64
  else => @alignOf(T),
65
65
  },
66
- .pointer => |info| info.alignment orelse @alignOf(info.child),
66
+ .pointer => |info| info.attrs.@"align" orelse @alignOf(info.child),
67
67
  else => @alignOf(T),
68
68
  };
69
69
  }
@@ -171,34 +171,20 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
171
171
  switch (@typeInfo(T)) {
172
172
  .pointer => |info| switch (info.size) {
173
173
  .one => switch (@typeInfo(info.child)) {
174
- .array => |array_info| return @Pointer(.one, .{
175
- .@"const" = info.is_const,
176
- .@"volatile" = info.is_volatile,
177
- .@"allowzero" = info.is_allowzero,
178
- .@"align" = info.alignment,
179
- .@"addrspace" = info.address_space,
180
- }, [array_info.len:sentinel_val]array_info.child, null),
174
+ .array => |array_info| return @Pointer(
175
+ .one,
176
+ info.attrs,
177
+ [array_info.len:sentinel_val]array_info.child,
178
+ null,
179
+ ),
181
180
  else => {},
182
181
  },
183
- .many, .slice => |size| return @Pointer(size, .{
184
- .@"const" = info.is_const,
185
- .@"volatile" = info.is_volatile,
186
- .@"allowzero" = info.is_allowzero,
187
- .@"align" = info.alignment,
188
- .@"addrspace" = info.address_space,
189
- }, info.child, sentinel_val),
182
+ .many, .slice => |size| return @Pointer(size, info.attrs, info.child, sentinel_val),
190
183
  else => {},
191
184
  },
192
185
  .optional => |info| switch (@typeInfo(info.child)) {
193
186
  .pointer => |ptr_info| switch (ptr_info.size) {
194
- .many => return ?@Pointer(.many, .{
195
- .@"const" = ptr_info.is_const,
196
- .@"volatile" = ptr_info.is_volatile,
197
- .@"allowzero" = ptr_info.is_allowzero,
198
- .@"align" = ptr_info.alignment,
199
- .@"addrspace" = ptr_info.address_space,
200
- .child = ptr_info.child,
201
- }, ptr_info.child, sentinel_val),
187
+ .many => return ?@Pointer(.many, ptr_info.attrs, ptr_info.child, sentinel_val),
202
188
  else => {},
203
189
  },
204
190
  else => {},
@@ -238,14 +224,14 @@ test containerLayout {
238
224
  try testing.expect(containerLayout(U3) == .@"extern");
239
225
  }
240
226
 
241
- /// Instead of this function, prefer to use e.g. `@typeInfo(foo).@"struct".decls`
227
+ /// Instead of this function, prefer to use e.g. `@typeInfo(foo).@"struct".decl_names`
242
228
  /// directly when you know what kind of type it is.
243
- pub fn declarations(comptime T: type) []const Type.Declaration {
229
+ pub fn declarations(comptime T: type) []const [:0]const u8 {
244
230
  return switch (@typeInfo(T)) {
245
- .@"struct" => |info| info.decls,
246
- .@"enum" => |info| info.decls,
247
- .@"union" => |info| info.decls,
248
- .@"opaque" => |info| info.decls,
231
+ .@"struct" => |info| info.decl_names,
232
+ .@"enum" => |info| info.decl_names,
233
+ .@"union" => |info| info.decl_names,
234
+ .@"opaque" => |info| info.decl_names,
249
235
  else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"),
250
236
  };
251
237
  }
@@ -268,7 +254,7 @@ test declarations {
268
254
  pub fn a() void {}
269
255
  };
270
256
 
271
- const decls = comptime [_][]const Type.Declaration{
257
+ const decls = comptime [_][]const [:0]const u8{
272
258
  declarations(E1),
273
259
  declarations(S1),
274
260
  declarations(U1),
@@ -277,99 +263,43 @@ test declarations {
277
263
 
278
264
  inline for (decls) |decl| {
279
265
  try testing.expect(decl.len == 1);
280
- try testing.expect(comptime mem.eql(u8, decl[0].name, "a"));
266
+ try testing.expect(comptime mem.eql(u8, decl[0], "a"));
281
267
  }
282
268
  }
283
269
 
284
- pub fn declarationInfo(comptime T: type, comptime decl_name: []const u8) Type.Declaration {
285
- inline for (comptime declarations(T)) |decl| {
286
- if (comptime mem.eql(u8, decl.name, decl_name))
287
- return decl;
288
- }
289
-
290
- @compileError("'" ++ @typeName(T) ++ "' has no declaration '" ++ decl_name ++ "'");
291
- }
292
-
293
- test declarationInfo {
294
- const E1 = enum {
295
- A,
296
-
297
- pub fn a() void {}
298
- };
299
- const S1 = struct {
300
- pub fn a() void {}
301
- };
302
- const U1 = union {
303
- b: u8,
304
-
305
- pub fn a() void {}
306
- };
307
-
308
- const infos = comptime [_]Type.Declaration{
309
- declarationInfo(E1, "a"),
310
- declarationInfo(S1, "a"),
311
- declarationInfo(U1, "a"),
312
- };
270
+ /// To be removed after Zig 0.17.0 is tagged.
271
+ pub const declarationInfo = @compileError("Deprecated; use '@hasDecl' instead");
272
+ /// To be removed after Zig 0.17.0 is tagged.
273
+ pub const fields = @compileError("Deprecated; use 'fieldNames' and 'fieldTypes' instead");
313
274
 
314
- inline for (infos) |info| {
315
- try testing.expect(comptime mem.eql(u8, info.name, "a"));
316
- }
317
- }
318
- pub inline fn fields(comptime T: type) switch (@typeInfo(T)) {
319
- .@"struct" => []const Type.StructField,
320
- .@"union" => []const Type.UnionField,
321
- .@"enum" => []const Type.EnumField,
322
- .error_set => []const Type.Error,
275
+ pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
276
+ .@"struct" => struct { name: [:0]const u8, type: type, attrs: Type.Struct.FieldAttributes },
277
+ .@"union" => struct { name: [:0]const u8, type: type, attrs: Type.Union.FieldAttributes },
278
+ .@"enum" => struct { name: [:0]const u8, value: comptime_int },
279
+ .error_set => struct { name: [:0]const u8 },
323
280
  else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
324
281
  } {
282
+ const idx = @intFromEnum(field);
325
283
  return switch (@typeInfo(T)) {
326
- .@"struct" => |info| info.fields,
327
- .@"union" => |info| info.fields,
328
- .@"enum" => |info| info.fields,
329
- .error_set => |errors| errors.?, // must be non global error set
284
+ .@"struct" => |info| .{
285
+ .name = info.field_names[idx],
286
+ .type = info.field_types[idx],
287
+ .attrs = info.field_attrs[idx],
288
+ },
289
+ .@"union" => |info| .{
290
+ .name = info.field_names[idx],
291
+ .type = info.field_types[idx],
292
+ .attrs = info.field_attrs[idx],
293
+ },
294
+ .@"enum" => |info| .{
295
+ .name = info.field_names[idx],
296
+ .value = info.field_values[idx],
297
+ },
298
+ .error_set => |info| .{ .name = info.error_names.?[idx] },
330
299
  else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
331
300
  };
332
301
  }
333
302
 
334
- test fields {
335
- const E1 = enum {
336
- A,
337
- };
338
- const E2 = error{A};
339
- const S1 = struct {
340
- a: u8,
341
- };
342
- const U1 = union {
343
- a: u8,
344
- };
345
-
346
- const e1f = comptime fields(E1);
347
- const e2f = comptime fields(E2);
348
- const sf = comptime fields(S1);
349
- const uf = comptime fields(U1);
350
-
351
- try testing.expect(e1f.len == 1);
352
- try testing.expect(e2f.len == 1);
353
- try testing.expect(sf.len == 1);
354
- try testing.expect(uf.len == 1);
355
- try testing.expect(mem.eql(u8, e1f[0].name, "A"));
356
- try testing.expect(mem.eql(u8, e2f[0].name, "A"));
357
- try testing.expect(mem.eql(u8, sf[0].name, "a"));
358
- try testing.expect(mem.eql(u8, uf[0].name, "a"));
359
- try testing.expect(comptime sf[0].type == u8);
360
- try testing.expect(comptime uf[0].type == u8);
361
- }
362
-
363
- pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
364
- .@"struct" => Type.StructField,
365
- .@"union" => Type.UnionField,
366
- .@"enum" => Type.EnumField,
367
- .error_set => Type.Error,
368
- else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
369
- } {
370
- return fields(T)[@intFromEnum(field)];
371
- }
372
-
373
303
  test fieldInfo {
374
304
  const E1 = enum {
375
305
  A,
@@ -395,13 +325,13 @@ test fieldInfo {
395
325
  try testing.expect(comptime uf.type == u8);
396
326
  }
397
327
 
398
- pub fn fieldNames(comptime T: type) *const [fields(T).len][:0]const u8 {
399
- return comptime blk: {
400
- const fieldInfos = fields(T);
401
- var names: [fieldInfos.len][:0]const u8 = undefined;
402
- for (&names, fieldInfos) |*name, field| name.* = field.name;
403
- const final = names;
404
- break :blk &final;
328
+ pub fn fieldNames(comptime T: type) []const [:0]const u8 {
329
+ return switch (@typeInfo(T)) {
330
+ .@"struct" => |s| s.field_names,
331
+ .@"union" => |u| u.field_names,
332
+ .@"enum" => |e| e.field_names,
333
+ .error_set => |es| es.error_names.?,
334
+ else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
405
335
  };
406
336
  }
407
337
 
@@ -433,14 +363,41 @@ test fieldNames {
433
363
  try testing.expectEqualSlices(u8, u1names[1], "b");
434
364
  }
435
365
 
366
+ pub fn fieldTypes(comptime T: type) []const type {
367
+ return switch (@typeInfo(T)) {
368
+ .@"struct" => |s| s.field_types,
369
+ .@"union" => |u| u.field_types,
370
+ else => @compileError("Expected struct or union type, found '" ++ @typeName(T) ++ "'"),
371
+ };
372
+ }
373
+
374
+ test fieldTypes {
375
+ const S1 = struct {
376
+ a: u8,
377
+ };
378
+ const U1 = union {
379
+ a: u8,
380
+ b: void,
381
+ };
382
+
383
+ const s1types = comptime fieldTypes(S1);
384
+ const u1types = comptime fieldTypes(U1);
385
+
386
+ try testing.expect(s1types.len == 1);
387
+ try testing.expect(s1types[0] == u8);
388
+ try testing.expect(u1types.len == 2);
389
+ try testing.expect(u1types[0] == u8);
390
+ try testing.expect(u1types[1] == void);
391
+ }
392
+
436
393
  /// Given an enum or error set type, returns a pointer to an array containing all tags for that
437
394
  /// enum or error set.
438
- pub fn tags(comptime T: type) *const [fields(T).len]T {
395
+ pub fn tags(comptime T: type) *const [fieldNames(T).len]T {
439
396
  return comptime blk: {
440
- const fieldInfos = fields(T);
441
- var res: [fieldInfos.len]T = undefined;
442
- for (fieldInfos, 0..) |field, i| {
443
- res[i] = @field(T, field.name);
397
+ const field_names = fieldNames(T);
398
+ var res: [field_names.len]T = undefined;
399
+ for (field_names, 0..) |field_name, i| {
400
+ res[i] = @field(T, field_name);
444
401
  }
445
402
  const final = res;
446
403
  break :blk &final;
@@ -491,27 +448,30 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
491
448
  // because the language does not guarantee that the slice pointers for field names
492
449
  // and decl names will be the same.
493
450
  comptime {
494
- const expected_fields = @typeInfo(expected).@"enum".fields;
495
- const actual_fields = @typeInfo(actual).@"enum".fields;
496
- if (expected_fields.len != actual_fields.len) return error.FailedTest;
497
- for (expected_fields, 0..) |expected_field, i| {
498
- const actual_field = actual_fields[i];
499
- try testing.expectEqual(expected_field.value, actual_field.value);
500
- try testing.expectEqualStrings(expected_field.name, actual_field.name);
451
+ const expected_field_names = @typeInfo(expected).@"enum".field_names;
452
+ const expected_field_values = @typeInfo(expected).@"enum".field_values;
453
+ const actual_field_names = @typeInfo(actual).@"enum".field_names;
454
+ const actual_field_values = @typeInfo(actual).@"enum".field_values;
455
+ if (expected_field_names.len != actual_field_names.len) return error.FailedTest;
456
+ for (expected_field_names, expected_field_values, 0..) |expected_field_name, expected_field_value, i| {
457
+ const actual_field_name = actual_field_names[i];
458
+ const actual_field_value = actual_field_values[i];
459
+ try testing.expectEqual(expected_field_value, actual_field_value);
460
+ try testing.expectEqualStrings(expected_field_name, actual_field_name);
501
461
  }
502
462
  }
503
463
  comptime {
504
- const expected_decls = @typeInfo(expected).@"enum".decls;
505
- const actual_decls = @typeInfo(actual).@"enum".decls;
506
- if (expected_decls.len != actual_decls.len) return error.FailedTest;
507
- for (expected_decls, 0..) |expected_decl, i| {
508
- const actual_decl = actual_decls[i];
509
- try testing.expectEqualStrings(expected_decl.name, actual_decl.name);
464
+ const expected_decl_names = @typeInfo(expected).@"enum".decl_names;
465
+ const actual_decl_names = @typeInfo(actual).@"enum".decl_names;
466
+ if (expected_decl_names.len != actual_decl_names.len) return error.FailedTest;
467
+ for (expected_decl_names, 0..) |expected_decl_name, i| {
468
+ const actual_decl_name = actual_decl_names[i];
469
+ try testing.expectEqualStrings(expected_decl_name, actual_decl_name);
510
470
  }
511
471
  }
512
472
  try testing.expectEqual(
513
- @typeInfo(expected).@"enum".is_exhaustive,
514
- @typeInfo(actual).@"enum".is_exhaustive,
473
+ @typeInfo(expected).@"enum".mode,
474
+ @typeInfo(actual).@"enum".mode,
515
475
  );
516
476
  }
517
477
 
@@ -534,11 +494,9 @@ test FieldEnum {
534
494
  }
535
495
 
536
496
  pub fn DeclEnum(comptime T: type) type {
537
- const decls = declarations(T);
538
- var names: [decls.len][]const u8 = undefined;
539
- for (&names, decls) |*name, decl| name.* = decl.name;
540
- const IntTag = std.math.IntFittingRange(0, decls.len -| 1);
541
- return @Enum(IntTag, .exhaustive, &names, &std.simd.iota(IntTag, decls.len));
497
+ const decl_names = declarations(T);
498
+ const IntTag = std.math.IntFittingRange(0, decl_names.len -| 1);
499
+ return @Enum(IntTag, .exhaustive, decl_names, &std.simd.iota(IntTag, decl_names.len));
542
500
  }
543
501
 
544
502
  test DeclEnum {
@@ -622,8 +580,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
622
580
  .@"struct" => |info| {
623
581
  if (info.layout == .@"packed") return a == b;
624
582
 
625
- inline for (info.fields) |field_info| {
626
- if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false;
583
+ inline for (info.field_names) |field_name| {
584
+ if (!eql(@field(a, field_name), @field(b, field_name))) return false;
627
585
  }
628
586
  return true;
629
587
  },
@@ -744,8 +702,8 @@ test eql {
744
702
  /// Given a type and a name, return the field index according to source order.
745
703
  /// Returns `null` if the field is not found.
746
704
  pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
747
- inline for (fields(T), 0..) |field, i| {
748
- if (mem.eql(u8, field.name, name))
705
+ inline for (fieldNames(T), 0..) |field_name, i| {
706
+ if (mem.eql(u8, field_name, name))
749
707
  return i;
750
708
  }
751
709
  return null;
@@ -782,12 +740,12 @@ pub fn ArgsTuple(comptime Function: type) type {
782
740
  @compileError("ArgsTuple expects a function type");
783
741
 
784
742
  const function_info = info.@"fn";
785
- if (function_info.is_var_args)
743
+ if (function_info.attrs.varargs)
786
744
  @compileError("Cannot create ArgsTuple for variadic function");
787
745
 
788
- var argument_field_list: [function_info.params.len]type = undefined;
789
- inline for (function_info.params, 0..) |arg, i| {
790
- const T = arg.type orelse @compileError("cannot create ArgsTuple for function with an 'anytype' parameter");
746
+ var argument_field_list: [function_info.param_types.len]type = undefined;
747
+ inline for (function_info.param_types, 0..) |arg_type, i| {
748
+ const T = arg_type orelse @compileError("cannot create ArgsTuple for function with an 'anytype' parameter");
791
749
  argument_field_list[i] = T;
792
750
  }
793
751
 
@@ -807,13 +765,15 @@ const TupleTester = struct {
807
765
  if (!info.@"struct".is_tuple)
808
766
  @compileError("Struct type must be a tuple type");
809
767
 
810
- const fields_list = std.meta.fields(Actual);
811
- if (expected.len != fields_list.len)
812
- @compileError("Argument count mismatch");
768
+ const field_names = info.@"struct".field_names;
769
+ if (expected.len != field_names.len) {
770
+ const msg = std.fmt.comptimePrint("Argument count mismatch: expected {d}, got {d}", .{ expected.len, field_names.len });
771
+ @compileError(msg);
772
+ }
813
773
 
814
- inline for (fields_list, 0..) |fld, i| {
815
- if (expected[i] != fld.type) {
816
- @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.type));
774
+ inline for (field_names, info.@"struct".field_types, 0..) |fld_name, fld_type, i| {
775
+ if (expected[i] != fld_type) {
776
+ @compileError("Field " ++ fld_name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld_type));
817
777
  }
818
778
  }
819
779
  }
@@ -943,7 +903,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
943
903
  .pointer => |info| info.size != .slice,
944
904
 
945
905
  .optional => |info| switch (@typeInfo(info.child)) {
946
- .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
906
+ .pointer => |ptr| !ptr.attrs.@"allowzero" and switch (ptr.size) {
947
907
  .slice, .c => false,
948
908
  .one, .many => true,
949
909
  },
@@ -957,10 +917,10 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
957
917
 
958
918
  var sum_size = @as(usize, 0);
959
919
 
960
- inline for (info.fields) |field| {
961
- if (field.is_comptime) continue;
962
- if (!hasUniqueRepresentation(field.type)) return false;
963
- sum_size += @sizeOf(field.type);
920
+ inline for (info.field_attrs, info.field_types) |field_attr, field_type| {
921
+ if (field_attr.@"comptime") continue;
922
+ if (!hasUniqueRepresentation(field_type)) return false;
923
+ sum_size += @sizeOf(field_type);
964
924
  }
965
925
 
966
926
  return @sizeOf(T) == sum_size;