diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-02-22 08:54:10 +0100 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-02-22 08:54:35 +0100 |
| commit | 4b215e3a115d172913d4bb993b6b48dc97566181 (patch) | |
| tree | b0a3ab6335e76b60b9ae13c98b949f623de86435 /lib | |
| parent | a907353ca4df47b359b59d15259bbb105253b176 (diff) | |
| download | zig-4b215e3a115d172913d4bb993b6b48dc97566181.tar.gz zig-4b215e3a115d172913d4bb993b6b48dc97566181.zip | |
Builder: support printing metadata in llvm ir
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/meta.zig | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 0df80359ac..a94ad97041 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -460,13 +460,11 @@ test "std.meta.FieldType" { try testing.expect(FieldType(U, .d) == *const u8); } -pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { +pub fn fieldNames(comptime T: type) *const [fields(T).len][:0]const u8 { return comptime blk: { const fieldInfos = fields(T); - var names: [fieldInfos.len][]const u8 = undefined; - for (fieldInfos, 0..) |field, i| { - names[i] = field.name; - } + var names: [fieldInfos.len][:0]const u8 = undefined; + for (&names, fieldInfos) |*name, field| name.* = field.name; break :blk &names; }; } |
