Rollup merge of #150460 - RalfJung:miri-manually-drop, r=dtolnay
fix ManuallyDrop::into_inner aliasing (Miri) issues Fixes https://github.com/rust-lang/miri/issues/4793 r? `@WaffleLapkin`
This commit is contained in:
commit
2ecaa1df2d
2 changed files with 6 additions and 1 deletions
|
|
@ -200,7 +200,9 @@ impl<T> ManuallyDrop<T> {
|
|||
#[rustc_const_stable(feature = "const_manually_drop", since = "1.32.0")]
|
||||
#[inline(always)]
|
||||
pub const fn into_inner(slot: ManuallyDrop<T>) -> T {
|
||||
slot.value.into_inner()
|
||||
// Cannot use `MaybeDangling::into_inner` as that does not yet have the desired semantics.
|
||||
// SAFETY: We know this is a valid `T`. `slot` will not be dropped.
|
||||
unsafe { (&raw const slot).cast::<T>().read() }
|
||||
}
|
||||
|
||||
/// Takes the value from the `ManuallyDrop<T>` container out.
|
||||
|
|
|
|||
3
src/tools/miri/tests/pass/issues/issue-miri-4793.rs
Normal file
3
src/tools/miri/tests/pass/issues/issue-miri-4793.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
let _ = std::panic::catch_unwind(|| Box::<str>::from("..."));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue