@@ -287,17 +287,15 @@ impl<T> Arc<T> {
287
287
/// # Examples
288
288
///
289
289
/// ```
290
- /// #![feature(rc_raw)]
291
- ///
292
290
/// use std::sync::Arc;
293
291
///
294
292
/// let x = Arc::new(10);
295
293
/// let x_ptr = Arc::into_raw(x);
296
294
/// assert_eq!(unsafe { *x_ptr }, 10);
297
295
/// ```
298
- #[ unstable ( feature = "rc_raw" , issue = "37197 " ) ]
299
- pub fn into_raw ( this : Self ) -> * mut T {
300
- let ptr = unsafe { & mut ( * * this. ptr ) . data as * mut _ } ;
296
+ #[ stable ( feature = "rc_raw" , since = "1.17.0 " ) ]
297
+ pub fn into_raw ( this : Self ) -> * const T {
298
+ let ptr = unsafe { & ( * * this. ptr ) . data as * const _ } ;
301
299
mem:: forget ( this) ;
302
300
ptr
303
301
}
@@ -315,8 +313,6 @@ impl<T> Arc<T> {
315
313
/// # Examples
316
314
///
317
315
/// ```
318
- /// #![feature(rc_raw)]
319
- ///
320
316
/// use std::sync::Arc;
321
317
///
322
318
/// let x = Arc::new(10);
@@ -332,11 +328,14 @@ impl<T> Arc<T> {
332
328
///
333
329
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
334
330
/// ```
335
- #[ unstable ( feature = "rc_raw" , issue = "37197 " ) ]
336
- pub unsafe fn from_raw ( ptr : * mut T ) -> Self {
331
+ #[ stable ( feature = "rc_raw" , since = "1.17.0 " ) ]
332
+ pub unsafe fn from_raw ( ptr : * const T ) -> Self {
337
333
// To find the corresponding pointer to the `ArcInner` we need to subtract the offset of the
338
334
// `data` field from the pointer.
339
- Arc { ptr : Shared :: new ( ( ptr as * mut u8 ) . offset ( -offset_of ! ( ArcInner <T >, data) ) as * mut _ ) }
335
+ let ptr = ( ptr as * const u8 ) . offset ( -offset_of ! ( ArcInner <T >, data) ) ;
336
+ Arc {
337
+ ptr : Shared :: new ( ptr as * const _ ) ,
338
+ }
340
339
}
341
340
}
342
341
@@ -448,7 +447,7 @@ impl<T: ?Sized> Arc<T> {
448
447
// Non-inlined part of `drop`.
449
448
#[ inline( never) ]
450
449
unsafe fn drop_slow ( & mut self ) {
451
- let ptr = * self . ptr ;
450
+ let ptr = self . ptr . as_mut_ptr ( ) ;
452
451
453
452
// Destroy the data at this time, even though we may not free the box
454
453
// allocation itself (there may still be weak pointers lying around).
@@ -461,17 +460,13 @@ impl<T: ?Sized> Arc<T> {
461
460
}
462
461
463
462
#[ inline]
464
- #[ unstable( feature = "ptr_eq" ,
465
- reason = "newly added" ,
466
- issue = "36497" ) ]
463
+ #[ stable( feature = "ptr_eq" , since = "1.17.0" ) ]
467
464
/// Returns true if the two `Arc`s point to the same value (not
468
465
/// just values that compare as equal).
469
466
///
470
467
/// # Examples
471
468
///
472
469
/// ```
473
- /// #![feature(ptr_eq)]
474
- ///
475
470
/// use std::sync::Arc;
476
471
///
477
472
/// let five = Arc::new(5);
@@ -628,7 +623,7 @@ impl<T: Clone> Arc<T> {
628
623
// As with `get_mut()`, the unsafety is ok because our reference was
629
624
// either unique to begin with, or became one upon cloning the contents.
630
625
unsafe {
631
- let inner = & mut * * this. ptr ;
626
+ let inner = & mut * this. ptr . as_mut_ptr ( ) ;
632
627
& mut inner. data
633
628
}
634
629
}
@@ -671,7 +666,7 @@ impl<T: ?Sized> Arc<T> {
671
666
// the Arc itself to be `mut`, so we're returning the only possible
672
667
// reference to the inner data.
673
668
unsafe {
674
- let inner = & mut * * this. ptr ;
669
+ let inner = & mut * this. ptr . as_mut_ptr ( ) ;
675
670
Some ( & mut inner. data )
676
671
}
677
672
} else {
0 commit comments