authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-18 22:02:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-18 22:02:10-07:00
log5e989fcb679215a6357dd35b5b8903293f963846
treecfab9e446693df750eebad12d49f0ce0de3b283e
parentcee82c7ce4fb8beb39042f9dba16a1a391803fa4

stage2: pointers to comptime-only types are comptime-only

This is a partial revert of c5ba941b77fbdb06841f28142420c6786f2a4d0c.

1 files changed, 15 insertions(+), 1 deletions(-)

src/type.zig+15-1
...@@ -2374,6 +2374,10 @@ pub const Type = extern union {...@@ -2374,6 +2374,10 @@ pub const Type = extern union {
2374 .error_union,2374 .error_union,
2375 .error_set,2375 .error_set,
2376 .error_set_merged,2376 .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.
2377 .anyframe_T,2381 .anyframe_T,
2378 .optional_single_mut_pointer,2382 .optional_single_mut_pointer,
2379 .optional_single_const_pointer,2383 .optional_single_const_pointer,
...@@ -2386,7 +2390,17 @@ pub const Type = extern union {...@@ -2386,7 +2390,17 @@ pub const Type = extern union {
2386 .const_slice,2390 .const_slice,
2387 .mut_slice,2391 .mut_slice,
2388 .pointer,2392 .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
2391 // These are false because they are comptime-only types.2405 // These are false because they are comptime-only types.
2392 .single_const_pointer_to_comptime_int,2406 .single_const_pointer_to_comptime_int,