Skip to content

internal drop_in_place shim should take &mut arguments #154274

Closed

Description

@RalfJung

The signature of drop_in_place says that it takes a raw pointer, but we have hacks in place to actually treat that argument as-if it was a mutable reference. These hacks are now part of the MIR semantics and have to be replicated in every MIR consumer that cares about aliasing, i.e., Miri will need a similar logic (as part of a refactor where we no longer use Retag statements).

This is obviously not great; if we want the argument of those functions to be &mut T we should just change it to literally have that type. We can keep the public method in std::ptr unchanged, it can dispatch to the actual function that does take a mutable reference.

I wonder why those hacks were added in the first place instead of properly changing the signature?
This was apparently done in #111807.
Cc @pcwalton @erikdesjardins @oli-obk @WaffleLapkin @scottmcm

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 23, 2026
  2. added
    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    on Mar 23, 2026
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 24, 2026
  4. self-assigned this
    on Mar 24, 2026
  5. added 3 commits that reference this issue on May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-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