Skip to content

MIRI disagree with the documentation of ptr::drop_in_place #112015

Closed
@SkiFire13

Description

Location

https://doc.rust-lang.org/stable/std/ptr/fn.drop_in_place.html

Summary

The documentation for ptr::drop_in_place claims that:

This is semantically equivalent to calling ptr::read and discarding the result.

However when tested in a playground MIRI complained about the use of ptr::read but not of ptr::drop_in_place: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c3dfe878ef015b93f051785b67239752

Although the ptr::drop_in_place documentation lists a bunch of cases where they differ, none of them seems to apply to this one.

Some details of the reproduction:

  • it uses #[may_dangle] both because the issue derived from this user.rust-lang.com thread on #[may_dangle] and because I didn't find a quicker way to create a dangling reference. However this doesn't seem fundamental to the issue and likely is not required.
  • this seems to only work with exclusive references, MIRI won't complain with shared ones

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-opsemRelevant to the opsem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions