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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the only reason to use
zero_copy(unsafe)is to be able to userepr(packed). Shouldn't use that here to be more representative of real world usage?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, but
zero_copy(unsafe)mostly exists for historical reasons (it was the initial impl and some older programs needed compatibility in newer versions) and you should generally avoid usingrepr(packed).Additionally, this file doesn't represent real world usage, and in fact, it doesn't even work. This change was only aimed at fixing the
clippyerror in CI, so which repr(s) we use doesn't matter at all.However, you're right; this may cause confusion, so I'll fix that. I initially wanted to avoid making codegen changes because those changes might delay the next release, but now that I think about this again, it's probably better to just change
https://github.com/coral-xyz/anchor/blob/4004c4e964ffa2399999e6fc900232df6d164f41/lang/attribute/account/src/lib.rs#L459
to
repr(Rust, packed)to also fix this lint for downstream users.