Skip to content

Commit 5e989fc

Browse files
committed
stage2: pointers to comptime-only types are comptime-only
This is a partial revert of c5ba941.
1 parent cee82c7 commit 5e989fc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/type.zig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,10 @@ pub const Type = extern union {
23742374
.error_union,
23752375
.error_set,
23762376
.error_set_merged,
2377+
=> return true,
2378+
2379+
// Pointers to zero-bit types still have a runtime address; however, pointers
2380+
// to comptime-only types do not, with the exception of function pointers.
23772381
.anyframe_T,
23782382
.optional_single_mut_pointer,
23792383
.optional_single_const_pointer,
@@ -2386,7 +2390,17 @@ pub const Type = extern union {
23862390
.const_slice,
23872391
.mut_slice,
23882392
.pointer,
2389-
=> return true,
2393+
=> {
2394+
if (ignore_comptime_only) {
2395+
return true;
2396+
} else if (ty.childType().zigTypeTag() == .Fn) {
2397+
return true;
2398+
} else if (sema_kit) |sk| {
2399+
return !(try sk.sema.typeRequiresComptime(sk.block, sk.src, ty));
2400+
} else {
2401+
return !comptimeOnly(ty);
2402+
}
2403+
},
23902404

23912405
// These are false because they are comptime-only types.
23922406
.single_const_pointer_to_comptime_int,

0 commit comments

Comments
 (0)