Skip to content

Commit

Permalink
Rollup merge of #125739 - RalfJung:drop-in-place-docs, r=workingjubilee
Browse files Browse the repository at this point in the history
drop_in_place: weaken the claim of equivalence with drop(ptr.read())

The two are *not* semantically equivalent in all cases, so let's not be so definite about this.

Fixes rust-lang/rust#112015
  • Loading branch information
matthiaskrgr authored May 30, 2024
2 parents 5e0a672 + 1bf4f03 commit 48e9ba2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/pass/drop_in_place.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Miri currently doesn't require types without drop glue to be
// valid when dropped. This test confirms that behavior.
// This is not a stable guarantee!

use std::ptr;

fn main() {
let mut not_a_bool = 13u8;
unsafe {
ptr::drop_in_place(&mut not_a_bool as *mut u8 as *mut bool)
};
}

0 comments on commit 48e9ba2

Please sign in to comment.