diff options
| author | DilithiumNitrate <38111406+DilithiumNitrate@users.noreply.github.com> | 2023-10-29 22:12:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-29 21:12:43 +0000 |
| commit | 91e117697ad90430d9266203415712b6cc59f669 (patch) | |
| tree | 5980dcec62fb3fdec01c00e072f0a453e63c5b23 /src/type.zig | |
| parent | fa022d1ecc148280a3b6e95312087b4e8c0c6166 (diff) | |
| download | zig-91e117697ad90430d9266203415712b6cc59f669.tar.gz zig-91e117697ad90430d9266203415712b6cc59f669.zip | |
Fix hasRuntimeBitsAdvanced lazy case for pointers and optionals
As suggested by mlugg, always returns `error.NeedLazy`. If this has a
performance impact, it could be replaced by adding lazy handling to
`comptimeOnlyAdvanced`.
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/type.zig b/src/type.zig index 812a753987..086a293351 100644 --- a/src/type.zig +++ b/src/type.zig @@ -473,8 +473,11 @@ pub const Type = struct { // Pointers to zero-bit types still have a runtime address; however, pointers // to comptime-only types do not, with the exception of function pointers. if (ignore_comptime_only) return true; - if (strat == .sema) return !(try strat.sema.typeRequiresComptime(ty)); - return !comptimeOnly(ty, mod); + return switch (strat) { + .sema => |sema| !(try sema.typeRequiresComptime(ty)), + .eager => !comptimeOnly(ty, mod), + .lazy => error.NeedLazy, + }; }, .anyframe_type => true, .array_type => |array_type| { @@ -495,13 +498,12 @@ pub const Type = struct { // Then the optional is comptime-known to be null. return false; } - if (ignore_comptime_only) { - return true; - } else if (strat == .sema) { - return !(try strat.sema.typeRequiresComptime(child_ty)); - } else { - return !comptimeOnly(child_ty, mod); - } + if (ignore_comptime_only) return true; + return switch (strat) { + .sema => |sema| !(try sema.typeRequiresComptime(child_ty)), + .eager => !comptimeOnly(child_ty, mod), + .lazy => error.NeedLazy, + }; }, .error_union_type, .error_set_type, |
