Skip to content

Drop with guaranteed move elision #62508

Open
@tmandry

Description

@tmandry

Today, calling drop(_1) results in the following MIR:

_2 = move _1;
std::mem::drop::<T>(_2) -> [return .., unwind ..];

We could instead inline this directly to a MIR drop, with no move. This makes it simpler to do some optimizations in MIR.

This issue specifically tracks having such a drop available in HIR lowering; whether or not to bless std::mem::drop with this guarantee is up for discussion.

cc @cramertj @withoutboats

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-destructorsArea: Destructors (`Drop`, …)C-enhancementCategory: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions