diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-07-09 18:48:37 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-07-10 11:10:49 -0400 |
| commit | 667b4f9054cd0d4c8e9912bddc18049d09107678 (patch) | |
| tree | 8049d0f1dab34e4bf5994bd4aeacbd1ba7aa804d /src/Type.zig | |
| parent | 95d9292a7a09ed883e65510ec054619747315c48 (diff) | |
| download | zig-667b4f9054cd0d4c8e9912bddc18049d09107678.tar.gz zig-667b4f9054cd0d4c8e9912bddc18049d09107678.zip | |
Zcu: cache fully qualified name on Decl
This avoids needing to mutate the intern pool from backends.
Diffstat (limited to 'src/Type.zig')
| -rw-r--r-- | src/Type.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Type.zig b/src/Type.zig index 57ac2310d5..b22f8650ab 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -268,10 +268,10 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error return; }, .inferred_error_set_type => |func_index| { - try writer.writeAll("@typeInfo(@typeInfo(@TypeOf("); const owner_decl = mod.funcOwnerDeclPtr(func_index); - try owner_decl.renderFullyQualifiedName(mod, writer); - try writer.writeAll(")).Fn.return_type.?).ErrorUnion.error_set"); + try writer.print("@typeInfo(@typeInfo(@TypeOf({})).Fn.return_type.?).ErrorUnion.error_set", .{ + owner_decl.fqn.fmt(ip), + }); }, .error_set_type => |error_set_type| { const names = error_set_type.names; @@ -334,7 +334,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error const struct_type = ip.loadStructType(ty.toIntern()); if (struct_type.decl.unwrap()) |decl_index| { const decl = mod.declPtr(decl_index); - try decl.renderFullyQualifiedName(mod, writer); + try writer.print("{}", .{decl.fqn.fmt(ip)}); } else if (ip.loadStructType(ty.toIntern()).namespace.unwrap()) |namespace_index| { const namespace = mod.namespacePtr(namespace_index); try namespace.renderFullyQualifiedName(mod, .empty, writer); @@ -367,15 +367,15 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error .union_type => { const decl = mod.declPtr(ip.loadUnionType(ty.toIntern()).decl); - try decl.renderFullyQualifiedName(mod, writer); + try writer.print("{}", .{decl.fqn.fmt(ip)}); }, .opaque_type => { const decl = mod.declPtr(ip.loadOpaqueType(ty.toIntern()).decl); - try decl.renderFullyQualifiedName(mod, writer); + try writer.print("{}", .{decl.fqn.fmt(ip)}); }, .enum_type => { const decl = mod.declPtr(ip.loadEnumType(ty.toIntern()).decl); - try decl.renderFullyQualifiedName(mod, writer); + try writer.print("{}", .{decl.fqn.fmt(ip)}); }, .func_type => |fn_info| { if (fn_info.is_noinline) { |
