|
211 | 211 | //! [`pin_init!`]: crate::pin_init! |
212 | 212 |
|
213 | 213 | use crate::{ |
214 | | - alloc::{box_ext::BoxExt, AllocError, Flags, KBox}, |
| 214 | + alloc::{AllocError, Flags, KBox}, |
215 | 215 | error::{self, Error}, |
216 | 216 | sync::Arc, |
217 | 217 | sync::UniqueArc, |
218 | 218 | types::{Opaque, ScopeGuard}, |
219 | 219 | }; |
220 | | -use alloc::boxed::Box; |
221 | 220 | use core::{ |
222 | 221 | cell::UnsafeCell, |
223 | 222 | convert::Infallible, |
@@ -588,7 +587,6 @@ macro_rules! pin_init { |
588 | 587 | /// # Examples |
589 | 588 | /// |
590 | 589 | /// ```rust |
591 | | -/// # #![feature(new_uninit)] |
592 | 590 | /// use kernel::{init::{self, PinInit}, error::Error}; |
593 | 591 | /// #[pin_data] |
594 | 592 | /// struct BigBuf { |
@@ -1245,26 +1243,6 @@ impl<T> InPlaceInit<T> for Arc<T> { |
1245 | 1243 | } |
1246 | 1244 | } |
1247 | 1245 |
|
1248 | | -impl<T> InPlaceInit<T> for Box<T> { |
1249 | | - type PinnedSelf = Pin<Self>; |
1250 | | - |
1251 | | - #[inline] |
1252 | | - fn try_pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Self::PinnedSelf, E> |
1253 | | - where |
1254 | | - E: From<AllocError>, |
1255 | | - { |
1256 | | - <Box<_> as BoxExt<_>>::new_uninit(flags)?.write_pin_init(init) |
1257 | | - } |
1258 | | - |
1259 | | - #[inline] |
1260 | | - fn try_init<E>(init: impl Init<T, E>, flags: Flags) -> Result<Self, E> |
1261 | | - where |
1262 | | - E: From<AllocError>, |
1263 | | - { |
1264 | | - <Box<_> as BoxExt<_>>::new_uninit(flags)?.write_init(init) |
1265 | | - } |
1266 | | -} |
1267 | | - |
1268 | 1246 | impl<T> InPlaceInit<T> for UniqueArc<T> { |
1269 | 1247 | type PinnedSelf = Pin<Self>; |
1270 | 1248 |
|
@@ -1301,28 +1279,6 @@ pub trait InPlaceWrite<T> { |
1301 | 1279 | fn write_pin_init<E>(self, init: impl PinInit<T, E>) -> Result<Pin<Self::Initialized>, E>; |
1302 | 1280 | } |
1303 | 1281 |
|
1304 | | -impl<T> InPlaceWrite<T> for Box<MaybeUninit<T>> { |
1305 | | - type Initialized = Box<T>; |
1306 | | - |
1307 | | - fn write_init<E>(mut self, init: impl Init<T, E>) -> Result<Self::Initialized, E> { |
1308 | | - let slot = self.as_mut_ptr(); |
1309 | | - // SAFETY: When init errors/panics, slot will get deallocated but not dropped, |
1310 | | - // slot is valid. |
1311 | | - unsafe { init.__init(slot)? }; |
1312 | | - // SAFETY: All fields have been initialized. |
1313 | | - Ok(unsafe { self.assume_init() }) |
1314 | | - } |
1315 | | - |
1316 | | - fn write_pin_init<E>(mut self, init: impl PinInit<T, E>) -> Result<Pin<Self::Initialized>, E> { |
1317 | | - let slot = self.as_mut_ptr(); |
1318 | | - // SAFETY: When init errors/panics, slot will get deallocated but not dropped, |
1319 | | - // slot is valid and will not be moved, because we pin it later. |
1320 | | - unsafe { init.__pinned_init(slot)? }; |
1321 | | - // SAFETY: All fields have been initialized. |
1322 | | - Ok(unsafe { self.assume_init() }.into()) |
1323 | | - } |
1324 | | -} |
1325 | | - |
1326 | 1282 | impl<T> InPlaceWrite<T> for UniqueArc<MaybeUninit<T>> { |
1327 | 1283 | type Initialized = UniqueArc<T>; |
1328 | 1284 |
|
|
0 commit comments