Skip to content

Tracking issue for ManuallyDrop::take #55422

Description

@CAD97

This is a tracking issue for the function ManuallyDrop::take, gated on the feature manually_drop_take.

Steps:

Unresolved questions:

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Oct 27, 2018
  2. added a commit that references this issue on Oct 28, 2018
  3. RalfJung commented on Oct 29, 2018

    @RalfJung
    Member

    I am a bit worried about the name of this method being too innocent-looking. We have take as a safe method in other places, like Option and Iterator. This leaves the fact that the method is unsafe as the only safeguard -- which is a problem e.g. when this gets (accidentally) used inside an unsafe fn or in a large unsafe block.

    I'd prefer a name that already indicates this to be a dangerous operation. Strawman: take_unchecked because it doesn't check you are taking twice?

  4. CAD97 commented on Oct 29, 2018

    @CAD97
    ContributorAuthor

    Note that it has to be written as ManuallyDrop::take, which eliminates some of the risk of using a familiar name, as it's attached to ManuallyDrop, which is known to have interesting semantics, and thus is hard to use accidentally.

    (Procedural note: I'll update OP with useful information soon.)

  5. SimonSapin commented on Feb 1, 2019

    @SimonSapin
    Contributor

    @RalfJung I’m sympathetic to this argument, but we also have ManuallyDrop::drop which is (almost) as innocent-looking, and also doesn’t check if we are dropping twice.

    (I also notice that ManuallyDrop::into_inner is safe, even though it would be unsound to call after drop or take.)

    So I’m inclined to FCP to stabilize as-is. Or do you feel strongly we should rename?

  6. RalfJung commented on Feb 1, 2019

    @RalfJung
    Member

    No, not very strongly. And not being able to say foo.take() helps a lot.

  7. scottmcm commented on Jun 27, 2019

    @scottmcm
    Member

    Anything that needs to be resolved for this to stabilize, libs?

    I just ended up here because someone on discord was just using mem::replace(x, mem::uninitialized()) (😭) where hopefully they would have just used this if it were stable.

  8. RalfJung commented on Jun 27, 2019

    @RalfJung
    Member

    The corresponding (unstable) method on MaybeUninit is (currently) called "read", because the safety concerns are a lot like the ones of ptr::read. Would the same make sense here as well?

  9. SimonSapin commented on Jun 27, 2019

    @SimonSapin
    Contributor

    This sounds reasonable. In fact both methods are implemented based on ptr::read. We can repeat it again in the docs:

    Like std::ptr::read, this function semantically moves […]

    @rust-lang/libs, what do you think?

  10. CAD97 commented on Jun 28, 2019

    @CAD97
    ContributorAuthor

    Documentation is updated and rename is done in #62198. I've also finally updated the OP with the proper details. I can roll stabilization into #62198 if desired, or it can be done separately of course.

  11. HyeonuPark commented on Jul 9, 2019

    @HyeonuPark

    I think this method is only reasonable only if we don't have MaybeUninit in stable. Practically we use ManuallyDrop when we need untagged Option, because we don't have any other way to prevent accidentally dropping invalid data. But now we have MaybeUninit in stable which exactly is for this purpose.

    Is there some use case that can't be reasonably expressed using MaybeUninit?

  12. 11 remaining items

  13. petertodd commented on Dec 22, 2019

    @petertodd
    Contributor

    @RalfJung So counter-argument to my "it should be clear" argument: How many people who are unfamiliar with ManuallyDrop read it and think "ah, drop flags!"?

  14. jyn514 commented on Jan 8, 2020

    @jyn514
    Member

    IMO, anyone who sees ManuallyDrop and unsafe already knows there's something fishy going on, I don't think it needs to be reinforced by _unchecked.

  15. Amanieu commented on Jan 9, 2020

    @Amanieu
    Member

    I would like to stabilize this function as it is. For reference, here is the signature:

    impl<T> ManuallyDrop<T> {
        pub unsafe fn take(slot: &mut ManuallyDrop<T>) -> T;
    }

    @rfcbot fcp merge

  16. rfcbot commented on Jan 9, 2020

    @rfcbot

    Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

    No concerns currently listed.

    Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

    See this document for info about what commands tagged team members can give me.

  17. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.
    on Jan 9, 2020
  18. CAD97 commented on Jan 9, 2020

    @CAD97
    ContributorAuthor

    I went ahead and filed the stabilization PR at #68066 along with reclaimed doc improvements from the closed rename PR.

  19. rfcbot commented on Jan 10, 2020

    @rfcbot

    🔔 This is now entering its final comment period, as per the review above. 🔔

  20. added
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    and removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Jan 10, 2020
  21. rfcbot commented on Jan 20, 2020

    @rfcbot

    The final comment period, with a disposition to merge, as per the review above, is now complete.

    As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

    The RFC will be merged soon.

  22. removed
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Jan 20, 2020
  23. added a commit that references this issue on Jan 20, 2020
    b5a3341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions