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