@@ -295,6 +295,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
295
295
impl < T : ?Sized + Unsize < U > , U : ?Sized > DispatchFromDyn < Rc < U > > for Rc < T > { }
296
296
297
297
impl < 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
+
298
305
fn from_inner ( ptr : NonNull < RcBox < T > > ) -> Self {
299
306
Self { ptr, phantom : PhantomData }
300
307
}
@@ -845,17 +852,10 @@ impl<T: ?Sized> Rc<T> {
845
852
#[ unstable( feature = "get_mut_unchecked" , issue = "63292" ) ]
846
853
pub unsafe fn get_mut_unchecked ( this : & mut Self ) -> & mut T {
847
854
// 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`).
849
856
unsafe { & mut ( * this. ptr . as_ptr ( ) ) . value }
850
857
}
851
858
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
-
859
859
#[ inline]
860
860
#[ stable( feature = "ptr_eq" , since = "1.17.0" ) ]
861
861
/// Returns `true` if the two `Rc`s point to the same allocation
@@ -2145,18 +2145,24 @@ trait RcInnerPtr {
2145
2145
}
2146
2146
2147
2147
impl < T : ?Sized > RcInnerPtr for RcBox < T > {
2148
+ #[ inline( always) ]
2148
2149
fn weak_ref ( & self ) -> & Cell < usize > {
2149
2150
& self . weak
2150
2151
}
2152
+
2153
+ #[ inline( always) ]
2151
2154
fn strong_ref ( & self ) -> & Cell < usize > {
2152
2155
& self . strong
2153
2156
}
2154
2157
}
2155
2158
2156
2159
impl < ' a > RcInnerPtr for WeakInner < ' a > {
2160
+ #[ inline( always) ]
2157
2161
fn weak_ref ( & self ) -> & Cell < usize > {
2158
2162
self . weak
2159
2163
}
2164
+
2165
+ #[ inline( always) ]
2160
2166
fn strong_ref ( & self ) -> & Cell < usize > {
2161
2167
self . strong
2162
2168
}
0 commit comments