@@ -174,61 +174,17 @@ struct RcBox<T> {
174
174
/// See the [module level documentation](../index.html) for more details.
175
175
#[ unsafe_no_drop_flag]
176
176
#[ stable]
177
- #[ cfg( stage0) ] // NOTE remove impl after next snapshot
178
177
pub struct Rc < T > {
179
178
// FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
180
179
// type via Deref
181
180
_ptr : NonZero < * mut RcBox < T > > ,
182
- _nosend : marker:: NoSend ,
183
- _noshare : marker:: NoSync
184
181
}
185
182
186
- /// An immutable reference-counted pointer type.
187
- ///
188
- /// See the [module level documentation](../index.html) for more details.
189
- #[ unsafe_no_drop_flag]
190
- #[ stable]
191
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
192
- pub struct Rc < T > {
193
- // FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
194
- // type via Deref
195
- _ptr : NonZero < * mut RcBox < T > > ,
196
- }
197
-
198
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
199
183
impl < T > !marker:: Send for Rc < T > { }
200
184
201
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
202
185
impl < T > !marker:: Sync for Rc < T > { }
203
186
204
187
impl < T > Rc < T > {
205
- /// Constructs a new `Rc<T>`.
206
- ///
207
- /// # Examples
208
- ///
209
- /// ```
210
- /// use std::rc::Rc;
211
- ///
212
- /// let five = Rc::new(5i);
213
- /// ```
214
- #[ stable]
215
- #[ cfg( stage0) ] // NOTE remove after next snapshot
216
- pub fn new ( value : T ) -> Rc < T > {
217
- unsafe {
218
- Rc {
219
- // there is an implicit weak pointer owned by all the strong pointers, which
220
- // ensures that the weak destructor never frees the allocation while the strong
221
- // destructor is running, even if the weak pointer is stored inside the strong one.
222
- _ptr : NonZero :: new ( transmute ( box RcBox {
223
- value : value,
224
- strong : Cell :: new ( 1 ) ,
225
- weak : Cell :: new ( 1 )
226
- } ) ) ,
227
- _nosend : marker:: NoSend ,
228
- _noshare : marker:: NoSync
229
- }
230
- }
231
- }
232
188
233
189
/// Constructs a new `Rc<T>`.
234
190
///
@@ -240,7 +196,6 @@ impl<T> Rc<T> {
240
196
/// let five = Rc::new(5i);
241
197
/// ```
242
198
#[ stable]
243
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
244
199
pub fn new ( value : T ) -> Rc < T > {
245
200
unsafe {
246
201
Rc {
@@ -267,29 +222,6 @@ impl<T> Rc<T> {
267
222
///
268
223
/// let weak_five = five.downgrade();
269
224
/// ```
270
- #[ cfg( stage0) ] // NOTE remove after next snapshot
271
- #[ unstable = "Weak pointers may not belong in this module" ]
272
- pub fn downgrade ( & self ) -> Weak < T > {
273
- self . inc_weak ( ) ;
274
- Weak {
275
- _ptr : self . _ptr ,
276
- _nosend : marker:: NoSend ,
277
- _noshare : marker:: NoSync
278
- }
279
- }
280
-
281
- /// Downgrades the `Rc<T>` to a `Weak<T>` reference.
282
- ///
283
- /// # Examples
284
- ///
285
- /// ```
286
- /// use std::rc::Rc;
287
- ///
288
- /// let five = Rc::new(5i);
289
- ///
290
- /// let weak_five = five.downgrade();
291
- /// ```
292
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
293
225
#[ unstable = "Weak pointers may not belong in this module" ]
294
226
pub fn downgrade ( & self ) -> Weak < T > {
295
227
self . inc_weak ( ) ;
@@ -483,25 +415,6 @@ impl<T> Drop for Rc<T> {
483
415
484
416
#[ stable]
485
417
impl < T > Clone for Rc < T > {
486
- /// Makes a clone of the `Rc<T>`.
487
- ///
488
- /// This increases the strong reference count.
489
- ///
490
- /// # Examples
491
- ///
492
- /// ```
493
- /// use std::rc::Rc;
494
- ///
495
- /// let five = Rc::new(5i);
496
- ///
497
- /// five.clone();
498
- /// ```
499
- #[ inline]
500
- #[ cfg( stage0) ] // NOTE remove after next snapshot
501
- fn clone ( & self ) -> Rc < T > {
502
- self . inc_strong ( ) ;
503
- Rc { _ptr : self . _ptr , _nosend : marker:: NoSend , _noshare : marker:: NoSync }
504
- }
505
418
506
419
/// Makes a clone of the `Rc<T>`.
507
420
///
@@ -517,7 +430,6 @@ impl<T> Clone for Rc<T> {
517
430
/// five.clone();
518
431
/// ```
519
432
#[ inline]
520
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
521
433
fn clone ( & self ) -> Rc < T > {
522
434
self . inc_strong ( ) ;
523
435
Rc { _ptr : self . _ptr }
@@ -714,66 +626,21 @@ impl<T: fmt::String> fmt::String for Rc<T> {
714
626
/// See the [module level documentation](../index.html) for more.
715
627
#[ unsafe_no_drop_flag]
716
628
#[ unstable = "Weak pointers may not belong in this module." ]
717
- #[ cfg( stage0) ] // NOTE remove impl after next snapshot
718
629
pub struct Weak < T > {
719
630
// FIXME #12808: strange names to try to avoid interfering with
720
631
// field accesses of the contained type via Deref
721
632
_ptr : NonZero < * mut RcBox < T > > ,
722
- _nosend : marker:: NoSend ,
723
- _noshare : marker:: NoSync
724
633
}
725
634
726
- /// A weak version of `Rc<T>`.
727
- ///
728
- /// Weak references do not count when determining if the inner value should be dropped.
729
- ///
730
- /// See the [module level documentation](../index.html) for more.
731
- #[ unsafe_no_drop_flag]
732
- #[ unstable = "Weak pointers may not belong in this module." ]
733
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
734
- pub struct Weak < T > {
735
- // FIXME #12808: strange names to try to avoid interfering with
736
- // field accesses of the contained type via Deref
737
- _ptr : NonZero < * mut RcBox < T > > ,
738
- }
739
-
740
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
741
635
#[ allow( unstable) ]
742
636
impl < T > !marker:: Send for Weak < T > { }
743
637
744
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
745
638
#[ allow( unstable) ]
746
639
impl < T > !marker:: Sync for Weak < T > { }
747
640
748
641
749
642
#[ unstable = "Weak pointers may not belong in this module." ]
750
643
impl < T > Weak < T > {
751
- /// Upgrades a weak reference to a strong reference.
752
- ///
753
- /// Upgrades the `Weak<T>` reference to an `Rc<T>`, if possible.
754
- ///
755
- /// Returns `None` if there were no strong references and the data was destroyed.
756
- ///
757
- /// # Examples
758
- ///
759
- /// ```
760
- /// use std::rc::Rc;
761
- ///
762
- /// let five = Rc::new(5i);
763
- ///
764
- /// let weak_five = five.downgrade();
765
- ///
766
- /// let strong_five: Option<Rc<_>> = weak_five.upgrade();
767
- /// ```
768
- #[ cfg( stage0) ] // NOTE remove after next snapshot
769
- pub fn upgrade ( & self ) -> Option < Rc < T > > {
770
- if self . strong ( ) == 0 {
771
- None
772
- } else {
773
- self . inc_strong ( ) ;
774
- Some ( Rc { _ptr : self . _ptr , _nosend : marker:: NoSend , _noshare : marker:: NoSync } )
775
- }
776
- }
777
644
778
645
/// Upgrades a weak reference to a strong reference.
779
646
///
@@ -792,7 +659,6 @@ impl<T> Weak<T> {
792
659
///
793
660
/// let strong_five: Option<Rc<_>> = weak_five.upgrade();
794
661
/// ```
795
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
796
662
pub fn upgrade ( & self ) -> Option < Rc < T > > {
797
663
if self . strong ( ) == 0 {
798
664
None
@@ -849,25 +715,6 @@ impl<T> Drop for Weak<T> {
849
715
850
716
#[ unstable = "Weak pointers may not belong in this module." ]
851
717
impl < T > Clone for Weak < T > {
852
- /// Makes a clone of the `Weak<T>`.
853
- ///
854
- /// This increases the weak reference count.
855
- ///
856
- /// # Examples
857
- ///
858
- /// ```
859
- /// use std::rc::Rc;
860
- ///
861
- /// let weak_five = Rc::new(5i).downgrade();
862
- ///
863
- /// weak_five.clone();
864
- /// ```
865
- #[ inline]
866
- #[ cfg( stage0) ] // NOTE remove after next snapshot
867
- fn clone ( & self ) -> Weak < T > {
868
- self . inc_weak ( ) ;
869
- Weak { _ptr : self . _ptr , _nosend : marker:: NoSend , _noshare : marker:: NoSync }
870
- }
871
718
872
719
/// Makes a clone of the `Weak<T>`.
873
720
///
@@ -883,7 +730,6 @@ impl<T> Clone for Weak<T> {
883
730
/// weak_five.clone();
884
731
/// ```
885
732
#[ inline]
886
- #[ cfg( not( stage0) ) ] // NOTE remove cfg after next snapshot
887
733
fn clone ( & self ) -> Weak < T > {
888
734
self . inc_weak ( ) ;
889
735
Weak { _ptr : self . _ptr }
0 commit comments