Skip to content

Tracking issue for drop_in_place #27908

Closed
@Gankra

Description

@Gankra

This calls the "drop glue" for a given type without having to explicitly read it out onto the stack to be dropped. All types have a drop glue implementation, which involves calling the types Drop impl (if it exists), and the recursively running drop glue on its fields.

drop_in_place is both a performance improvement (in the case of e.g. Vec, it avoids ptr::reading the elements out), and a semantic necessity (in the case of DSTs, it's impossible to ptr::read the value, but the vtable always contains a drop glue impl).

It is currently exposed in the ptr module because it's maximally expressive to take a *mut and because "that's what the intrinsic took" at the time it was exposed outside of std::intrinsics. It may be desirable to instead expose it in mem to parallel mem::drop, and require an &mut. For most cases you probably already have an &mut anyway, and it's trivial to upgrade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions