Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
refactor: remove the uses of Box::into_raw_non_null
Browse files Browse the repository at this point in the history
`Box::into_raw_non_null` was recently deprecated by
<rust-lang/rust#71168> and will probably be
removed after some time.
  • Loading branch information
yvt committed May 4, 2020
1 parent 12d2d23 commit f55c918
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
3 changes: 1 addition & 2 deletions support/atom2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Reimplementation of the [atom] library with specialized and extended features.
//!
//! [atom]: https://crates.io/crates/atom
#![feature(box_into_raw_non_null)]
#![feature(const_fn)] // `const fn` with a constrained type parameter (e.g., `T: PtrSized`)
use std::cell::Cell;
use std::marker::PhantomData;
Expand Down Expand Up @@ -85,7 +84,7 @@ impl<T: PtrSized> PtrSizedExt for T {

unsafe impl<T> PtrSized for Box<T> {
fn into_raw(this: Self) -> NonNull<()> {
unsafe { mem::transmute(Box::into_raw_non_null(this)) }
NonNull::from(Box::leak(this)).cast()
}
unsafe fn from_raw(ptr: NonNull<()>) -> Self {
Box::from_raw(ptr.as_ptr() as _)
Expand Down
1 change: 0 additions & 1 deletion support/neo_linked_list/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Provides a customized version of `std::collections::LinkedList`.
#![feature(box_into_raw_non_null)]
pub mod cell;
pub mod linked_list;

Expand Down
4 changes: 1 addition & 3 deletions support/neo_linked_list/src/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ impl<T: ?Sized> Node<T> {
fn box_into_hdr(mut self: Box<Self>) -> NonNull<Hdr> {
self.set_vtable();

let mut raw = Box::into_raw_non_null(self);

NonNull::from(unsafe { &mut raw.as_mut().hdr })
NonNull::from(&mut Box::leak(self).hdr)
}

#[inline]
Expand Down

0 comments on commit f55c918

Please sign in to comment.