File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -2172,7 +2172,6 @@ where
21722172struct InPlaceDrop < T > {
21732173 inner : * mut T ,
21742174 dst : * mut T ,
2175- did_panic : bool ,
21762175}
21772176
21782177impl < T > InPlaceDrop < T > {
@@ -2185,9 +2184,7 @@ impl<T> Drop for InPlaceDrop<T> {
21852184 #[ inline]
21862185 fn drop ( & mut self ) {
21872186 unsafe {
2188- if self . did_panic {
2189- ptr:: drop_in_place ( slice:: from_raw_parts_mut ( self . inner , self . len ( ) ) as * mut _ ) ;
2190- }
2187+ ptr:: drop_in_place ( slice:: from_raw_parts_mut ( self . inner , self . len ( ) ) as * mut _ ) ;
21912188 }
21922189 }
21932190}
@@ -2240,7 +2237,7 @@ where
22402237
22412238 let dst = if mem:: needs_drop :: < T > ( ) {
22422239 // special-case drop handling since it prevents vectorization
2243- let mut sink = InPlaceDrop { inner : src_buf, dst, did_panic : true } ;
2240+ let mut sink = InPlaceDrop { inner : src_buf, dst } ;
22442241 let _ = iterator. try_for_each :: < _ , Result < _ , !> > ( |item| {
22452242 unsafe {
22462243 debug_assert ! (
@@ -2252,7 +2249,8 @@ where
22522249 }
22532250 Ok ( ( ) )
22542251 } ) ;
2255- sink. did_panic = false ;
2252+ // iteration succeeded, don't drop head
2253+ let sink = mem:: ManuallyDrop :: new ( sink) ;
22562254 sink. dst
22572255 } else {
22582256 // use try-fold
You can’t perform that action at this time.
0 commit comments