Skip to content

Commit

Permalink
Use addr_of_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
steffahn committed Oct 4, 2021
1 parent 2ca0660 commit 5f9e9a8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/unsafe_self_cell.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::marker::PhantomData;
use core::mem::transmute;
use core::ptr::{drop_in_place, read, NonNull};
use core::ptr::{addr_of_mut, drop_in_place, read, NonNull};

extern crate alloc;

Expand Down Expand Up @@ -79,8 +79,8 @@ impl<ContainedIn, Owner, DependentStatic> UnsafeSelfCell<ContainedIn, Owner, Dep
// IMPORTANT dependent must be dropped before owner.
// We don't want to rely on an implicit order of struct fields.
// So we drop the struct, field by field manually.
drop_in_place(&mut (*joined_ptr.as_ptr()).dependent);
drop_in_place(&mut (*joined_ptr.as_ptr()).owner);
drop_in_place(addr_of_mut!((*joined_ptr.as_ptr()).dependent));
drop_in_place(addr_of_mut!((*joined_ptr.as_ptr()).owner));

let layout = Layout::new::<JoinedCell<Owner, Dependent>>();

Expand Down

0 comments on commit 5f9e9a8

Please sign in to comment.