Skip to content

gccrs: Support ZST type checking for #[repr(transparent)]#4698

Open
Polygonalr wants to merge 1 commit into
Rust-GCC:masterfrom
Polygonalr:zst-check
Open

gccrs: Support ZST type checking for #[repr(transparent)]#4698
Polygonalr wants to merge 1 commit into
Rust-GCC:masterfrom
Polygonalr:zst-check

Conversation

@Polygonalr

Copy link
Copy Markdown
Contributor

Zero-sized types such as PhantomData can be additional members of a #[repr(transparent)] struct besides the single non-zero-sized, so this PR supports type-checking them.

@Polygonalr Polygonalr force-pushed the zst-check branch 2 times, most recently from 38a3fcf to a240458 Compare July 12, 2026 14:38
@P-E-P P-E-P self-requested a review July 13, 2026 22:20
Comment thread gcc/rust/typecheck/rust-tyty.cc
gcc/rust/ChangeLog:

	* typecheck/rust-tyty.h (BaseType::is_zero_sized): New function.
	(TupleType::is_zero_sized): New function.
	(ArrayType::is_zero_sized): New function.
	(ADTType::is_zero_sized): New function.
	* typecheck/rust-tyty.cc (BaseType::is_zero_sized): Implement checking of
	whether a type is zero-sized.
	(TupleType::is_zero_sized): Ditto.
	(ArrayType::is_zero_sized): Ditto.
	(ADTType::is_zero_sized): Ditto.
	* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit (StructStruct)): Update
	transparent repr type-checking to check for zero-sized members.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit (TyTy::ADTType)): Support
	compilation of transparent repr structs with more than 1 fields.

gcc/testsuite/ChangeLog:

	* rust/compile/repr_transparent_fields.rs: Add new test case with PhantomData.

Signed-Off-By: Yap Zhi Heng <yapzhhg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants