248248#![ cfg_attr( any( feature = "alloc" ) , feature( new_uninit) ) ]
249249#![ cfg_attr( any( feature = "alloc" ) , feature( get_mut_unchecked) ) ]
250250
251- #[ cfg( any ( feature = "alloc" ) ) ]
251+ #[ cfg( feature = "alloc" ) ]
252252extern crate alloc;
253253
254- #[ cfg( any( feature = "alloc" ) ) ]
255- use alloc:: { boxed:: Box , sync:: Arc } ;
254+ #[ cfg( all( feature = "alloc" , not( feature = "std" ) ) ) ]
255+ use alloc:: boxed:: Box ;
256+ #[ cfg( feature = "alloc" ) ]
257+ use alloc:: sync:: Arc ;
258+
256259use core:: {
257260 alloc:: AllocError ,
258261 cell:: UnsafeCell ,
@@ -1202,8 +1205,9 @@ pub trait InPlaceInit<T>: Sized {
12021205 fn pin_init ( init : impl PinInit < T > ) -> Result < Pin < Self > , AllocError > {
12031206 // SAFETY: We delegate to `init` and only change the error type.
12041207 let init = unsafe {
1205- pin_init_from_closure ( |slot| {
1206- Ok ( init. __pinned_init ( slot) . unwrap ( ) ) // cannot fail
1208+ pin_init_from_closure ( |slot| match init. __pinned_init ( slot) {
1209+ Ok ( ( ) ) => Ok ( ( ) ) ,
1210+ Err ( i) => match i { } ,
12071211 } )
12081212 } ;
12091213 Self :: try_pin_init ( init)
@@ -1217,13 +1221,16 @@ pub trait InPlaceInit<T>: Sized {
12171221 /// Use the given initializer to in-place initialize a `T`.
12181222 fn init ( init : impl Init < T > ) -> Result < Self , AllocError > {
12191223 let init = unsafe {
1220- init_from_closure ( |slot| Ok ( init. __init ( slot) . unwrap ( ) ) ) //cannot fail
1224+ init_from_closure ( |slot| match init. __init ( slot) {
1225+ Ok ( ( ) ) => Ok ( ( ) ) ,
1226+ Err ( i) => match i { } ,
1227+ } )
12211228 } ;
12221229 Self :: try_init ( init)
12231230 }
12241231}
12251232
1226- #[ cfg( any ( feature = "alloc" ) ) ]
1233+ #[ cfg( feature = "alloc" ) ]
12271234impl < T > InPlaceInit < T > for Box < T > {
12281235 #[ inline]
12291236 fn try_pin_init < E > ( init : impl PinInit < T , E > ) -> Result < Pin < Self > , E >
@@ -1254,7 +1261,7 @@ impl<T> InPlaceInit<T> for Box<T> {
12541261 }
12551262}
12561263
1257- #[ cfg( any ( feature = "alloc" ) ) ]
1264+ #[ cfg( feature = "alloc" ) ]
12581265impl < T > InPlaceInit < T > for Arc < T > {
12591266 #[ inline]
12601267 fn try_pin_init < E > ( init : impl PinInit < T , E > ) -> Result < Pin < Self > , E >
0 commit comments