From 0075c5a1d5ad1198b16e6a1c390c985a8e4354de Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Fri, 27 Feb 2026 10:27:29 +0000 Subject: [PATCH] Type: tiny refactors --- src/Type.zig | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Type.zig b/src/Type.zig index 1eab734882f8d25b246e4bc754004d4ca2397e39..60adb6f10ffb7601d85eb337ff05cafe452b1cba 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -690,9 +690,9 @@ pub fn hasRuntimeBits(ty: Type, zcu: *const Zcu) bool { }; } -/// true if and only if the type has a well-defined memory layout -/// readFrom/writeToMemory are supported only for types with a well- -/// defined memory layout +/// Returns `true` iff the memory layout of `ty` is defined by the Zig language specification. +/// +/// Does not require `ty` to be resolved. pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool { const ip = &zcu.intern_pool; return switch (ip.indexToKey(ty.toIntern())) { @@ -3140,9 +3140,16 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool }, }; }, - .array => { - if (position == .ret_ty or position == .param_ty) return false; - return ty.childType(zcu).validateExtern(.element, zcu); + .array => switch (position) { + .ret_ty, + .param_ty, + => false, + + .union_field, + .struct_field, + .element, + .other, + => ty.childType(zcu).validateExtern(.element, zcu), }, .vector => ty.childType(zcu).validateExtern(.element, zcu), .optional => ty.isPtrLikeOptional(zcu), -- 2.54.0