@@ -2298,20 +2298,21 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
2298
2298
#[ stable( feature = "pin" , since = "1.33.0" ) ]
2299
2299
impl < T : ?Sized > Unpin for Arc < T > { }
2300
2300
2301
- /// Computes the offset of the data field within ArcInner.
2301
+ /// Computes the offset of the data field within ` ArcInner` .
2302
2302
unsafe 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) )
2308
2306
}
2309
2307
2310
- /// Computes the offset of the data field within ArcInner.
2308
+ /// Computes the offset of the data field within ` ArcInner` .
2311
2309
///
2312
2310
/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`.
2313
2311
fn 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 {
2315
2316
let layout = Layout :: new :: < ArcInner < ( ) > > ( ) ;
2316
2317
( layout. size ( ) + layout. padding_needed_for ( align) ) as isize
2317
2318
}
0 commit comments