MIRI disagree with the documentation of ptr::drop_in_place
#112015
Closed
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