20
20
//!
21
21
//! ## Nightly Needed for `alloc` and `std` features
22
22
//!
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.
27
25
//!
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.
30
28
//!
31
29
//! # Overview
32
30
//!
236
234
#![ forbid( missing_docs, unsafe_op_in_unsafe_fn) ]
237
235
#![ cfg_attr( not( feature = "std" ) , no_std) ]
238
236
#![ cfg_attr( feature = "alloc" , feature( allocator_api) ) ]
239
- #![ cfg_attr( feature = "alloc" , feature( get_mut_unchecked) ) ]
240
237
241
238
#[ cfg( feature = "alloc" ) ]
242
239
extern crate alloc;
@@ -1226,7 +1223,10 @@ impl<T> InPlaceInit<T> for Arc<T> {
1226
1223
E : From < AllocError > ,
1227
1224
{
1228
1225
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
+ } ;
1230
1230
let slot = slot. as_mut_ptr ( ) ;
1231
1231
// SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1232
1232
// slot is valid and will not be moved, because we pin it later.
@@ -1241,7 +1241,10 @@ impl<T> InPlaceInit<T> for Arc<T> {
1241
1241
E : From < AllocError > ,
1242
1242
{
1243
1243
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
+ } ;
1245
1248
let slot = slot. as_mut_ptr ( ) ;
1246
1249
// SAFETY: When init errors/panics, slot will get deallocated but not dropped,
1247
1250
// slot is valid.
0 commit comments