Skip to content

Commit 595b1c1

Browse files
committed
rust: alloc: kbox: Add CoerceUnsized trait
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent da30caf commit 595b1c1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

rust/kernel/alloc/kbox.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ use super::{AllocError, Allocator, Flags};
88
use core::alloc::Layout;
99
use core::fmt;
1010
use core::marker::PhantomData;
11+
#[cfg(not(CONFIG_RUSTC_HAS_COERCE_POINTEE))]
12+
use core::marker::Unsize;
1113
use core::mem::ManuallyDrop;
1214
use core::mem::MaybeUninit;
15+
#[cfg(not(CONFIG_RUSTC_HAS_COERCE_POINTEE))]
16+
use core::ops::CoerceUnsized;
1317
use core::ops::{Deref, DerefMut};
1418
use core::pin::Pin;
1519
use core::ptr::NonNull;
@@ -486,6 +490,10 @@ where
486490
}
487491
}
488492

493+
//#[unstable(feature = "coerce_unsized", issue = "18598")]
494+
#[cfg(not(CONFIG_RUSTC_HAS_COERCE_POINTEE))]
495+
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
496+
489497
impl<T, A> AsRef<T> for Box<T, A>
490498
where
491499
T: ?Sized,

0 commit comments

Comments
 (0)