authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-07 14:47:59+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-12 13:55:41+01:00
logc4ec382fc806e0cb4484c1cb2edcc5fc40c3c9d8
treee2b3fd46007dfa4fc775245dfb53bb9f7946d92c
parent580d622b0dfec3ae9f1e3262673d8d4daa6b5b60
signaturelock-open Commit is signed but in an unrecognized format.

InternPool: store the Nav types are named after

When the name strategy is `.parent`, the DWARF info really wants to know what `Nav` we were named after to emit a more optimal hierarchy.

4 files changed, 106 insertions(+), 32 deletions(-)

src/InternPool.zig+51
...@@ -3249,6 +3249,9 @@ pub const LoadedUnionType = struct {...@@ -3249,6 +3249,9 @@ pub const LoadedUnionType = struct {
3249 name: NullTerminatedString,3249 name: NullTerminatedString,
3250 /// Represents the declarations inside this union.3250 /// Represents the declarations inside this union.
3251 namespace: NamespaceIndex,3251 namespace: NamespaceIndex,
3252 /// If this is a declared type with the `.parent` name strategy, this is the `Nav` it was named after.
3253 /// Otherwise, this is `.none`.
3254 name_nav: Nav.Index.Optional,
3252 /// The enum tag type.3255 /// The enum tag type.
3253 enum_tag_ty: Index,3256 enum_tag_ty: Index,
3254 /// List of field types in declaration order.3257 /// List of field types in declaration order.
...@@ -3567,6 +3570,7 @@ pub fn loadUnionType(ip: *const InternPool, index: Index) LoadedUnionType {...@@ -3567,6 +3570,7 @@ pub fn loadUnionType(ip: *const InternPool, index: Index) LoadedUnionType {
3567 .tid = unwrapped_index.tid,3570 .tid = unwrapped_index.tid,
3568 .extra_index = data,3571 .extra_index = data,
3569 .name = type_union.data.name,3572 .name = type_union.data.name,
3573 .name_nav = type_union.data.name_nav,
3570 .namespace = type_union.data.namespace,3574 .namespace = type_union.data.namespace,
3571 .enum_tag_ty = type_union.data.tag_ty,3575 .enum_tag_ty = type_union.data.tag_ty,
3572 .field_types = field_types,3576 .field_types = field_types,
...@@ -3584,6 +3588,9 @@ pub const LoadedStructType = struct {...@@ -3584,6 +3588,9 @@ pub const LoadedStructType = struct {
3584 /// The name of this struct type.3588 /// The name of this struct type.
3585 name: NullTerminatedString,3589 name: NullTerminatedString,
3586 namespace: NamespaceIndex,3590 namespace: NamespaceIndex,
3591 /// If this is a declared type with the `.parent` name strategy, this is the `Nav` it was named after.
3592 /// Otherwise, or if this is a file's root struct type, this is `.none`.
3593 name_nav: Nav.Index.Optional,
3587 /// Index of the `struct_decl` or `reify` ZIR instruction.3594 /// Index of the `struct_decl` or `reify` ZIR instruction.
3588 zir_index: TrackedInst.Index,3595 zir_index: TrackedInst.Index,
3589 layout: std.builtin.Type.ContainerLayout,3596 layout: std.builtin.Type.ContainerLayout,
...@@ -4173,6 +4180,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -4173,6 +4180,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
4173 switch (item.tag) {4180 switch (item.tag) {
4174 .type_struct => {4181 .type_struct => {
4175 const name: NullTerminatedString = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "name").?]);4182 const name: NullTerminatedString = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "name").?]);
4183 const name_nav: Nav.Index.Optional = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "name_nav").?]);
4176 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "namespace").?]);4184 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "namespace").?]);
4177 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);4185 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);
4178 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "fields_len").?];4186 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "fields_len").?];
...@@ -4259,6 +4267,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -4259,6 +4267,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
4259 .tid = unwrapped_index.tid,4267 .tid = unwrapped_index.tid,
4260 .extra_index = item.data,4268 .extra_index = item.data,
4261 .name = name,4269 .name = name,
4270 .name_nav = name_nav,
4262 .namespace = namespace,4271 .namespace = namespace,
4263 .zir_index = zir_index,4272 .zir_index = zir_index,
4264 .layout = if (flags.is_extern) .@"extern" else .auto,4273 .layout = if (flags.is_extern) .@"extern" else .auto,
...@@ -4275,6 +4284,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -4275,6 +4284,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
4275 },4284 },
4276 .type_struct_packed, .type_struct_packed_inits => {4285 .type_struct_packed, .type_struct_packed_inits => {
4277 const name: NullTerminatedString = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "name").?]);4286 const name: NullTerminatedString = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "name").?]);
4287 const name_nav: Nav.Index.Optional = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "name_nav").?]);
4278 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "zir_index").?]);4288 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "zir_index").?]);
4279 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "fields_len").?];4289 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "fields_len").?];
4280 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?]);4290 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?]);
...@@ -4321,6 +4331,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -4321,6 +4331,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
4321 .tid = unwrapped_index.tid,4331 .tid = unwrapped_index.tid,
4322 .extra_index = item.data,4332 .extra_index = item.data,
4323 .name = name,4333 .name = name,
4334 .name_nav = name_nav,
4324 .namespace = namespace,4335 .namespace = namespace,
4325 .zir_index = zir_index,4336 .zir_index = zir_index,
4326 .layout = .@"packed",4337 .layout = .@"packed",
...@@ -4345,6 +4356,9 @@ pub const LoadedEnumType = struct {...@@ -4345,6 +4356,9 @@ pub const LoadedEnumType = struct {
4345 name: NullTerminatedString,4356 name: NullTerminatedString,
4346 /// Represents the declarations inside this enum.4357 /// Represents the declarations inside this enum.
4347 namespace: NamespaceIndex,4358 namespace: NamespaceIndex,
4359 /// If this is a declared type with the `.parent` name strategy, this is the `Nav` it was named after.
4360 /// Otherwise, this is `.none`.
4361 name_nav: Nav.Index.Optional,
4348 /// An integer type which is used for the numerical value of the enum.4362 /// An integer type which is used for the numerical value of the enum.
4349 /// This field is present regardless of whether the enum has an4363 /// This field is present regardless of whether the enum has an
4350 /// explicitly provided tag type or auto-numbered.4364 /// explicitly provided tag type or auto-numbered.
...@@ -4428,6 +4442,7 @@ pub fn loadEnumType(ip: *const InternPool, index: Index) LoadedEnumType {...@@ -4428,6 +4442,7 @@ pub fn loadEnumType(ip: *const InternPool, index: Index) LoadedEnumType {
4428 } else extra.data.captures_len;4442 } else extra.data.captures_len;
4429 return .{4443 return .{
4430 .name = extra.data.name,4444 .name = extra.data.name,
4445 .name_nav = extra.data.name_nav,
4431 .namespace = extra.data.namespace,4446 .namespace = extra.data.namespace,
4432 .tag_ty = extra.data.int_tag_type,4447 .tag_ty = extra.data.int_tag_type,
4433 .names = .{4448 .names = .{
...@@ -4462,6 +4477,7 @@ pub fn loadEnumType(ip: *const InternPool, index: Index) LoadedEnumType {...@@ -4462,6 +4477,7 @@ pub fn loadEnumType(ip: *const InternPool, index: Index) LoadedEnumType {
4462 } else extra.data.captures_len;4477 } else extra.data.captures_len;
4463 return .{4478 return .{
4464 .name = extra.data.name,4479 .name = extra.data.name,
4480 .name_nav = extra.data.name_nav,
4465 .namespace = extra.data.namespace,4481 .namespace = extra.data.namespace,
4466 .tag_ty = extra.data.int_tag_type,4482 .tag_ty = extra.data.int_tag_type,
4467 .names = .{4483 .names = .{
...@@ -4493,6 +4509,9 @@ pub const LoadedOpaqueType = struct {...@@ -4493,6 +4509,9 @@ pub const LoadedOpaqueType = struct {
4493 // TODO: the non-fqn will be needed by the new dwarf structure4509 // TODO: the non-fqn will be needed by the new dwarf structure
4494 /// The name of this opaque type.4510 /// The name of this opaque type.
4495 name: NullTerminatedString,4511 name: NullTerminatedString,
4512 /// If this is a declared type with the `.parent` name strategy, this is the `Nav` it was named after.
4513 /// Otherwise, this is `.none`.
4514 name_nav: Nav.Index.Optional,
4496 /// Index of the `opaque_decl` or `reify` instruction.4515 /// Index of the `opaque_decl` or `reify` instruction.
4497 zir_index: TrackedInst.Index,4516 zir_index: TrackedInst.Index,
4498 captures: CaptureValue.Slice,4517 captures: CaptureValue.Slice,
...@@ -4509,6 +4528,7 @@ pub fn loadOpaqueType(ip: *const InternPool, index: Index) LoadedOpaqueType {...@@ -4509,6 +4528,7 @@ pub fn loadOpaqueType(ip: *const InternPool, index: Index) LoadedOpaqueType {
4509 extra.data.captures_len;4528 extra.data.captures_len;
4510 return .{4529 return .{
4511 .name = extra.data.name,4530 .name = extra.data.name,
4531 .name_nav = extra.data.name_nav,
4512 .namespace = extra.data.namespace,4532 .namespace = extra.data.namespace,
4513 .zir_index = extra.data.zir_index,4533 .zir_index = extra.data.zir_index,
4514 .captures = .{4534 .captures = .{
...@@ -6022,6 +6042,7 @@ pub const Tag = enum(u8) {...@@ -6022,6 +6042,7 @@ pub const Tag = enum(u8) {
6022 /// 4. field align: Alignment for each field; declaration order6042 /// 4. field align: Alignment for each field; declaration order
6023 pub const TypeUnion = struct {6043 pub const TypeUnion = struct {
6024 name: NullTerminatedString,6044 name: NullTerminatedString,
6045 name_nav: Nav.Index.Optional,
6025 flags: Flags,6046 flags: Flags,
6026 /// This could be provided through the tag type, but it is more convenient6047 /// This could be provided through the tag type, but it is more convenient
6027 /// to store it directly. This is also necessary for `dumpStatsFallible` to6048 /// to store it directly. This is also necessary for `dumpStatsFallible` to
...@@ -6061,6 +6082,7 @@ pub const Tag = enum(u8) {...@@ -6061,6 +6082,7 @@ pub const Tag = enum(u8) {
6061 /// 5. init: Index for each fields_len // if tag is type_struct_packed_inits6082 /// 5. init: Index for each fields_len // if tag is type_struct_packed_inits
6062 pub const TypeStructPacked = struct {6083 pub const TypeStructPacked = struct {
6063 name: NullTerminatedString,6084 name: NullTerminatedString,
6085 name_nav: Nav.Index.Optional,
6064 zir_index: TrackedInst.Index,6086 zir_index: TrackedInst.Index,
6065 fields_len: u32,6087 fields_len: u32,
6066 namespace: NamespaceIndex,6088 namespace: NamespaceIndex,
...@@ -6108,6 +6130,7 @@ pub const Tag = enum(u8) {...@@ -6108,6 +6130,7 @@ pub const Tag = enum(u8) {
6108 /// 8. field_offset: u32 // for each field in declared order, undef until layout_resolved6130 /// 8. field_offset: u32 // for each field in declared order, undef until layout_resolved
6109 pub const TypeStruct = struct {6131 pub const TypeStruct = struct {
6110 name: NullTerminatedString,6132 name: NullTerminatedString,
6133 name_nav: Nav.Index.Optional,
6111 zir_index: TrackedInst.Index,6134 zir_index: TrackedInst.Index,
6112 namespace: NamespaceIndex,6135 namespace: NamespaceIndex,
6113 fields_len: u32,6136 fields_len: u32,
...@@ -6151,6 +6174,7 @@ pub const Tag = enum(u8) {...@@ -6151,6 +6174,7 @@ pub const Tag = enum(u8) {
6151 /// 0. capture: CaptureValue // for each `captures_len`6174 /// 0. capture: CaptureValue // for each `captures_len`
6152 pub const TypeOpaque = struct {6175 pub const TypeOpaque = struct {
6153 name: NullTerminatedString,6176 name: NullTerminatedString,
6177 name_nav: Nav.Index.Optional,
6154 /// Contains the declarations inside this opaque.6178 /// Contains the declarations inside this opaque.
6155 namespace: NamespaceIndex,6179 namespace: NamespaceIndex,
6156 /// The index of the `opaque_decl` instruction.6180 /// The index of the `opaque_decl` instruction.
...@@ -6429,6 +6453,7 @@ pub const Array = struct {...@@ -6429,6 +6453,7 @@ pub const Array = struct {
6429/// 4. tag value: Index for each fields_len; declaration order6453/// 4. tag value: Index for each fields_len; declaration order
6430pub const EnumExplicit = struct {6454pub const EnumExplicit = struct {
6431 name: NullTerminatedString,6455 name: NullTerminatedString,
6456 name_nav: Nav.Index.Optional,
6432 /// `std.math.maxInt(u32)` indicates this type is reified.6457 /// `std.math.maxInt(u32)` indicates this type is reified.
6433 captures_len: u32,6458 captures_len: u32,
6434 namespace: NamespaceIndex,6459 namespace: NamespaceIndex,
...@@ -6454,6 +6479,7 @@ pub const EnumExplicit = struct {...@@ -6454,6 +6479,7 @@ pub const EnumExplicit = struct {
6454/// 3. field name: NullTerminatedString for each fields_len; declaration order6479/// 3. field name: NullTerminatedString for each fields_len; declaration order
6455pub const EnumAuto = struct {6480pub const EnumAuto = struct {
6456 name: NullTerminatedString,6481 name: NullTerminatedString,
6482 name_nav: Nav.Index.Optional,
6457 /// `std.math.maxInt(u32)` indicates this type is reified.6483 /// `std.math.maxInt(u32)` indicates this type is reified.
6458 captures_len: u32,6484 captures_len: u32,
6459 namespace: NamespaceIndex,6485 namespace: NamespaceIndex,
...@@ -8666,6 +8692,7 @@ pub fn getUnionType(...@@ -8666,6 +8692,7 @@ pub fn getUnionType(
8666 .size = std.math.maxInt(u32),8692 .size = std.math.maxInt(u32),
8667 .padding = std.math.maxInt(u32),8693 .padding = std.math.maxInt(u32),
8668 .name = undefined, // set by `finish`8694 .name = undefined, // set by `finish`
8695 .name_nav = undefined, // set by `finish`
8669 .namespace = undefined, // set by `finish`8696 .namespace = undefined, // set by `finish`
8670 .tag_ty = ini.enum_tag_ty,8697 .tag_ty = ini.enum_tag_ty,
8671 .zir_index = switch (ini.key) {8698 .zir_index = switch (ini.key) {
...@@ -8717,6 +8744,7 @@ pub fn getUnionType(...@@ -8717,6 +8744,7 @@ pub fn getUnionType(
8717 .tid = tid,8744 .tid = tid,
8718 .index = gop.put(),8745 .index = gop.put(),
8719 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeUnion, "name").?,8746 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeUnion, "name").?,
8747 .name_nav_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeUnion, "name_nav").?,
8720 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeUnion, "namespace").?,8748 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeUnion, "namespace").?,
8721 } };8749 } };
8722}8750}
...@@ -8726,15 +8754,20 @@ pub const WipNamespaceType = struct {...@@ -8726,15 +8754,20 @@ pub const WipNamespaceType = struct {
8726 index: Index,8754 index: Index,
8727 type_name_extra_index: u32,8755 type_name_extra_index: u32,
8728 namespace_extra_index: u32,8756 namespace_extra_index: u32,
8757 name_nav_extra_index: u32,
87298758
8730 pub fn setName(8759 pub fn setName(
8731 wip: WipNamespaceType,8760 wip: WipNamespaceType,
8732 ip: *InternPool,8761 ip: *InternPool,
8733 type_name: NullTerminatedString,8762 type_name: NullTerminatedString,
8763 /// This should be the `Nav` we are named after if we use the `.parent` name strategy; `.none` otherwise.
8764 /// This is also `.none` if we use `.parent` because we are the root struct type for a file.
8765 name_nav: Nav.Index.Optional,
8734 ) void {8766 ) void {
8735 const extra = ip.getLocalShared(wip.tid).extra.acquire();8767 const extra = ip.getLocalShared(wip.tid).extra.acquire();
8736 const extra_items = extra.view().items(.@"0");8768 const extra_items = extra.view().items(.@"0");
8737 extra_items[wip.type_name_extra_index] = @intFromEnum(type_name);8769 extra_items[wip.type_name_extra_index] = @intFromEnum(type_name);
8770 extra_items[wip.name_nav_extra_index] = @intFromEnum(name_nav);
8738 }8771 }
87398772
8740 pub fn finish(8773 pub fn finish(
...@@ -8843,6 +8876,7 @@ pub fn getStructType(...@@ -8843,6 +8876,7 @@ pub fn getStructType(
8843 ini.fields_len); // inits8876 ini.fields_len); // inits
8844 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeStructPacked{8877 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeStructPacked{
8845 .name = undefined, // set by `finish`8878 .name = undefined, // set by `finish`
8879 .name_nav = undefined, // set by `finish`
8846 .zir_index = zir_index,8880 .zir_index = zir_index,
8847 .fields_len = ini.fields_len,8881 .fields_len = ini.fields_len,
8848 .namespace = undefined, // set by `finish`8882 .namespace = undefined, // set by `finish`
...@@ -8887,6 +8921,7 @@ pub fn getStructType(...@@ -8887,6 +8921,7 @@ pub fn getStructType(
8887 .tid = tid,8921 .tid = tid,
8888 .index = gop.put(),8922 .index = gop.put(),
8889 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStructPacked, "name").?,8923 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStructPacked, "name").?,
8924 .name_nav_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStructPacked, "name_nav").?,
8890 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?,8925 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?,
8891 } };8926 } };
8892 },8927 },
...@@ -8909,6 +8944,7 @@ pub fn getStructType(...@@ -8909,6 +8944,7 @@ pub fn getStructType(
8909 1); // names_map8944 1); // names_map
8910 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeStruct{8945 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeStruct{
8911 .name = undefined, // set by `finish`8946 .name = undefined, // set by `finish`
8947 .name_nav = undefined, // set by `finish`
8912 .zir_index = zir_index,8948 .zir_index = zir_index,
8913 .namespace = undefined, // set by `finish`8949 .namespace = undefined, // set by `finish`
8914 .fields_len = ini.fields_len,8950 .fields_len = ini.fields_len,
...@@ -8977,6 +9013,7 @@ pub fn getStructType(...@@ -8977,6 +9013,7 @@ pub fn getStructType(
8977 .tid = tid,9013 .tid = tid,
8978 .index = gop.put(),9014 .index = gop.put(),
8979 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStruct, "name").?,9015 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStruct, "name").?,
9016 .name_nav_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStruct, "name_nav").?,
8980 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStruct, "namespace").?,9017 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStruct, "namespace").?,
8981 } };9018 } };
8982}9019}
...@@ -9766,6 +9803,7 @@ pub const WipEnumType = struct {...@@ -9766,6 +9803,7 @@ pub const WipEnumType = struct {
9766 tag_ty_index: u32,9803 tag_ty_index: u32,
9767 type_name_extra_index: u32,9804 type_name_extra_index: u32,
9768 namespace_extra_index: u32,9805 namespace_extra_index: u32,
9806 name_nav_extra_index: u32,
9769 names_map: MapIndex,9807 names_map: MapIndex,
9770 names_start: u32,9808 names_start: u32,
9771 values_map: OptionalMapIndex,9809 values_map: OptionalMapIndex,
...@@ -9775,10 +9813,13 @@ pub const WipEnumType = struct {...@@ -9775,10 +9813,13 @@ pub const WipEnumType = struct {
9775 wip: WipEnumType,9813 wip: WipEnumType,
9776 ip: *InternPool,9814 ip: *InternPool,
9777 type_name: NullTerminatedString,9815 type_name: NullTerminatedString,
9816 /// This should be the `Nav` we are named after if we use the `.parent` name strategy; `.none` otherwise.
9817 name_nav: Nav.Index.Optional,
9778 ) void {9818 ) void {
9779 const extra = ip.getLocalShared(wip.tid).extra.acquire();9819 const extra = ip.getLocalShared(wip.tid).extra.acquire();
9780 const extra_items = extra.view().items(.@"0");9820 const extra_items = extra.view().items(.@"0");
9781 extra_items[wip.type_name_extra_index] = @intFromEnum(type_name);9821 extra_items[wip.type_name_extra_index] = @intFromEnum(type_name);
9822 extra_items[wip.name_nav_extra_index] = @intFromEnum(name_nav);
9782 }9823 }
97839824
9784 pub fn prepare(9825 pub fn prepare(
...@@ -9893,6 +9934,7 @@ pub fn getEnumType(...@@ -9893,6 +9934,7 @@ pub fn getEnumType(
98939934
9894 const extra_index = addExtraAssumeCapacity(extra, EnumAuto{9935 const extra_index = addExtraAssumeCapacity(extra, EnumAuto{
9895 .name = undefined, // set by `prepare`9936 .name = undefined, // set by `prepare`
9937 .name_nav = undefined, // set by `prepare`
9896 .captures_len = switch (ini.key) {9938 .captures_len = switch (ini.key) {
9897 inline .declared, .declared_owned_captures => |d| @intCast(d.captures.len),9939 inline .declared, .declared_owned_captures => |d| @intCast(d.captures.len),
9898 .reified => std.math.maxInt(u32),9940 .reified => std.math.maxInt(u32),
...@@ -9921,6 +9963,7 @@ pub fn getEnumType(...@@ -9921,6 +9963,7 @@ pub fn getEnumType(
9921 .index = gop.put(),9963 .index = gop.put(),
9922 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumAuto, "int_tag_type").?,9964 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumAuto, "int_tag_type").?,
9923 .type_name_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "name").?,9965 .type_name_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "name").?,
9966 .name_nav_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "name_nav").?,
9924 .namespace_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "namespace").?,9967 .namespace_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "namespace").?,
9925 .names_map = names_map,9968 .names_map = names_map,
9926 .names_start = @intCast(names_start),9969 .names_start = @intCast(names_start),
...@@ -9950,6 +9993,7 @@ pub fn getEnumType(...@@ -9950,6 +9993,7 @@ pub fn getEnumType(
99509993
9951 const extra_index = addExtraAssumeCapacity(extra, EnumExplicit{9994 const extra_index = addExtraAssumeCapacity(extra, EnumExplicit{
9952 .name = undefined, // set by `prepare`9995 .name = undefined, // set by `prepare`
9996 .name_nav = undefined, // set by `prepare`
9953 .captures_len = switch (ini.key) {9997 .captures_len = switch (ini.key) {
9954 inline .declared, .declared_owned_captures => |d| @intCast(d.captures.len),9998 inline .declared, .declared_owned_captures => |d| @intCast(d.captures.len),
9955 .reified => std.math.maxInt(u32),9999 .reified => std.math.maxInt(u32),
...@@ -9987,6 +10031,7 @@ pub fn getEnumType(...@@ -9987,6 +10031,7 @@ pub fn getEnumType(
9987 .index = gop.put(),10031 .index = gop.put(),
9988 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumExplicit, "int_tag_type").?,10032 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumExplicit, "int_tag_type").?,
9989 .type_name_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "name").?,10033 .type_name_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "name").?,
10034 .name_nav_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "name_nav").?,
9990 .namespace_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "namespace").?,10035 .namespace_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "namespace").?,
9991 .names_map = names_map,10036 .names_map = names_map,
9992 .names_start = @intCast(names_start),10037 .names_start = @intCast(names_start),
...@@ -10055,6 +10100,7 @@ pub fn getGeneratedTagEnumType(...@@ -10055,6 +10100,7 @@ pub fn getGeneratedTagEnumType(
10055 .tag = .type_enum_auto,10100 .tag = .type_enum_auto,
10056 .data = addExtraAssumeCapacity(extra, EnumAuto{10101 .data = addExtraAssumeCapacity(extra, EnumAuto{
10057 .name = ini.name,10102 .name = ini.name,
10103 .name_nav = .none,
10058 .captures_len = 0,10104 .captures_len = 0,
10059 .namespace = namespace,10105 .namespace = namespace,
10060 .int_tag_type = ini.tag_ty,10106 .int_tag_type = ini.tag_ty,
...@@ -10088,6 +10134,7 @@ pub fn getGeneratedTagEnumType(...@@ -10088,6 +10134,7 @@ pub fn getGeneratedTagEnumType(
10088 },10134 },
10089 .data = addExtraAssumeCapacity(extra, EnumExplicit{10135 .data = addExtraAssumeCapacity(extra, EnumExplicit{
10090 .name = ini.name,10136 .name = ini.name,
10137 .name_nav = .none,
10091 .captures_len = 0,10138 .captures_len = 0,
10092 .namespace = namespace,10139 .namespace = namespace,
10093 .int_tag_type = ini.tag_ty,10140 .int_tag_type = ini.tag_ty,
...@@ -10161,6 +10208,7 @@ pub fn getOpaqueType(...@@ -10161,6 +10208,7 @@ pub fn getOpaqueType(
10161 });10208 });
10162 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeOpaque{10209 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeOpaque{
10163 .name = undefined, // set by `finish`10210 .name = undefined, // set by `finish`
10211 .name_nav = undefined, // set by `finish`
10164 .namespace = undefined, // set by `finish`10212 .namespace = undefined, // set by `finish`
10165 .zir_index = switch (ini.key) {10213 .zir_index = switch (ini.key) {
10166 inline else => |x| x.zir_index,10214 inline else => |x| x.zir_index,
...@@ -10183,6 +10231,7 @@ pub fn getOpaqueType(...@@ -10183,6 +10231,7 @@ pub fn getOpaqueType(
10183 .tid = tid,10231 .tid = tid,
10184 .index = gop.put(),10232 .index = gop.put(),
10185 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeOpaque, "name").?,10233 .type_name_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeOpaque, "name").?,
10234 .name_nav_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeOpaque, "name_nav").?,
10186 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeOpaque, "namespace").?,10235 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeOpaque, "namespace").?,
10187 },10236 },
10188 };10237 };
...@@ -10299,6 +10348,7 @@ fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 {...@@ -10299,6 +10348,7 @@ fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 {
10299 extra.appendAssumeCapacity(.{switch (field.type) {10348 extra.appendAssumeCapacity(.{switch (field.type) {
10300 Index,10349 Index,
10301 Nav.Index,10350 Nav.Index,
10351 Nav.Index.Optional,
10302 NamespaceIndex,10352 NamespaceIndex,
10303 OptionalNamespaceIndex,10353 OptionalNamespaceIndex,
10304 MapIndex,10354 MapIndex,
...@@ -10361,6 +10411,7 @@ fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { dat...@@ -10361,6 +10411,7 @@ fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { dat
10361 @field(result, field.name) = switch (field.type) {10411 @field(result, field.name) = switch (field.type) {
10362 Index,10412 Index,
10363 Nav.Index,10413 Nav.Index,
10414 Nav.Index.Optional,
10364 NamespaceIndex,10415 NamespaceIndex,
10365 OptionalNamespaceIndex,10416 OptionalNamespaceIndex,
10366 MapIndex,10417 MapIndex,
src/Sema.zig+48-26
...@@ -2963,13 +2963,14 @@ fn zirStructDecl(...@@ -2963,13 +2963,14 @@ fn zirStructDecl(
2963 };2963 };
2964 errdefer wip_ty.cancel(ip, pt.tid);2964 errdefer wip_ty.cancel(ip, pt.tid);
29652965
2966 wip_ty.setName(ip, try sema.createTypeName(2966 const type_name = try sema.createTypeName(
2967 block,2967 block,
2968 small.name_strategy,2968 small.name_strategy,
2969 "struct",2969 "struct",
2970 inst,2970 inst,
2971 wip_ty.index,2971 wip_ty.index,
2972 ));2972 );
2973 wip_ty.setName(ip, type_name.name, type_name.nav);
29732974
2974 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{2975 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
2975 .parent = block.namespace.toOptional(),2976 .parent = block.namespace.toOptional(),
...@@ -3007,7 +3008,10 @@ pub fn createTypeName(...@@ -3007,7 +3008,10 @@ pub fn createTypeName(
3007 inst: ?Zir.Inst.Index,3008 inst: ?Zir.Inst.Index,
3008 /// This is used purely to give the type a unique name in the `anon` case.3009 /// This is used purely to give the type a unique name in the `anon` case.
3009 type_index: InternPool.Index,3010 type_index: InternPool.Index,
3010) !InternPool.NullTerminatedString {3011) !struct {
3012 name: InternPool.NullTerminatedString,
3013 nav: InternPool.Nav.Index.Optional,
3014} {
3011 const pt = sema.pt;3015 const pt = sema.pt;
3012 const zcu = pt.zcu;3016 const zcu = pt.zcu;
3013 const gpa = zcu.gpa;3017 const gpa = zcu.gpa;
...@@ -3015,7 +3019,10 @@ pub fn createTypeName(...@@ -3015,7 +3019,10 @@ pub fn createTypeName(
30153019
3016 switch (name_strategy) {3020 switch (name_strategy) {
3017 .anon => {}, // handled after switch3021 .anon => {}, // handled after switch
3018 .parent => return block.type_name_ctx,3022 .parent => return .{
3023 .name = block.type_name_ctx,
3024 .nav = sema.owner.unwrap().nav_val.toOptional(),
3025 },
3019 .func => func_strat: {3026 .func => func_strat: {
3020 const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail);3027 const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail);
3021 const zir_tags = sema.code.instructions.items(.tag);3028 const zir_tags = sema.code.instructions.items(.tag);
...@@ -3057,7 +3064,10 @@ pub fn createTypeName(...@@ -3057,7 +3064,10 @@ pub fn createTypeName(
3057 };3064 };
30583065
3059 try writer.writeByte(')');3066 try writer.writeByte(')');
3060 return ip.getOrPutString(gpa, pt.tid, buf.items, .no_embedded_nulls);3067 return .{
3068 .name = try ip.getOrPutString(gpa, pt.tid, buf.items, .no_embedded_nulls),
3069 .nav = .none,
3070 };
3061 },3071 },
3062 .dbg_var => {3072 .dbg_var => {
3063 // TODO: this logic is questionable. We ideally should be traversing the `Block` rather than relying on the order of AstGen instructions.3073 // TODO: this logic is questionable. We ideally should be traversing the `Block` rather than relying on the order of AstGen instructions.
...@@ -3066,9 +3076,12 @@ pub fn createTypeName(...@@ -3066,9 +3076,12 @@ pub fn createTypeName(
3066 const zir_data = sema.code.instructions.items(.data);3076 const zir_data = sema.code.instructions.items(.data);
3067 for (@intFromEnum(inst.?)..zir_tags.len) |i| switch (zir_tags[i]) {3077 for (@intFromEnum(inst.?)..zir_tags.len) |i| switch (zir_tags[i]) {
3068 .dbg_var_ptr, .dbg_var_val => if (zir_data[i].str_op.operand == ref) {3078 .dbg_var_ptr, .dbg_var_val => if (zir_data[i].str_op.operand == ref) {
3069 return ip.getOrPutStringFmt(gpa, pt.tid, "{}.{s}", .{3079 return .{
3070 block.type_name_ctx.fmt(ip), zir_data[i].str_op.getStr(sema.code),3080 .name = try ip.getOrPutStringFmt(gpa, pt.tid, "{}.{s}", .{
3071 }, .no_embedded_nulls);3081 block.type_name_ctx.fmt(ip), zir_data[i].str_op.getStr(sema.code),
3082 }, .no_embedded_nulls),
3083 .nav = .none,
3084 };
3072 },3085 },
3073 else => {},3086 else => {},
3074 };3087 };
...@@ -3086,9 +3099,12 @@ pub fn createTypeName(...@@ -3086,9 +3099,12 @@ pub fn createTypeName(
3086 // types appropriately. However, `@typeName` becomes a problem then. If we remove3099 // types appropriately. However, `@typeName` becomes a problem then. If we remove
3087 // that builtin from the language, we can consider this.3100 // that builtin from the language, we can consider this.
30883101
3089 return ip.getOrPutStringFmt(gpa, pt.tid, "{}__{s}_{d}", .{3102 return .{
3090 block.type_name_ctx.fmt(ip), anon_prefix, @intFromEnum(type_index),3103 .name = try ip.getOrPutStringFmt(gpa, pt.tid, "{}__{s}_{d}", .{
3091 }, .no_embedded_nulls);3104 block.type_name_ctx.fmt(ip), anon_prefix, @intFromEnum(type_index),
3105 }, .no_embedded_nulls),
3106 .nav = .none,
3107 };
3092}3108}
30933109
3094fn zirEnumDecl(3110fn zirEnumDecl(
...@@ -3209,7 +3225,7 @@ fn zirEnumDecl(...@@ -3209,7 +3225,7 @@ fn zirEnumDecl(
3209 inst,3225 inst,
3210 wip_ty.index,3226 wip_ty.index,
3211 );3227 );
3212 wip_ty.setName(ip, type_name);3228 wip_ty.setName(ip, type_name.name, type_name.nav);
32133229
3214 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{3230 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
3215 .parent = block.namespace.toOptional(),3231 .parent = block.namespace.toOptional(),
...@@ -3236,7 +3252,7 @@ fn zirEnumDecl(...@@ -3236,7 +3252,7 @@ fn zirEnumDecl(
3236 inst,3252 inst,
3237 tracked_inst,3253 tracked_inst,
3238 new_namespace_index,3254 new_namespace_index,
3239 type_name,3255 type_name.name,
3240 small,3256 small,
3241 body,3257 body,
3242 tag_type_ref,3258 tag_type_ref,
...@@ -3340,13 +3356,14 @@ fn zirUnionDecl(...@@ -3340,13 +3356,14 @@ fn zirUnionDecl(
3340 };3356 };
3341 errdefer wip_ty.cancel(ip, pt.tid);3357 errdefer wip_ty.cancel(ip, pt.tid);
33423358
3343 wip_ty.setName(ip, try sema.createTypeName(3359 const type_name = try sema.createTypeName(
3344 block,3360 block,
3345 small.name_strategy,3361 small.name_strategy,
3346 "union",3362 "union",
3347 inst,3363 inst,
3348 wip_ty.index,3364 wip_ty.index,
3349 ));3365 );
3366 wip_ty.setName(ip, type_name.name, type_name.nav);
33503367
3351 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{3368 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
3352 .parent = block.namespace.toOptional(),3369 .parent = block.namespace.toOptional(),
...@@ -3432,13 +3449,14 @@ fn zirOpaqueDecl(...@@ -3432,13 +3449,14 @@ fn zirOpaqueDecl(
3432 };3449 };
3433 errdefer wip_ty.cancel(ip, pt.tid);3450 errdefer wip_ty.cancel(ip, pt.tid);
34343451
3435 wip_ty.setName(ip, try sema.createTypeName(3452 const type_name = try sema.createTypeName(
3436 block,3453 block,
3437 small.name_strategy,3454 small.name_strategy,
3438 "opaque",3455 "opaque",
3439 inst,3456 inst,
3440 wip_ty.index,3457 wip_ty.index,
3441 ));3458 );
3459 wip_ty.setName(ip, type_name.name, type_name.nav);
34423460
3443 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{3461 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
3444 .parent = block.namespace.toOptional(),3462 .parent = block.namespace.toOptional(),
...@@ -20062,7 +20080,8 @@ fn structInitAnon(...@@ -20062,7 +20080,8 @@ fn structInitAnon(
20062 }, false)) {20080 }, false)) {
20063 .wip => |wip| ty: {20081 .wip => |wip| ty: {
20064 errdefer wip.cancel(ip, pt.tid);20082 errdefer wip.cancel(ip, pt.tid);
20065 wip.setName(ip, try sema.createTypeName(block, .anon, "struct", inst, wip.index));20083 const type_name = try sema.createTypeName(block, .anon, "struct", inst, wip.index);
20084 wip.setName(ip, type_name.name, type_name.nav);
2006620085
20067 const struct_type = ip.loadStructType(wip.index);20086 const struct_type = ip.loadStructType(wip.index);
2006820087
...@@ -21122,13 +21141,14 @@ fn zirReify(...@@ -21122,13 +21141,14 @@ fn zirReify(
21122 };21141 };
21123 errdefer wip_ty.cancel(ip, pt.tid);21142 errdefer wip_ty.cancel(ip, pt.tid);
2112421143
21125 wip_ty.setName(ip, try sema.createTypeName(21144 const type_name = try sema.createTypeName(
21126 block,21145 block,
21127 name_strategy,21146 name_strategy,
21128 "opaque",21147 "opaque",
21129 inst,21148 inst,
21130 wip_ty.index,21149 wip_ty.index,
21131 ));21150 );
21151 wip_ty.setName(ip, type_name.name, type_name.nav);
2113221152
21133 const new_namespace_index = try pt.createNamespace(.{21153 const new_namespace_index = try pt.createNamespace(.{
21134 .parent = block.namespace.toOptional(),21154 .parent = block.namespace.toOptional(),
...@@ -21327,13 +21347,14 @@ fn reifyEnum(...@@ -21327,13 +21347,14 @@ fn reifyEnum(
21327 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});21347 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});
21328 }21348 }
2132921349
21330 wip_ty.setName(ip, try sema.createTypeName(21350 const type_name = try sema.createTypeName(
21331 block,21351 block,
21332 name_strategy,21352 name_strategy,
21333 "enum",21353 "enum",
21334 inst,21354 inst,
21335 wip_ty.index,21355 wip_ty.index,
21336 ));21356 );
21357 wip_ty.setName(ip, type_name.name, type_name.nav);
2133721358
21338 const new_namespace_index = try pt.createNamespace(.{21359 const new_namespace_index = try pt.createNamespace(.{
21339 .parent = block.namespace.toOptional(),21360 .parent = block.namespace.toOptional(),
...@@ -21498,7 +21519,7 @@ fn reifyUnion(...@@ -21498,7 +21519,7 @@ fn reifyUnion(
21498 inst,21519 inst,
21499 wip_ty.index,21520 wip_ty.index,
21500 );21521 );
21501 wip_ty.setName(ip, type_name);21522 wip_ty.setName(ip, type_name.name, type_name.nav);
2150221523
21503 const field_types = try sema.arena.alloc(InternPool.Index, fields_len);21524 const field_types = try sema.arena.alloc(InternPool.Index, fields_len);
21504 const field_aligns = if (any_aligns) try sema.arena.alloc(InternPool.Alignment, fields_len) else undefined;21525 const field_aligns = if (any_aligns) try sema.arena.alloc(InternPool.Alignment, fields_len) else undefined;
...@@ -21591,7 +21612,7 @@ fn reifyUnion(...@@ -21591,7 +21612,7 @@ fn reifyUnion(
21591 }21612 }
21592 }21613 }
2159321614
21594 const enum_tag_ty = try sema.generateUnionTagTypeSimple(block, field_names.keys(), wip_ty.index, type_name);21615 const enum_tag_ty = try sema.generateUnionTagTypeSimple(block, field_names.keys(), wip_ty.index, type_name.name);
21595 break :tag_ty .{ enum_tag_ty, false };21616 break :tag_ty .{ enum_tag_ty, false };
21596 };21617 };
21597 errdefer if (!has_explicit_tag) ip.remove(pt.tid, enum_tag_ty); // remove generated tag type on error21618 errdefer if (!has_explicit_tag) ip.remove(pt.tid, enum_tag_ty); // remove generated tag type on error
...@@ -21853,13 +21874,14 @@ fn reifyStruct(...@@ -21853,13 +21874,14 @@ fn reifyStruct(
21853 };21874 };
21854 errdefer wip_ty.cancel(ip, pt.tid);21875 errdefer wip_ty.cancel(ip, pt.tid);
2185521876
21856 wip_ty.setName(ip, try sema.createTypeName(21877 const type_name = try sema.createTypeName(
21857 block,21878 block,
21858 name_strategy,21879 name_strategy,
21859 "struct",21880 "struct",
21860 inst,21881 inst,
21861 wip_ty.index,21882 wip_ty.index,
21862 ));21883 );
21884 wip_ty.setName(ip, type_name.name, type_name.nav);
2186321885
21864 const struct_type = ip.loadStructType(wip_ty.index);21886 const struct_type = ip.loadStructType(wip_ty.index);
2186521887
src/Sema/LowerZon.zig+3-2
...@@ -157,13 +157,14 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter...@@ -157,13 +157,14 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter
157 )) {157 )) {
158 .wip => |wip| ty: {158 .wip => |wip| ty: {
159 errdefer wip.cancel(ip, pt.tid);159 errdefer wip.cancel(ip, pt.tid);
160 wip.setName(ip, try self.sema.createTypeName(160 const type_name = try self.sema.createTypeName(
161 self.block,161 self.block,
162 .anon,162 .anon,
163 "struct",163 "struct",
164 self.base_node_inst.resolve(ip),164 self.base_node_inst.resolve(ip),
165 wip.index,165 wip.index,
166 ));166 );
167 wip.setName(ip, type_name.name, type_name.nav);
167168
168 const struct_type = ip.loadStructType(wip.index);169 const struct_type = ip.loadStructType(wip.index);
169170
src/Zcu/PerThread.zig+4-4
...@@ -1787,7 +1787,7 @@ fn createFileRootStruct(...@@ -1787,7 +1787,7 @@ fn createFileRootStruct(
1787 };1787 };
1788 errdefer wip_ty.cancel(ip, pt.tid);1788 errdefer wip_ty.cancel(ip, pt.tid);
17891789
1790 wip_ty.setName(ip, try file.internFullyQualifiedName(pt));1790 wip_ty.setName(ip, try file.internFullyQualifiedName(pt), .none);
1791 ip.namespacePtr(namespace_index).owner_type = wip_ty.index;1791 ip.namespacePtr(namespace_index).owner_type = wip_ty.index;
17921792
1793 if (zcu.comp.incremental) {1793 if (zcu.comp.incremental) {
...@@ -3976,7 +3976,7 @@ fn recreateStructType(...@@ -3976,7 +3976,7 @@ fn recreateStructType(
3976 };3976 };
3977 errdefer wip_ty.cancel(ip, pt.tid);3977 errdefer wip_ty.cancel(ip, pt.tid);
39783978
3979 wip_ty.setName(ip, struct_obj.name);3979 wip_ty.setName(ip, struct_obj.name, struct_obj.name_nav);
3980 try pt.addDependency(.wrap(.{ .type = wip_ty.index }), .{ .src_hash = key.zir_index });3980 try pt.addDependency(.wrap(.{ .type = wip_ty.index }), .{ .src_hash = key.zir_index });
3981 zcu.namespacePtr(struct_obj.namespace).owner_type = wip_ty.index;3981 zcu.namespacePtr(struct_obj.namespace).owner_type = wip_ty.index;
3982 // No need to re-scan the namespace -- `zirStructDecl` will ultimately do that if the type is still alive.3982 // No need to re-scan the namespace -- `zirStructDecl` will ultimately do that if the type is still alive.
...@@ -4068,7 +4068,7 @@ fn recreateUnionType(...@@ -4068,7 +4068,7 @@ fn recreateUnionType(
4068 };4068 };
4069 errdefer wip_ty.cancel(ip, pt.tid);4069 errdefer wip_ty.cancel(ip, pt.tid);
40704070
4071 wip_ty.setName(ip, union_obj.name);4071 wip_ty.setName(ip, union_obj.name, union_obj.name_nav);
4072 try pt.addDependency(.wrap(.{ .type = wip_ty.index }), .{ .src_hash = key.zir_index });4072 try pt.addDependency(.wrap(.{ .type = wip_ty.index }), .{ .src_hash = key.zir_index });
4073 zcu.namespacePtr(namespace_index).owner_type = wip_ty.index;4073 zcu.namespacePtr(namespace_index).owner_type = wip_ty.index;
4074 // No need to re-scan the namespace -- `zirUnionDecl` will ultimately do that if the type is still alive.4074 // No need to re-scan the namespace -- `zirUnionDecl` will ultimately do that if the type is still alive.
...@@ -4177,7 +4177,7 @@ fn recreateEnumType(...@@ -4177,7 +4177,7 @@ fn recreateEnumType(
4177 var done = true;4177 var done = true;
4178 errdefer if (!done) wip_ty.cancel(ip, pt.tid);4178 errdefer if (!done) wip_ty.cancel(ip, pt.tid);
41794179
4180 wip_ty.setName(ip, enum_obj.name);4180 wip_ty.setName(ip, enum_obj.name, enum_obj.name_nav);
41814181
4182 zcu.namespacePtr(namespace_index).owner_type = wip_ty.index;4182 zcu.namespacePtr(namespace_index).owner_type = wip_ty.index;
4183 // No need to re-scan the namespace -- `zirEnumDecl` will ultimately do that if the type is still alive.4183 // No need to re-scan the namespace -- `zirEnumDecl` will ultimately do that if the type is still alive.