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 {
32493249 name: NullTerminatedString,
32503250 /// Represents the declarations inside this union.
32513251 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,
32523255 /// The enum tag type.
32533256 enum_tag_ty: Index,
32543257 /// List of field types in declaration order.
......@@ -3567,6 +3570,7 @@ pub fn loadUnionType(ip: *const InternPool, index: Index) LoadedUnionType {
35673570 .tid = unwrapped_index.tid,
35683571 .extra_index = data,
35693572 .name = type_union.data.name,
3573 .name_nav = type_union.data.name_nav,
35703574 .namespace = type_union.data.namespace,
35713575 .enum_tag_ty = type_union.data.tag_ty,
35723576 .field_types = field_types,
......@@ -3584,6 +3588,9 @@ pub const LoadedStructType = struct {
35843588 /// The name of this struct type.
35853589 name: NullTerminatedString,
35863590 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,
35873594 /// Index of the `struct_decl` or `reify` ZIR instruction.
35883595 zir_index: TrackedInst.Index,
35893596 layout: std.builtin.Type.ContainerLayout,
......@@ -4173,6 +4180,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
41734180 switch (item.tag) {
41744181 .type_struct => {
41754182 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").?]);
41764184 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "namespace").?]);
41774185 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);
41784186 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 {
42594267 .tid = unwrapped_index.tid,
42604268 .extra_index = item.data,
42614269 .name = name,
4270 .name_nav = name_nav,
42624271 .namespace = namespace,
42634272 .zir_index = zir_index,
42644273 .layout = if (flags.is_extern) .@"extern" else .auto,
......@@ -4275,6 +4284,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
42754284 },
42764285 .type_struct_packed, .type_struct_packed_inits => {
42774286 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").?]);
42784288 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "zir_index").?]);
42794289 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "fields_len").?];
42804290 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 {
43214331 .tid = unwrapped_index.tid,
43224332 .extra_index = item.data,
43234333 .name = name,
4334 .name_nav = name_nav,
43244335 .namespace = namespace,
43254336 .zir_index = zir_index,
43264337 .layout = .@"packed",
......@@ -4345,6 +4356,9 @@ pub const LoadedEnumType = struct {
43454356 name: NullTerminatedString,
43464357 /// Represents the declarations inside this enum.
43474358 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,
43484362 /// An integer type which is used for the numerical value of the enum.
43494363 /// This field is present regardless of whether the enum has an
43504364 /// explicitly provided tag type or auto-numbered.
......@@ -4428,6 +4442,7 @@ pub fn loadEnumType(ip: *const InternPool, index: Index) LoadedEnumType {
44284442 } else extra.data.captures_len;
44294443 return .{
44304444 .name = extra.data.name,
4445 .name_nav = extra.data.name_nav,
44314446 .namespace = extra.data.namespace,
44324447 .tag_ty = extra.data.int_tag_type,
44334448 .names = .{
......@@ -4462,6 +4477,7 @@ pub fn loadEnumType(ip: *const InternPool, index: Index) LoadedEnumType {
44624477 } else extra.data.captures_len;
44634478 return .{
44644479 .name = extra.data.name,
4480 .name_nav = extra.data.name_nav,
44654481 .namespace = extra.data.namespace,
44664482 .tag_ty = extra.data.int_tag_type,
44674483 .names = .{
......@@ -4493,6 +4509,9 @@ pub const LoadedOpaqueType = struct {
44934509 // TODO: the non-fqn will be needed by the new dwarf structure
44944510 /// The name of this opaque type.
44954511 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,
44964515 /// Index of the `opaque_decl` or `reify` instruction.
44974516 zir_index: TrackedInst.Index,
44984517 captures: CaptureValue.Slice,
......@@ -4509,6 +4528,7 @@ pub fn loadOpaqueType(ip: *const InternPool, index: Index) LoadedOpaqueType {
45094528 extra.data.captures_len;
45104529 return .{
45114530 .name = extra.data.name,
4531 .name_nav = extra.data.name_nav,
45124532 .namespace = extra.data.namespace,
45134533 .zir_index = extra.data.zir_index,
45144534 .captures = .{
......@@ -6022,6 +6042,7 @@ pub const Tag = enum(u8) {
60226042 /// 4. field align: Alignment for each field; declaration order
60236043 pub const TypeUnion = struct {
60246044 name: NullTerminatedString,
6045 name_nav: Nav.Index.Optional,
60256046 flags: Flags,
60266047 /// This could be provided through the tag type, but it is more convenient
60276048 /// to store it directly. This is also necessary for `dumpStatsFallible` to
......@@ -6061,6 +6082,7 @@ pub const Tag = enum(u8) {
60616082 /// 5. init: Index for each fields_len // if tag is type_struct_packed_inits
60626083 pub const TypeStructPacked = struct {
60636084 name: NullTerminatedString,
6085 name_nav: Nav.Index.Optional,
60646086 zir_index: TrackedInst.Index,
60656087 fields_len: u32,
60666088 namespace: NamespaceIndex,
......@@ -6108,6 +6130,7 @@ pub const Tag = enum(u8) {
61086130 /// 8. field_offset: u32 // for each field in declared order, undef until layout_resolved
61096131 pub const TypeStruct = struct {
61106132 name: NullTerminatedString,
6133 name_nav: Nav.Index.Optional,
61116134 zir_index: TrackedInst.Index,
61126135 namespace: NamespaceIndex,
61136136 fields_len: u32,
......@@ -6151,6 +6174,7 @@ pub const Tag = enum(u8) {
61516174 /// 0. capture: CaptureValue // for each `captures_len`
61526175 pub const TypeOpaque = struct {
61536176 name: NullTerminatedString,
6177 name_nav: Nav.Index.Optional,
61546178 /// Contains the declarations inside this opaque.
61556179 namespace: NamespaceIndex,
61566180 /// The index of the `opaque_decl` instruction.
......@@ -6429,6 +6453,7 @@ pub const Array = struct {
64296453/// 4. tag value: Index for each fields_len; declaration order
64306454pub const EnumExplicit = struct {
64316455 name: NullTerminatedString,
6456 name_nav: Nav.Index.Optional,
64326457 /// `std.math.maxInt(u32)` indicates this type is reified.
64336458 captures_len: u32,
64346459 namespace: NamespaceIndex,
......@@ -6454,6 +6479,7 @@ pub const EnumExplicit = struct {
64546479/// 3. field name: NullTerminatedString for each fields_len; declaration order
64556480pub const EnumAuto = struct {
64566481 name: NullTerminatedString,
6482 name_nav: Nav.Index.Optional,
64576483 /// `std.math.maxInt(u32)` indicates this type is reified.
64586484 captures_len: u32,
64596485 namespace: NamespaceIndex,
......@@ -8666,6 +8692,7 @@ pub fn getUnionType(
86668692 .size = std.math.maxInt(u32),
86678693 .padding = std.math.maxInt(u32),
86688694 .name = undefined, // set by `finish`
8695 .name_nav = undefined, // set by `finish`
86698696 .namespace = undefined, // set by `finish`
86708697 .tag_ty = ini.enum_tag_ty,
86718698 .zir_index = switch (ini.key) {
......@@ -8717,6 +8744,7 @@ pub fn getUnionType(
87178744 .tid = tid,
87188745 .index = gop.put(),
87198746 .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").?,
87208748 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeUnion, "namespace").?,
87218749 } };
87228750}
......@@ -8726,15 +8754,20 @@ pub const WipNamespaceType = struct {
87268754 index: Index,
87278755 type_name_extra_index: u32,
87288756 namespace_extra_index: u32,
8757 name_nav_extra_index: u32,
87298758
87308759 pub fn setName(
87318760 wip: WipNamespaceType,
87328761 ip: *InternPool,
87338762 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,
87348766 ) void {
87358767 const extra = ip.getLocalShared(wip.tid).extra.acquire();
87368768 const extra_items = extra.view().items(.@"0");
87378769 extra_items[wip.type_name_extra_index] = @intFromEnum(type_name);
8770 extra_items[wip.name_nav_extra_index] = @intFromEnum(name_nav);
87388771 }
87398772
87408773 pub fn finish(
......@@ -8843,6 +8876,7 @@ pub fn getStructType(
88438876 ini.fields_len); // inits
88448877 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeStructPacked{
88458878 .name = undefined, // set by `finish`
8879 .name_nav = undefined, // set by `finish`
88468880 .zir_index = zir_index,
88478881 .fields_len = ini.fields_len,
88488882 .namespace = undefined, // set by `finish`
......@@ -8887,6 +8921,7 @@ pub fn getStructType(
88878921 .tid = tid,
88888922 .index = gop.put(),
88898923 .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").?,
88908925 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?,
88918926 } };
88928927 },
......@@ -8909,6 +8944,7 @@ pub fn getStructType(
89098944 1); // names_map
89108945 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeStruct{
89118946 .name = undefined, // set by `finish`
8947 .name_nav = undefined, // set by `finish`
89128948 .zir_index = zir_index,
89138949 .namespace = undefined, // set by `finish`
89148950 .fields_len = ini.fields_len,
......@@ -8977,6 +9013,7 @@ pub fn getStructType(
89779013 .tid = tid,
89789014 .index = gop.put(),
89799015 .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").?,
89809017 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeStruct, "namespace").?,
89819018 } };
89829019}
......@@ -9766,6 +9803,7 @@ pub const WipEnumType = struct {
97669803 tag_ty_index: u32,
97679804 type_name_extra_index: u32,
97689805 namespace_extra_index: u32,
9806 name_nav_extra_index: u32,
97699807 names_map: MapIndex,
97709808 names_start: u32,
97719809 values_map: OptionalMapIndex,
......@@ -9775,10 +9813,13 @@ pub const WipEnumType = struct {
97759813 wip: WipEnumType,
97769814 ip: *InternPool,
97779815 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,
97789818 ) void {
97799819 const extra = ip.getLocalShared(wip.tid).extra.acquire();
97809820 const extra_items = extra.view().items(.@"0");
97819821 extra_items[wip.type_name_extra_index] = @intFromEnum(type_name);
9822 extra_items[wip.name_nav_extra_index] = @intFromEnum(name_nav);
97829823 }
97839824
97849825 pub fn prepare(
......@@ -9893,6 +9934,7 @@ pub fn getEnumType(
98939934
98949935 const extra_index = addExtraAssumeCapacity(extra, EnumAuto{
98959936 .name = undefined, // set by `prepare`
9937 .name_nav = undefined, // set by `prepare`
98969938 .captures_len = switch (ini.key) {
98979939 inline .declared, .declared_owned_captures => |d| @intCast(d.captures.len),
98989940 .reified => std.math.maxInt(u32),
......@@ -9921,6 +9963,7 @@ pub fn getEnumType(
99219963 .index = gop.put(),
99229964 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumAuto, "int_tag_type").?,
99239965 .type_name_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "name").?,
9966 .name_nav_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "name_nav").?,
99249967 .namespace_extra_index = extra_index + std.meta.fieldIndex(EnumAuto, "namespace").?,
99259968 .names_map = names_map,
99269969 .names_start = @intCast(names_start),
......@@ -9950,6 +9993,7 @@ pub fn getEnumType(
99509993
99519994 const extra_index = addExtraAssumeCapacity(extra, EnumExplicit{
99529995 .name = undefined, // set by `prepare`
9996 .name_nav = undefined, // set by `prepare`
99539997 .captures_len = switch (ini.key) {
99549998 inline .declared, .declared_owned_captures => |d| @intCast(d.captures.len),
99559999 .reified => std.math.maxInt(u32),
......@@ -9987,6 +10031,7 @@ pub fn getEnumType(
998710031 .index = gop.put(),
998810032 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumExplicit, "int_tag_type").?,
998910033 .type_name_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "name").?,
10034 .name_nav_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "name_nav").?,
999010035 .namespace_extra_index = extra_index + std.meta.fieldIndex(EnumExplicit, "namespace").?,
999110036 .names_map = names_map,
999210037 .names_start = @intCast(names_start),
......@@ -10055,6 +10100,7 @@ pub fn getGeneratedTagEnumType(
1005510100 .tag = .type_enum_auto,
1005610101 .data = addExtraAssumeCapacity(extra, EnumAuto{
1005710102 .name = ini.name,
10103 .name_nav = .none,
1005810104 .captures_len = 0,
1005910105 .namespace = namespace,
1006010106 .int_tag_type = ini.tag_ty,
......@@ -10088,6 +10134,7 @@ pub fn getGeneratedTagEnumType(
1008810134 },
1008910135 .data = addExtraAssumeCapacity(extra, EnumExplicit{
1009010136 .name = ini.name,
10137 .name_nav = .none,
1009110138 .captures_len = 0,
1009210139 .namespace = namespace,
1009310140 .int_tag_type = ini.tag_ty,
......@@ -10161,6 +10208,7 @@ pub fn getOpaqueType(
1016110208 });
1016210209 const extra_index = addExtraAssumeCapacity(extra, Tag.TypeOpaque{
1016310210 .name = undefined, // set by `finish`
10211 .name_nav = undefined, // set by `finish`
1016410212 .namespace = undefined, // set by `finish`
1016510213 .zir_index = switch (ini.key) {
1016610214 inline else => |x| x.zir_index,
......@@ -10183,6 +10231,7 @@ pub fn getOpaqueType(
1018310231 .tid = tid,
1018410232 .index = gop.put(),
1018510233 .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").?,
1018610235 .namespace_extra_index = extra_index + std.meta.fieldIndex(Tag.TypeOpaque, "namespace").?,
1018710236 },
1018810237 };
......@@ -10299,6 +10348,7 @@ fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 {
1029910348 extra.appendAssumeCapacity(.{switch (field.type) {
1030010349 Index,
1030110350 Nav.Index,
10351 Nav.Index.Optional,
1030210352 NamespaceIndex,
1030310353 OptionalNamespaceIndex,
1030410354 MapIndex,
......@@ -10361,6 +10411,7 @@ fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { dat
1036110411 @field(result, field.name) = switch (field.type) {
1036210412 Index,
1036310413 Nav.Index,
10414 Nav.Index.Optional,
1036410415 NamespaceIndex,
1036510416 OptionalNamespaceIndex,
1036610417 MapIndex,
src/Sema.zig+48-26
......@@ -2963,13 +2963,14 @@ fn zirStructDecl(
29632963 };
29642964 errdefer wip_ty.cancel(ip, pt.tid);
29652965
2966 wip_ty.setName(ip, try sema.createTypeName(
2966 const type_name = try sema.createTypeName(
29672967 block,
29682968 small.name_strategy,
29692969 "struct",
29702970 inst,
29712971 wip_ty.index,
2972 ));
2972 );
2973 wip_ty.setName(ip, type_name.name, type_name.nav);
29732974
29742975 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
29752976 .parent = block.namespace.toOptional(),
......@@ -3007,7 +3008,10 @@ pub fn createTypeName(
30073008 inst: ?Zir.Inst.Index,
30083009 /// This is used purely to give the type a unique name in the `anon` case.
30093010 type_index: InternPool.Index,
3010) !InternPool.NullTerminatedString {
3011) !struct {
3012 name: InternPool.NullTerminatedString,
3013 nav: InternPool.Nav.Index.Optional,
3014} {
30113015 const pt = sema.pt;
30123016 const zcu = pt.zcu;
30133017 const gpa = zcu.gpa;
......@@ -3015,7 +3019,10 @@ pub fn createTypeName(
30153019
30163020 switch (name_strategy) {
30173021 .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 },
30193026 .func => func_strat: {
30203027 const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail);
30213028 const zir_tags = sema.code.instructions.items(.tag);
......@@ -3057,7 +3064,10 @@ pub fn createTypeName(
30573064 };
30583065
30593066 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 };
30613071 },
30623072 .dbg_var => {
30633073 // 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(
30663076 const zir_data = sema.code.instructions.items(.data);
30673077 for (@intFromEnum(inst.?)..zir_tags.len) |i| switch (zir_tags[i]) {
30683078 .dbg_var_ptr, .dbg_var_val => if (zir_data[i].str_op.operand == ref) {
3069 return ip.getOrPutStringFmt(gpa, pt.tid, "{}.{s}", .{
3070 block.type_name_ctx.fmt(ip), zir_data[i].str_op.getStr(sema.code),
3071 }, .no_embedded_nulls);
3079 return .{
3080 .name = try ip.getOrPutStringFmt(gpa, pt.tid, "{}.{s}", .{
3081 block.type_name_ctx.fmt(ip), zir_data[i].str_op.getStr(sema.code),
3082 }, .no_embedded_nulls),
3083 .nav = .none,
3084 };
30723085 },
30733086 else => {},
30743087 };
......@@ -3086,9 +3099,12 @@ pub fn createTypeName(
30863099 // types appropriately. However, `@typeName` becomes a problem then. If we remove
30873100 // that builtin from the language, we can consider this.
30883101
3089 return ip.getOrPutStringFmt(gpa, pt.tid, "{}__{s}_{d}", .{
3090 block.type_name_ctx.fmt(ip), anon_prefix, @intFromEnum(type_index),
3091 }, .no_embedded_nulls);
3102 return .{
3103 .name = try ip.getOrPutStringFmt(gpa, pt.tid, "{}__{s}_{d}", .{
3104 block.type_name_ctx.fmt(ip), anon_prefix, @intFromEnum(type_index),
3105 }, .no_embedded_nulls),
3106 .nav = .none,
3107 };
30923108}
30933109
30943110fn zirEnumDecl(
......@@ -3209,7 +3225,7 @@ fn zirEnumDecl(
32093225 inst,
32103226 wip_ty.index,
32113227 );
3212 wip_ty.setName(ip, type_name);
3228 wip_ty.setName(ip, type_name.name, type_name.nav);
32133229
32143230 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
32153231 .parent = block.namespace.toOptional(),
......@@ -3236,7 +3252,7 @@ fn zirEnumDecl(
32363252 inst,
32373253 tracked_inst,
32383254 new_namespace_index,
3239 type_name,
3255 type_name.name,
32403256 small,
32413257 body,
32423258 tag_type_ref,
......@@ -3340,13 +3356,14 @@ fn zirUnionDecl(
33403356 };
33413357 errdefer wip_ty.cancel(ip, pt.tid);
33423358
3343 wip_ty.setName(ip, try sema.createTypeName(
3359 const type_name = try sema.createTypeName(
33443360 block,
33453361 small.name_strategy,
33463362 "union",
33473363 inst,
33483364 wip_ty.index,
3349 ));
3365 );
3366 wip_ty.setName(ip, type_name.name, type_name.nav);
33503367
33513368 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
33523369 .parent = block.namespace.toOptional(),
......@@ -3432,13 +3449,14 @@ fn zirOpaqueDecl(
34323449 };
34333450 errdefer wip_ty.cancel(ip, pt.tid);
34343451
3435 wip_ty.setName(ip, try sema.createTypeName(
3452 const type_name = try sema.createTypeName(
34363453 block,
34373454 small.name_strategy,
34383455 "opaque",
34393456 inst,
34403457 wip_ty.index,
3441 ));
3458 );
3459 wip_ty.setName(ip, type_name.name, type_name.nav);
34423460
34433461 const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{
34443462 .parent = block.namespace.toOptional(),
......@@ -20062,7 +20080,8 @@ fn structInitAnon(
2006220080 }, false)) {
2006320081 .wip => |wip| ty: {
2006420082 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
2006720086 const struct_type = ip.loadStructType(wip.index);
2006820087
......@@ -21122,13 +21141,14 @@ fn zirReify(
2112221141 };
2112321142 errdefer wip_ty.cancel(ip, pt.tid);
2112421143
21125 wip_ty.setName(ip, try sema.createTypeName(
21144 const type_name = try sema.createTypeName(
2112621145 block,
2112721146 name_strategy,
2112821147 "opaque",
2112921148 inst,
2113021149 wip_ty.index,
21131 ));
21150 );
21151 wip_ty.setName(ip, type_name.name, type_name.nav);
2113221152
2113321153 const new_namespace_index = try pt.createNamespace(.{
2113421154 .parent = block.namespace.toOptional(),
......@@ -21327,13 +21347,14 @@ fn reifyEnum(
2132721347 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});
2132821348 }
2132921349
21330 wip_ty.setName(ip, try sema.createTypeName(
21350 const type_name = try sema.createTypeName(
2133121351 block,
2133221352 name_strategy,
2133321353 "enum",
2133421354 inst,
2133521355 wip_ty.index,
21336 ));
21356 );
21357 wip_ty.setName(ip, type_name.name, type_name.nav);
2133721358
2133821359 const new_namespace_index = try pt.createNamespace(.{
2133921360 .parent = block.namespace.toOptional(),
......@@ -21498,7 +21519,7 @@ fn reifyUnion(
2149821519 inst,
2149921520 wip_ty.index,
2150021521 );
21501 wip_ty.setName(ip, type_name);
21522 wip_ty.setName(ip, type_name.name, type_name.nav);
2150221523
2150321524 const field_types = try sema.arena.alloc(InternPool.Index, fields_len);
2150421525 const field_aligns = if (any_aligns) try sema.arena.alloc(InternPool.Alignment, fields_len) else undefined;
......@@ -21591,7 +21612,7 @@ fn reifyUnion(
2159121612 }
2159221613 }
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);
2159521616 break :tag_ty .{ enum_tag_ty, false };
2159621617 };
2159721618 errdefer if (!has_explicit_tag) ip.remove(pt.tid, enum_tag_ty); // remove generated tag type on error
......@@ -21853,13 +21874,14 @@ fn reifyStruct(
2185321874 };
2185421875 errdefer wip_ty.cancel(ip, pt.tid);
2185521876
21856 wip_ty.setName(ip, try sema.createTypeName(
21877 const type_name = try sema.createTypeName(
2185721878 block,
2185821879 name_strategy,
2185921880 "struct",
2186021881 inst,
2186121882 wip_ty.index,
21862 ));
21883 );
21884 wip_ty.setName(ip, type_name.name, type_name.nav);
2186321885
2186421886 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
157157 )) {
158158 .wip => |wip| ty: {
159159 errdefer wip.cancel(ip, pt.tid);
160 wip.setName(ip, try self.sema.createTypeName(
160 const type_name = try self.sema.createTypeName(
161161 self.block,
162162 .anon,
163163 "struct",
164164 self.base_node_inst.resolve(ip),
165165 wip.index,
166 ));
166 );
167 wip.setName(ip, type_name.name, type_name.nav);
167168
168169 const struct_type = ip.loadStructType(wip.index);
169170
src/Zcu/PerThread.zig+4-4
......@@ -1787,7 +1787,7 @@ fn createFileRootStruct(
17871787 };
17881788 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);
17911791 ip.namespacePtr(namespace_index).owner_type = wip_ty.index;
17921792
17931793 if (zcu.comp.incremental) {
......@@ -3976,7 +3976,7 @@ fn recreateStructType(
39763976 };
39773977 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);
39803980 try pt.addDependency(.wrap(.{ .type = wip_ty.index }), .{ .src_hash = key.zir_index });
39813981 zcu.namespacePtr(struct_obj.namespace).owner_type = wip_ty.index;
39823982 // No need to re-scan the namespace -- `zirStructDecl` will ultimately do that if the type is still alive.
......@@ -4068,7 +4068,7 @@ fn recreateUnionType(
40684068 };
40694069 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);
40724072 try pt.addDependency(.wrap(.{ .type = wip_ty.index }), .{ .src_hash = key.zir_index });
40734073 zcu.namespacePtr(namespace_index).owner_type = wip_ty.index;
40744074 // No need to re-scan the namespace -- `zirUnionDecl` will ultimately do that if the type is still alive.
......@@ -4177,7 +4177,7 @@ fn recreateEnumType(
41774177 var done = true;
41784178 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
41824182 zcu.namespacePtr(namespace_index).owner_type = wip_ty.index;
41834183 // No need to re-scan the namespace -- `zirEnumDecl` will ultimately do that if the type is still alive.