@@ -2298,20 +2298,21 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
22982298#[ stable( feature = "pin" , since = "1.33.0" ) ]
22992299impl < T : ?Sized > Unpin for Arc < T > { }
23002300
2301- /// Computes the offset of the data field within ArcInner.
2301+ /// Computes the offset of the data field within ` ArcInner` .
23022302unsafe fn data_offset < T : ?Sized > ( ptr : * const T ) -> isize {
2303- // Align the unsized value to the end of the ArcInner.
2304- // Because it is ?Sized, it will always be the last field in memory.
2305- let align = align_of_val ( & * ptr) ;
2306- let layout = Layout :: new :: < ArcInner < ( ) > > ( ) ;
2307- ( layout. size ( ) + layout. padding_needed_for ( align) ) as isize
2303+ // Align the unsized value to the end of the `ArcInner`.
2304+ // Because it is `?Sized`, it will always be the last field in memory.
2305+ data_offset_align ( align_of_val ( & * ptr) )
23082306}
23092307
2310- /// Computes the offset of the data field within ArcInner.
2308+ /// Computes the offset of the data field within ` ArcInner` .
23112309///
23122310/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`.
23132311fn data_offset_sized < T > ( ) -> isize {
2314- let align = align_of :: < T > ( ) ;
2312+ data_offset_align ( align_of :: < T > ( ) )
2313+ }
2314+
2315+ fn data_offset_align ( align : usize ) -> isize {
23152316 let layout = Layout :: new :: < ArcInner < ( ) > > ( ) ;
23162317 ( layout. size ( ) + layout. padding_needed_for ( align) ) as isize
23172318}
0 commit comments