Skip to content

Commit

Permalink
Rename Box::into_non_null_raw to Box::into_raw_non_null
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jan 20, 2018
1 parent 8ef5e54 commit 12b3630
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl<T> Arc<T> {
weak: atomic::AtomicUsize::new(1),
data,
};
Arc { ptr: Box::into_non_null_raw(x), phantom: PhantomData }
Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData }
}

/// Returns the contained value, if the `Arc` has exactly one strong reference.
Expand Down Expand Up @@ -991,7 +991,7 @@ impl<T> Weak<T> {
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Box::into_non_null_raw(box ArcInner {
ptr: Box::into_raw_non_null(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
Expand Down
12 changes: 6 additions & 6 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<T: ?Sized> Box<T> {
#[stable(feature = "box_raw", since = "1.4.0")]
#[inline]
pub fn into_raw(b: Box<T>) -> *mut T {
Box::into_non_null_raw(b).as_ptr()
Box::into_raw_non_null(b).as_ptr()
}

/// Consumes the `Box`, returning the wrapped pointer as `NonNull<T>`.
Expand All @@ -308,8 +308,8 @@ impl<T: ?Sized> Box<T> {
/// function.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Box::into_non_null_raw(b)`
/// instead of `b.into_non_null_raw()`. This
/// to call it as `Box::into_raw_non_null(b)`
/// instead of `b.into_raw_non_null()`. This
/// is so that there is no conflict with a method on the inner type.
///
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
Expand All @@ -319,16 +319,16 @@ impl<T: ?Sized> Box<T> {
/// ```
/// fn main() {
/// let x = Box::new(5);
/// let ptr = Box::into_non_null_raw(x);
/// let ptr = Box::into_raw_non_null(x);
/// }
/// ```
#[stable(feature = "nonnull", since = "1.24.0")]
#[inline]
pub fn into_non_null_raw(b: Box<T>) -> NonNull<T> {
pub fn into_raw_non_null(b: Box<T>) -> NonNull<T> {
Box::into_unique(b).into()
}

#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_non_null_raw instead")]
#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")]
#[inline]
pub fn into_unique(b: Box<T>) -> Unique<T> {
let unique = b.0;
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<T> LinkedList<T> {
unsafe {
node.next = self.head;
node.prev = None;
let node = Some(Box::into_non_null_raw(node));
let node = Some(Box::into_raw_non_null(node));

match self.head {
None => self.tail = node,
Expand Down Expand Up @@ -192,7 +192,7 @@ impl<T> LinkedList<T> {
unsafe {
node.next = None;
node.prev = self.tail;
let node = Some(Box::into_non_null_raw(node));
let node = Some(Box::into_raw_non_null(node));

match self.tail {
None => self.head = node,
Expand Down Expand Up @@ -986,7 +986,7 @@ impl<'a, T> IterMut<'a, T> {
Some(prev) => prev,
};

let node = Some(Box::into_non_null_raw(box Node {
let node = Some(Box::into_raw_non_null(box Node {
next: Some(head),
prev: Some(prev),
element,
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl<T> Rc<T> {
// pointers, which ensures that the weak destructor never frees
// the allocation while the strong destructor is running, even
// if the weak pointer is stored inside the strong one.
ptr: Box::into_non_null_raw(box RcBox {
ptr: Box::into_raw_non_null(box RcBox {
strong: Cell::new(1),
weak: Cell::new(1),
value,
Expand Down Expand Up @@ -1190,7 +1190,7 @@ impl<T> Weak<T> {
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Box::into_non_null_raw(box RcBox {
ptr: Box::into_raw_non_null(box RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: uninitialized(),
Expand Down

0 comments on commit 12b3630

Please sign in to comment.