Skip to content

Commit

Permalink
get rid of real_drop_in_place again
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jan 18, 2020
1 parent fb4ac14 commit 7935931
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,12 @@ mod mut_ptr;
/// i.e., you do not usually have to worry about such issues unless you call `drop_in_place`
/// manually.
#[stable(feature = "drop_in_place", since = "1.8.0")]
#[inline(always)]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
real_drop_in_place(&mut *to_drop)
}

// The real `drop_in_place` -- the one that gets called implicitly when variables go
// out of scope -- should have a safe reference and not a raw pointer as argument
// type. When we drop a local variable, we access it with a pointer that behaves
// like a safe reference; transmuting that to a raw pointer does not mean we can
// actually access it with raw pointers.
#[lang = "drop_in_place"]
#[allow(unconditional_recursion)]
unsafe fn real_drop_in_place<T: ?Sized>(to_drop: &mut T) {
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
// Code here does not matter - this is replaced by the
// real drop glue by the compiler.
real_drop_in_place(to_drop)
drop_in_place(to_drop)
}

/// Creates a null raw pointer.
Expand Down

0 comments on commit 7935931

Please sign in to comment.