Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nightly warnings #1080

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Fix Nightly warnings #1080

merged 3 commits into from
Jun 19, 2024

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
@@ -595,6 +595,8 @@ impl Zeroize for String {
#[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
33 checks passed
@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