@@ -295,6 +295,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
295295impl < T : ?Sized + Unsize < U > , U : ?Sized > DispatchFromDyn < Rc < U > > for Rc < T > { }
296296
297297impl < T : ?Sized > Rc < T > {
298+ #[ inline( always) ]
299+ fn inner ( & self ) -> & RcBox < T > {
300+ // This unsafety is ok because while this Rc is alive we're guaranteed
301+ // that the inner pointer is valid.
302+ unsafe { self . ptr . as_ref ( ) }
303+ }
304+
298305 fn from_inner ( ptr : NonNull < RcBox < T > > ) -> Self {
299306 Self { ptr, phantom : PhantomData }
300307 }
@@ -845,17 +852,10 @@ impl<T: ?Sized> Rc<T> {
845852 #[ unstable( feature = "get_mut_unchecked" , issue = "63292" ) ]
846853 pub unsafe fn get_mut_unchecked ( this : & mut Self ) -> & mut T {
847854 // We are careful to *not* create a reference covering the "count" fields, as
848- // this would alias with concurrent access to the reference counts (e.g. by `Weak`).
855+ // this would conflict with accesses to the reference counts (e.g. by `Weak`).
849856 unsafe { & mut ( * this. ptr . as_ptr ( ) ) . value }
850857 }
851858
852- #[ inline]
853- fn inner ( & self ) -> & RcBox < T > {
854- // This unsafety is ok because while this Rc is alive we're guaranteed
855- // that the inner pointer is valid.
856- unsafe { self . ptr . as_ref ( ) }
857- }
858-
859859 #[ inline]
860860 #[ stable( feature = "ptr_eq" , since = "1.17.0" ) ]
861861 /// Returns `true` if the two `Rc`s point to the same allocation
@@ -2145,18 +2145,24 @@ trait RcInnerPtr {
21452145}
21462146
21472147impl < T : ?Sized > RcInnerPtr for RcBox < T > {
2148+ #[ inline( always) ]
21482149 fn weak_ref ( & self ) -> & Cell < usize > {
21492150 & self . weak
21502151 }
2152+
2153+ #[ inline( always) ]
21512154 fn strong_ref ( & self ) -> & Cell < usize > {
21522155 & self . strong
21532156 }
21542157}
21552158
21562159impl < ' a > RcInnerPtr for WeakInner < ' a > {
2160+ #[ inline( always) ]
21572161 fn weak_ref ( & self ) -> & Cell < usize > {
21582162 self . weak
21592163 }
2164+
2165+ #[ inline( always) ]
21602166 fn strong_ref ( & self ) -> & Cell < usize > {
21612167 self . strong
21622168 }
0 commit comments