Skip to content

forget() is no-op in CallocBackingStore's Drop implementation #18

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oherrala
Copy link

@oherrala oherrala commented Nov 6, 2023

Calling core::mem::forget() for slice is no-op. Forget wants to have an ownership of the data, but it can't since slice is always a reference. While here, use take() instead of replace() as recommended by Clippy.

This should not have any functional change, but it should remove the emitted compile time warning:

  --> /Users/oherrala/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloc-no-stdlib-2.0.4/src/lib.rs:78:5
   |
78 |     core::mem::forget(core::mem::replace(&mut self.data, &mut[]));
   |     ^^^^^^^^^^^^^^^^^^------------------------------------------^
   |                       |
   |                       argument has type `&mut [T]`
   |
   = note: use `let _ = ...` to ignore the expression or result
   = note: `#[warn(forgetting_references)]` on by default

Calling core::mem::forget() for slice is no-op. Forget wants to have
an ownership of the data, but it can't since slice is always a
reference.

While here, use take() instead of replace() as recommended by Clippy.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@oherrala
Copy link
Author

oherrala commented Nov 6, 2023

I'm not going to sign any CLA for this trivial change.

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