Skip to content

Commit 48e9ba2

Browse files
authored
Rollup merge of #125739 - RalfJung:drop-in-place-docs, r=workingjubilee
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
2 parents 5e0a672 + 1bf4f03 commit 48e9ba2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/pass/drop_in_place.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Miri currently doesn't require types without drop glue to be
2+
// valid when dropped. This test confirms that behavior.
3+
// This is not a stable guarantee!
4+
5+
use std::ptr;
6+
7+
fn main() {
8+
let mut not_a_bool = 13u8;
9+
unsafe {
10+
ptr::drop_in_place(&mut not_a_bool as *mut u8 as *mut bool)
11+
};
12+
}

0 commit comments

Comments
 (0)