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 @@ -2066,7 +2066,6 @@ where
20662066struct InPlaceDrop < T > {
20672067 inner : * mut T ,
20682068 dst : * mut T ,
2069- did_panic : bool ,
20702069}
20712070
20722071impl < T > InPlaceDrop < T > {
@@ -2079,9 +2078,7 @@ impl<T> Drop for InPlaceDrop<T> {
20792078 #[ inline]
20802079 fn drop ( & mut self ) {
20812080 unsafe {
2082- if self . did_panic {
2083- ptr:: drop_in_place ( slice:: from_raw_parts_mut ( self . inner , self . len ( ) ) as * mut _ ) ;
2084- }
2081+ ptr:: drop_in_place ( slice:: from_raw_parts_mut ( self . inner , self . len ( ) ) as * mut _ ) ;
20852082 }
20862083 }
20872084}
@@ -2135,7 +2132,7 @@ where
21352132
21362133 let dst = if mem:: needs_drop :: < T > ( ) {
21372134 // special-case drop handling since it prevents vectorization
2138- let mut sink = InPlaceDrop { inner : src_buf, dst, did_panic : true } ;
2135+ let mut sink = InPlaceDrop { inner : src_buf, dst } ;
21392136 let _ = iterator. try_for_each :: < _ , Result < _ , !> > ( |item| {
21402137 unsafe {
21412138 debug_assert ! (
@@ -2147,7 +2144,8 @@ where
21472144 }
21482145 Ok ( ( ) )
21492146 } ) ;
2150- sink. did_panic = false ;
2147+ // iteration succeeded, don't drop head
2148+ let sink = mem:: ManuallyDrop :: new ( sink) ;
21512149 sink. dst
21522150 } else {
21532151 // use try-fold
You can’t perform that action at this time.
0 commit comments