@@ -4,7 +4,7 @@ use std::{
44 cmp:: Ordering ,
55 hash:: { Hash , Hasher } ,
66 marker:: PhantomData ,
7- mem:: { self , offset_of , ManuallyDrop } ,
7+ mem:: { self , ManuallyDrop , offset_of } ,
88 ops:: Deref ,
99 ptr,
1010 sync:: atomic:: {
@@ -55,14 +55,17 @@ impl<T> Arc<T> {
5555 pub ( crate ) unsafe fn from_raw ( ptr : * const T ) -> Self {
5656 // To find the corresponding pointer to the `ArcInner` we need
5757 // to subtract the offset of the `data` field from the pointer.
58- let ptr = ( ptr as * const u8 ) . sub ( offset_of ! ( ArcInner <T >, data) ) ;
59- Arc { p : ptr:: NonNull :: new_unchecked ( ptr as * mut ArcInner < T > ) , phantom : PhantomData }
58+ unsafe {
59+ let ptr = ( ptr as * const u8 ) . sub ( offset_of ! ( ArcInner <T >, data) ) ;
60+ Arc { p : ptr:: NonNull :: new_unchecked ( ptr as * mut ArcInner < T > ) , phantom : PhantomData }
61+ }
6062 }
6163}
6264
6365impl < T : ?Sized > Arc < T > {
6466 #[ inline]
6567 fn inner ( & self ) -> & ArcInner < T > {
68+ // SAFETY:
6669 // This unsafety is ok because while this arc is alive we're guaranteed
6770 // that the inner pointer is valid. Furthermore, we know that the
6871 // `ArcInner` structure itself is `Sync` because the inner data is
@@ -74,7 +77,9 @@ impl<T: ?Sized> Arc<T> {
7477 // Non-inlined part of `drop`. Just invokes the destructor.
7578 #[ inline( never) ]
7679 unsafe fn drop_slow ( & mut self ) {
77- let _ = Box :: from_raw ( self . ptr ( ) ) ;
80+ unsafe {
81+ let _ = Box :: from_raw ( self . ptr ( ) ) ;
82+ }
7883 }
7984
8085 /// Test pointer equality between the two Arcs, i.e. they must be the _same_
@@ -195,10 +200,6 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
195200 fn eq ( & self , other : & Arc < T > ) -> bool {
196201 Self :: ptr_eq ( self , other) || * ( * self ) == * ( * other)
197202 }
198-
199- fn ne ( & self , other : & Arc < T > ) -> bool {
200- !Self :: ptr_eq ( self , other) && * ( * self ) != * ( * other)
201- }
202203}
203204
204205impl < T : ?Sized + PartialOrd > PartialOrd for Arc < T > {
@@ -312,10 +313,7 @@ impl<H, T> ThinArc<H, T> {
312313 } ;
313314
314315 // Expose the transient Arc to the callback, which may clone it if it wants.
315- let result = f ( & transient) ;
316-
317- // Forward the result.
318- result
316+ f ( & transient)
319317 }
320318
321319 /// Creates a `ThinArc` for a HeaderSlice using the given header struct and
0 commit comments