diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-08-18 22:02:10 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-08-18 22:02:10 -0700 |
| commit | 5e989fcb679215a6357dd35b5b8903293f963846 (patch) | |
| tree | cfab9e446693df750eebad12d49f0ce0de3b283e /src | |
| parent | cee82c7ce4fb8beb39042f9dba16a1a391803fa4 (diff) | |
| download | zig-5e989fcb679215a6357dd35b5b8903293f963846.tar.gz zig-5e989fcb679215a6357dd35b5b8903293f963846.zip | |
stage2: pointers to comptime-only types are comptime-only
This is a partial revert of c5ba941b77fbdb06841f28142420c6786f2a4d0c.
Diffstat (limited to 'src')
| -rw-r--r-- | src/type.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/type.zig b/src/type.zig index 6a66fb9d70..f6afa33df1 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2374,6 +2374,10 @@ pub const Type = extern union { .error_union, .error_set, .error_set_merged, + => return true, + + // Pointers to zero-bit types still have a runtime address; however, pointers + // to comptime-only types do not, with the exception of function pointers. .anyframe_T, .optional_single_mut_pointer, .optional_single_const_pointer, @@ -2386,7 +2390,17 @@ pub const Type = extern union { .const_slice, .mut_slice, .pointer, - => return true, + => { + if (ignore_comptime_only) { + return true; + } else if (ty.childType().zigTypeTag() == .Fn) { + return true; + } else if (sema_kit) |sk| { + return !(try sk.sema.typeRequiresComptime(sk.block, sk.src, ty)); + } else { + return !comptimeOnly(ty); + } + }, // These are false because they are comptime-only types. .single_const_pointer_to_comptime_int, |
