Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/tests/generics_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ where
}

#[account(zero_copy(unsafe))]
#[repr(C)]
Copy link
Copy Markdown

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 use repr(packed). Shouldn't use that here to be more representative of real world usage?

Copy link
Copy Markdown
Collaborator Author

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 using repr(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 clippy error 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.

pub struct FooAccount<const N: usize> {
pub data: WrappedU8Array<N>,
}
Expand Down