@@ -124,9 +124,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
124
124
#[ unsafe_no_drop_flag]
125
125
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
126
126
pub struct Arc < T : ?Sized > {
127
- // FIXME #12808: strange name to try to avoid interfering with
128
- // field accesses of the contained type via Deref
129
- _ptr : Shared < ArcInner < T > > ,
127
+ ptr : Shared < ArcInner < T > > ,
130
128
}
131
129
132
130
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -144,9 +142,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
144
142
#[ unsafe_no_drop_flag]
145
143
#[ stable( feature = "arc_weak" , since = "1.4.0" ) ]
146
144
pub struct Weak < T : ?Sized > {
147
- // FIXME #12808: strange name to try to avoid interfering with
148
- // field accesses of the contained type via Deref
149
- _ptr : Shared < ArcInner < T > > ,
145
+ ptr : Shared < ArcInner < T > > ,
150
146
}
151
147
152
148
#[ stable( feature = "arc_weak" , since = "1.4.0" ) ]
@@ -198,7 +194,7 @@ impl<T> Arc<T> {
198
194
weak : atomic:: AtomicUsize :: new ( 1 ) ,
199
195
data : data,
200
196
} ;
201
- Arc { _ptr : unsafe { Shared :: new ( Box :: into_raw ( x) ) } }
197
+ Arc { ptr : unsafe { Shared :: new ( Box :: into_raw ( x) ) } }
202
198
}
203
199
204
200
/// Unwraps the contained value if the `Arc<T>` has exactly one strong reference.
@@ -230,11 +226,11 @@ impl<T> Arc<T> {
230
226
atomic:: fence ( Acquire ) ;
231
227
232
228
unsafe {
233
- let ptr = * this. _ptr ;
229
+ let ptr = * this. ptr ;
234
230
let elem = ptr:: read ( & ( * ptr) . data ) ;
235
231
236
232
// Make a weak pointer to clean up the implicit strong-weak reference
237
- let _weak = Weak { _ptr : this. _ptr } ;
233
+ let _weak = Weak { ptr : this. ptr } ;
238
234
mem:: forget ( this) ;
239
235
240
236
Ok ( elem)
@@ -274,7 +270,7 @@ impl<T: ?Sized> Arc<T> {
274
270
// synchronize with the write coming from `is_unique`, so that the
275
271
// events prior to that write happen before this read.
276
272
match this. inner ( ) . weak . compare_exchange_weak ( cur, cur + 1 , Acquire , Relaxed ) {
277
- Ok ( _) => return Weak { _ptr : this. _ptr } ,
273
+ Ok ( _) => return Weak { ptr : this. ptr } ,
278
274
Err ( old) => cur = old,
279
275
}
280
276
}
@@ -303,13 +299,13 @@ impl<T: ?Sized> Arc<T> {
303
299
// `ArcInner` structure itself is `Sync` because the inner data is
304
300
// `Sync` as well, so we're ok loaning out an immutable pointer to these
305
301
// contents.
306
- unsafe { & * * self . _ptr }
302
+ unsafe { & * * self . ptr }
307
303
}
308
304
309
305
// Non-inlined part of `drop`.
310
306
#[ inline( never) ]
311
307
unsafe fn drop_slow ( & mut self ) {
312
- let ptr = * self . _ptr ;
308
+ let ptr = * self . ptr ;
313
309
314
310
// Destroy the data at this time, even though we may not free the box
315
311
// allocation itself (there may still be weak pointers lying around).
@@ -367,7 +363,7 @@ impl<T: ?Sized> Clone for Arc<T> {
367
363
}
368
364
}
369
365
370
- Arc { _ptr : self . _ptr }
366
+ Arc { ptr : self . ptr }
371
367
}
372
368
}
373
369
@@ -435,15 +431,15 @@ impl<T: Clone> Arc<T> {
435
431
436
432
// Materialize our own implicit weak pointer, so that it can clean
437
433
// up the ArcInner as needed.
438
- let weak = Weak { _ptr : this. _ptr } ;
434
+ let weak = Weak { ptr : this. ptr } ;
439
435
440
436
// mark the data itself as already deallocated
441
437
unsafe {
442
438
// there is no data race in the implicit write caused by `read`
443
439
// here (due to zeroing) because data is no longer accessed by
444
440
// other threads (due to there being no more strong refs at this
445
441
// point).
446
- let mut swap = Arc :: new ( ptr:: read ( & ( * * weak. _ptr ) . data ) ) ;
442
+ let mut swap = Arc :: new ( ptr:: read ( & ( * * weak. ptr ) . data ) ) ;
447
443
mem:: swap ( this, & mut swap) ;
448
444
mem:: forget ( swap) ;
449
445
}
@@ -456,7 +452,7 @@ impl<T: Clone> Arc<T> {
456
452
// As with `get_mut()`, the unsafety is ok because our reference was
457
453
// either unique to begin with, or became one upon cloning the contents.
458
454
unsafe {
459
- let inner = & mut * * this. _ptr ;
455
+ let inner = & mut * * this. ptr ;
460
456
& mut inner. data
461
457
}
462
458
}
@@ -488,7 +484,7 @@ impl<T: ?Sized> Arc<T> {
488
484
// the Arc itself to be `mut`, so we're returning the only possible
489
485
// reference to the inner data.
490
486
unsafe {
491
- let inner = & mut * * this. _ptr ;
487
+ let inner = & mut * * this. ptr ;
492
488
Some ( & mut inner. data )
493
489
}
494
490
} else {
@@ -557,7 +553,7 @@ impl<T: ?Sized> Drop for Arc<T> {
557
553
// This structure has #[unsafe_no_drop_flag], so this drop glue may run
558
554
// more than once (but it is guaranteed to be zeroed after the first if
559
555
// it's run more than once)
560
- let thin = * self . _ptr as * const ( ) ;
556
+ let thin = * self . ptr as * const ( ) ;
561
557
562
558
if thin as usize == mem:: POST_DROP_USIZE {
563
559
return ;
@@ -638,7 +634,7 @@ impl<T: ?Sized> Weak<T> {
638
634
639
635
// Relaxed is valid for the same reason it is on Arc's Clone impl
640
636
match inner. strong . compare_exchange_weak ( n, n + 1 , Relaxed , Relaxed ) {
641
- Ok ( _) => return Some ( Arc { _ptr : self . _ptr } ) ,
637
+ Ok ( _) => return Some ( Arc { ptr : self . ptr } ) ,
642
638
Err ( old) => n = old,
643
639
}
644
640
}
@@ -647,7 +643,7 @@ impl<T: ?Sized> Weak<T> {
647
643
#[ inline]
648
644
fn inner ( & self ) -> & ArcInner < T > {
649
645
// See comments above for why this is "safe"
650
- unsafe { & * * self . _ptr }
646
+ unsafe { & * * self . ptr }
651
647
}
652
648
}
653
649
@@ -681,7 +677,7 @@ impl<T: ?Sized> Clone for Weak<T> {
681
677
}
682
678
}
683
679
684
- return Weak { _ptr : self . _ptr } ;
680
+ return Weak { ptr : self . ptr } ;
685
681
}
686
682
}
687
683
@@ -713,7 +709,7 @@ impl<T: ?Sized> Drop for Weak<T> {
713
709
/// } // implicit drop
714
710
/// ```
715
711
fn drop ( & mut self ) {
716
- let ptr = * self . _ptr ;
712
+ let ptr = * self . ptr ;
717
713
let thin = ptr as * const ( ) ;
718
714
719
715
// see comments above for why this check is here
@@ -885,7 +881,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
885
881
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
886
882
impl < T : ?Sized > fmt:: Pointer for Arc < T > {
887
883
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
888
- fmt:: Pointer :: fmt ( & * self . _ptr , f)
884
+ fmt:: Pointer :: fmt ( & * self . ptr , f)
889
885
}
890
886
}
891
887
@@ -930,7 +926,7 @@ impl<T> Weak<T> {
930
926
issue = "30425" ) ]
931
927
pub fn new ( ) -> Weak < T > {
932
928
unsafe {
933
- Weak { _ptr : Shared :: new ( Box :: into_raw ( box ArcInner {
929
+ Weak { ptr : Shared :: new ( Box :: into_raw ( box ArcInner {
934
930
strong : atomic:: AtomicUsize :: new ( 0 ) ,
935
931
weak : atomic:: AtomicUsize :: new ( 1 ) ,
936
932
data : uninitialized ( ) ,
0 commit comments