diff --git a/crossbeam-channel/src/flavors/array.rs b/crossbeam-channel/src/flavors/array.rs index c49eef1f0..871768ccd 100644 --- a/crossbeam-channel/src/flavors/array.rs +++ b/crossbeam-channel/src/flavors/array.rs @@ -10,7 +10,7 @@ use std::cell::UnsafeCell; use std::marker::PhantomData; -use std::mem::{self, MaybeUninit}; +use std::mem::MaybeUninit; use std::ptr; use std::sync::atomic::{self, AtomicUsize, Ordering}; use std::time::Instant; @@ -110,7 +110,7 @@ impl Channel { // Allocate a buffer of `cap` slots initialized // with stamps. let buffer = { - let mut boxed: Box<[Slot]> = (0..cap) + let boxed: Box<[Slot]> = (0..cap) .map(|i| { // Set the stamp to `{ lap: 0, mark: 0, index: i }`. Slot { @@ -119,9 +119,7 @@ impl Channel { } }) .collect(); - let ptr = boxed.as_mut_ptr(); - mem::forget(boxed); - ptr + Box::into_raw(boxed) as *mut Slot }; Channel { diff --git a/crossbeam-queue/src/array_queue.rs b/crossbeam-queue/src/array_queue.rs index ff1efaaa0..ef2c9ab4d 100644 --- a/crossbeam-queue/src/array_queue.rs +++ b/crossbeam-queue/src/array_queue.rs @@ -7,7 +7,7 @@ use alloc::boxed::Box; use core::cell::UnsafeCell; use core::fmt; use core::marker::PhantomData; -use core::mem::{self, MaybeUninit}; +use core::mem::MaybeUninit; use core::sync::atomic::{self, AtomicUsize, Ordering}; use crossbeam_utils::{Backoff, CachePadded}; @@ -103,7 +103,7 @@ impl ArrayQueue { // Allocate a buffer of `cap` slots initialized // with stamps. let buffer = { - let mut boxed: Box<[Slot]> = (0..cap) + let boxed: Box<[Slot]> = (0..cap) .map(|i| { // Set the stamp to `{ lap: 0, index: i }`. Slot { @@ -112,9 +112,7 @@ impl ArrayQueue { } }) .collect(); - let ptr = boxed.as_mut_ptr(); - mem::forget(boxed); - ptr + Box::into_raw(boxed) as *mut Slot }; // One lap is the smallest power of two greater than `cap`.