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

Commit f55c918

Browse files
committed
refactor: remove the uses of Box::into_raw_non_null
`Box::into_raw_non_null` was recently deprecated by <rust-lang/rust#71168> and will probably be removed after some time.
1 parent 12d2d23 commit f55c918

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

support/atom2/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Reimplementation of the [atom] library with specialized and extended features.
22
//!
33
//! [atom]: https://crates.io/crates/atom
4-
#![feature(box_into_raw_non_null)]
54
#![feature(const_fn)] // `const fn` with a constrained type parameter (e.g., `T: PtrSized`)
65
use std::cell::Cell;
76
use std::marker::PhantomData;
@@ -85,7 +84,7 @@ impl<T: PtrSized> PtrSizedExt for T {
8584

8685
unsafe impl<T> PtrSized for Box<T> {
8786
fn into_raw(this: Self) -> NonNull<()> {
88-
unsafe { mem::transmute(Box::into_raw_non_null(this)) }
87+
NonNull::from(Box::leak(this)).cast()
8988
}
9089
unsafe fn from_raw(ptr: NonNull<()>) -> Self {
9190
Box::from_raw(ptr.as_ptr() as _)

support/neo_linked_list/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Provides a customized version of `std::collections::LinkedList`.
2-
#![feature(box_into_raw_non_null)]
32
pub mod cell;
43
pub mod linked_list;
54

support/neo_linked_list/src/linked_list.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ impl<T: ?Sized> Node<T> {
177177
fn box_into_hdr(mut self: Box<Self>) -> NonNull<Hdr> {
178178
self.set_vtable();
179179

180-
let mut raw = Box::into_raw_non_null(self);
181-
182-
NonNull::from(unsafe { &mut raw.as_mut().hdr })
180+
NonNull::from(&mut Box::leak(self).hdr)
183181
}
184182

185183
#[inline]

0 commit comments

Comments
 (0)