aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-02 20:01:32 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:40:03 -0700
commit50f33734c6cec10a0132644c08ee443c2dd224e2 (patch)
treed5192de4e7f849226b93cf03095a5ac7e54c3782 /src/type.zig
parent00f82f1c46126f1fc6655c6142ef16e8e5afbf4e (diff)
downloadzig-50f33734c6cec10a0132644c08ee443c2dd224e2.tar.gz
zig-50f33734c6cec10a0132644c08ee443c2dd224e2.zip
stage2: isGenericPoison InternPool awareness
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/type.zig b/src/type.zig
index 94fd4c2eaf..9f14619c2c 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -727,8 +727,8 @@ pub const Type = struct {
const a_info = a.fnInfo();
const b_info = b.fnInfo();
- if (a_info.return_type.tag() != .generic_poison and
- b_info.return_type.tag() != .generic_poison and
+ if (!a_info.return_type.isGenericPoison() and
+ !b_info.return_type.isGenericPoison() and
!eql(a_info.return_type, b_info.return_type, mod))
return false;
@@ -758,8 +758,8 @@ pub const Type = struct {
if (a_info.comptime_params[i] != b_info.comptime_params[i])
return false;
- if (a_param_ty.tag() == .generic_poison) continue;
- if (b_param_ty.tag() == .generic_poison) continue;
+ if (a_param_ty.isGenericPoison()) continue;
+ if (b_param_ty.isGenericPoison()) continue;
if (!eql(a_param_ty, b_param_ty, mod))
return false;
@@ -1131,7 +1131,7 @@ pub const Type = struct {
std.hash.autoHash(hasher, std.builtin.TypeId.Fn);
const fn_info = ty.fnInfo();
- if (fn_info.return_type.tag() != .generic_poison) {
+ if (!fn_info.return_type.isGenericPoison()) {
hashWithHasher(fn_info.return_type, hasher, mod);
}
if (!fn_info.align_is_generic) {
@@ -1148,7 +1148,7 @@ pub const Type = struct {
std.hash.autoHash(hasher, fn_info.param_types.len);
for (fn_info.param_types, 0..) |param_ty, i| {
std.hash.autoHash(hasher, fn_info.paramIsComptime(i));
- if (param_ty.tag() == .generic_poison) continue;
+ if (param_ty.isGenericPoison()) continue;
hashWithHasher(param_ty, hasher, mod);
}
},
@@ -2154,7 +2154,7 @@ pub const Type = struct {
if (std.math.cast(u5, i)) |index| if (@truncate(u1, fn_info.noalias_bits >> index) != 0) {
try writer.writeAll("noalias ");
};
- if (param_ty.tag() == .generic_poison) {
+ if (param_ty.isGenericPoison()) {
try writer.writeAll("anytype");
} else {
try print(param_ty, writer, mod);
@@ -2175,7 +2175,7 @@ pub const Type = struct {
try writer.writeAll(@tagName(fn_info.cc));
try writer.writeAll(") ");
}
- if (fn_info.return_type.tag() == .generic_poison) {
+ if (fn_info.return_type.isGenericPoison()) {
try writer.writeAll("anytype");
} else {
try print(fn_info.return_type, writer, mod);
@@ -6075,6 +6075,14 @@ pub const Type = struct {
}
}
+ pub fn isGenericPoison(ty: Type) bool {
+ return switch (ty.ip_index) {
+ .generic_poison_type => true,
+ .none => ty.tag() == .generic_poison,
+ else => false,
+ };
+ }
+
/// This enum does not directly correspond to `std.builtin.TypeId` because
/// it has extra enum tags in it, as a way of using less memory. For example,
/// even though Zig recognizes `*align(10) i32` and `*i32` both as Pointer types