Skip to content

Use ManuallyDrop from the maybe-dangling crate.#6

Closed
theemathas wants to merge 1 commit intoWaffleLapkin:masterfrom
theemathas:maybe-dangling
Closed

Use ManuallyDrop from the maybe-dangling crate.#6
theemathas wants to merge 1 commit intoWaffleLapkin:masterfrom
theemathas:maybe-dangling

Conversation

@theemathas
Copy link
Copy Markdown

This fixes #5, because moving a maybe-dangling ManuallyDrop does not assert validity or ownership of its contents, which avoids an unsoundness.

Note that using the maybe-dangling crate means that, if the ManuallyDrop in the standard library ever gets MaybeDangling semantics, then the maybe-danging crate will get updated to take advantage of that (e.g., getting niche optimizations), and this takecell crate can benefit from that update without any code changes.
See https://docs.rs/maybe-dangling/0.1.2/maybe_dangling/struct.ManuallyDrop.html#differences-with-corememmanuallydrop

This fixes WaffleLapkin#5,
because moving a maybe-dangling ManuallyDrop does not assert validity
or ownership of its contents, which avoids an unsoundness.

Note that using the maybe-dangling crate means that, if the ManuallyDrop
in the standard library ever gets MaybeDangling semantics, then the
maybe-danging crate will get updated to take advantage of that
(e.g., getting niche optimizations), and this takecell crate can benefit
from that update without any code changes.
See https://docs.rs/maybe-dangling/0.1.2/maybe_dangling/struct.ManuallyDrop.html#differences-with-corememmanuallydrop
@WaffleLapkin
Copy link
Copy Markdown
Owner

Note that using the maybe-dangling crate means that, if the ManuallyDrop in the standard library ever gets MaybeDangling semantics, then the maybe-danging crate will get updated to take advantage of that (e.g., getting niche optimizations), and this takecell crate can benefit from that update without any code changes.

Well, I'd still need to update the dependency version ^^'

@theemathas
Copy link
Copy Markdown
Author

New users of takecell would automatically get the new version of maybe-dangling, assuming that maybe-dangling's updated version is semver-compatible. I think?

@WaffleLapkin
Copy link
Copy Markdown
Owner

Ur totally right, I forgot for a second about Cargo.lock and how the dependencies in Cargo.toml are generally a lower bound

@theemathas
Copy link
Copy Markdown
Author

The underlying issue has been fixed. See rust-lang/rust#155750

@theemathas theemathas closed this Apr 26, 2026
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.

TakeOwnCell is unsound due to using ManuallyDrop instead of MaybeUninit

2 participants