aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2024-02-16 03:13:25 +0100
committerAndrew Kelley <andrew@ziglang.org>2024-02-16 00:27:25 -0800
commit6f08e172299320a3b243998878b38b0b3f43d8d5 (patch)
tree22ca949d513aa57651081ce831875e322666eb2a /src/type.zig
parent0183b44bb10751c46bd520e673726a66c027b477 (diff)
downloadzig-6f08e172299320a3b243998878b38b0b3f43d8d5.tar.gz
zig-6f08e172299320a3b243998878b38b0b3f43d8d5.zip
InternPool: make more use of `NullTerminatedString.Slice`
This should avoid the random pointer invalidation crashes. Closes #18954
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/type.zig b/src/type.zig
index 43eaa9132a..a6265692c2 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2908,22 +2908,21 @@ pub const Type = struct {
// Asserts that `ty` is an error set and not `anyerror`.
// Asserts that `ty` is resolved if it is an inferred error set.
- pub fn errorSetNames(ty: Type, mod: *Module) []const InternPool.NullTerminatedString {
+ pub fn errorSetNames(ty: Type, mod: *Module) InternPool.NullTerminatedString.Slice {
const ip = &mod.intern_pool;
return switch (ip.indexToKey(ty.toIntern())) {
- .error_set_type => |x| x.names.get(ip),
+ .error_set_type => |x| x.names,
.inferred_error_set_type => |i| switch (ip.funcIesResolved(i).*) {
.none => unreachable, // unresolved inferred error set
.anyerror_type => unreachable,
- else => |t| ip.indexToKey(t).error_set_type.names.get(ip),
+ else => |t| ip.indexToKey(t).error_set_type.names,
},
else => unreachable,
};
}
- pub fn enumFields(ty: Type, mod: *Module) []const InternPool.NullTerminatedString {
- const ip = &mod.intern_pool;
- return ip.indexToKey(ty.toIntern()).enum_type.names.get(ip);
+ pub fn enumFields(ty: Type, mod: *Module) InternPool.NullTerminatedString.Slice {
+ return mod.intern_pool.indexToKey(ty.toIntern()).enum_type.names;
}
pub fn enumFieldCount(ty: Type, mod: *Module) usize {