2020//!
2121//! ## Nightly Needed for `alloc` and `std` features
2222//!
23- //! This library requires unstable features when the `alloc` or `std` features are enabled and thus
24- //! can only be used with a nightly compiler. The internally used features are:
25- //! - `allocator_api`
26- //! - `get_mut_unchecked`
23+ //! This library requires the `allocator_api` unstable feature when the `alloc` or `std` features
24+ //! are enabled and thus can only be used with a nightly compiler.
2725//!
28- //! When enabling the `alloc` or `std` feature, the user will be required to activate these features:
29- //! - `allocator_api`
26+ //! When enabling the `alloc` or `std` feature, the user will be required to activate `allocator_api`
27+ //! as well.
3028//!
3129//! # Overview
3230//!
236234#![ forbid( missing_docs, unsafe_op_in_unsafe_fn) ]
237235#![ cfg_attr( not( feature = "std" ) , no_std) ]
238236#![ cfg_attr( feature = "alloc" , feature( allocator_api) ) ]
239- #![ cfg_attr( feature = "alloc" , feature( get_mut_unchecked) ) ]
240237
241238#[ cfg( feature = "alloc" ) ]
242239extern crate alloc;
@@ -1226,7 +1223,10 @@ impl<T> InPlaceInit<T> for Arc<T> {
12261223 E : From < AllocError > ,
12271224 {
12281225 let mut this = Arc :: try_new_uninit ( ) ?;
1229- let slot = unsafe { Arc :: get_mut_unchecked ( & mut this) } ;
1226+ let Some ( slot) = Arc :: get_mut ( & mut this) else {
1227+ // SAFETY: the Arc has just been created and has no external referecnes
1228+ unsafe { core:: hint:: unreachable_unchecked ( ) }
1229+ } ;
12301230 let slot = slot. as_mut_ptr ( ) ;
12311231 // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
12321232 // slot is valid and will not be moved, because we pin it later.
@@ -1241,7 +1241,10 @@ impl<T> InPlaceInit<T> for Arc<T> {
12411241 E : From < AllocError > ,
12421242 {
12431243 let mut this = Arc :: try_new_uninit ( ) ?;
1244- let slot = unsafe { Arc :: get_mut_unchecked ( & mut this) } ;
1244+ let Some ( slot) = Arc :: get_mut ( & mut this) else {
1245+ // SAFETY: the Arc has just been created and has no external referecnes
1246+ unsafe { core:: hint:: unreachable_unchecked ( ) }
1247+ } ;
12451248 let slot = slot. as_mut_ptr ( ) ;
12461249 // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
12471250 // slot is valid.
0 commit comments