Skip to content

Commit 49cc548

Browse files
committed
add fallback body to box_new intrinsic
1 parent a17780d commit 49cc548

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/alloc/src/boxed.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ pub struct Box<
239239
/// This is the surface syntax for `box <expr>` expressions.
240240
#[rustc_intrinsic]
241241
#[unstable(feature = "liballoc_internals", issue = "none")]
242-
pub fn box_new<T>(x: T) -> Box<T>;
242+
pub fn box_new<T>(x: T) -> Box<T> {
243+
Box::write(Box::new_uninit(), x)
244+
}
243245

244246
impl<T> Box<T> {
245247
/// Allocates memory on the heap and then places `x` into it.

0 commit comments

Comments
 (0)