Repository navigation
fix(docs): remove CLayoutOf wrapper for ZST - #277
Merged
Merged
Conversation
Ben Chatelain (phatblat)
approved these changes
Nov 12, 2026
Daniel Henry-Mantilla (danielhenrymantilla)
approved these changes
Nov 13, 2026
Daniel Henry-Mantilla (danielhenrymantilla)
left a comment
Collaborator
There was a problem hiding this comment.
I've checked and in the specific case of transparent this does indeed not require further CTypes for the PhantomData: LGTM! ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Removes
CLayoutOfwrapper for zero-sizedPhantomDatain struct definitions generated bysaferffimacros.This will fix the recent build failures for dittolive-ditto-sys on docs.rs.
Contributes to SDKS-5225
How does this work?
#[repr(transparent)]is supposed to work on any struct with exactly one non-ZST (zero-sized type) field. While rustc knows thatPhantomData<T>is always ZST for anyT, it doesn't know thatCLayoutOf<PhantomData<T>>is always ZST.Removing the
CLayoutOfwrapper here has no other effects: the layout of anyPhantomData<T>isCVoid, which is similarly zero-sized with 1-byte alignment and has the same variance. It just ensures that#[repr(transparent)]works.How was this tested?
This patch was tested in a clone of the
getditto/dittorepository rather thangetditto/safer_ffidirectly.In
getditto/dittoon themainbranch, run the following command:This should fail with two errors:
(output abbreviated)
Running with this patch enabled should succeed:
Performance impact
N/A. replaces one ZST with another; no behavior change.
Checklist
I updated docs for any public API changesAI assistance
AI identified the issue and provided the fix. I understand the issue + fix and wrote the PR + changelog entry. The command to reproduce/test the issue was initially AI-written, then I simplified it.