Skip to content

Conversation

newpavlov
Copy link
Member

No description provided.

// It is also properly aligned, because `u8` has an alignment of `1`.
unsafe {
volatile_set((self as *mut Self).cast::<u8>(), 0, mem::size_of::<Self>());
volatile_set((self as *mut Self).cast::<u8>(), 0, size_of::<Self>());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why exactly compiler complains about mem::size_of. Was it added to the prelude?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was. Just encountered that here too: RustCrypto/traits#1589

@newpavlov newpavlov requested a review from tarcieri June 19, 2024 14:04
#[cfg(feature = "std")]
impl Zeroize for CString {
fn zeroize(&mut self) {
use core::mem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can continue to import mem, or maybe just import take?

Copy link
Member Author

@newpavlov newpavlov Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import would need to be gated on feature = "std", otherwise the compiler will complain about unused import. I think importing it inside the method is the simplest option. IMO mem::take/replace is a bit easier to read than just take/replace.

@newpavlov newpavlov merged commit c68a520 into master Jun 19, 2024
@newpavlov newpavlov deleted the clippy_fix2 branch June 19, 2024 14:18
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