@@ -28,8 +28,6 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
2828 let mut last_len = 0 ;
2929 let mut last_deref_idx = 0 ;
3030
31- let mut prev_temp: Option < Local > = None ;
32-
3331 for ( idx, elem) in place. projection [ 0 ..] . iter ( ) . enumerate ( ) {
3432 if * elem == ProjectionElem :: Deref {
3533 last_deref_idx = idx;
@@ -39,14 +37,12 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
3937 for ( idx, ( p_ref, p_elem) ) in place. iter_projections ( ) . enumerate ( ) {
4038 if !p_ref. projection . is_empty ( ) && p_elem == ProjectionElem :: Deref {
4139 let ty = p_ref. ty ( & self . local_decls , self . tcx ) . ty ;
42- let temp = self . patcher . new_local_with_info (
40+ let temp = self . patcher . new_internal_with_info (
4341 ty,
4442 self . local_decls [ p_ref. local ] . source_info . span ,
4543 Some ( Box :: new ( LocalInfo :: DerefTemp ) ) ,
4644 ) ;
4745
48- self . patcher . add_statement ( loc, StatementKind :: StorageLive ( temp) ) ;
49-
5046 // We are adding current p_ref's projections to our
5147 // temp value, excluding projections we already covered.
5248 let deref_place = Place :: from ( place_local)
@@ -66,22 +62,8 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
6662 Place :: from ( temp) . project_deeper ( & place. projection [ idx..] , self . tcx ) ;
6763 * place = temp_place;
6864 }
69-
70- // We are destroying the previous temp since it's no longer used.
71- if let Some ( prev_temp) = prev_temp {
72- self . patcher . add_statement ( loc, StatementKind :: StorageDead ( prev_temp) ) ;
73- }
74-
75- prev_temp = Some ( temp) ;
7665 }
7766 }
78-
79- // Since we won't be able to reach final temp, we destroy it outside the loop.
80- if let Some ( prev_temp) = prev_temp {
81- let last_loc =
82- Location { block : loc. block , statement_index : loc. statement_index + 1 } ;
83- self . patcher . add_statement ( last_loc, StatementKind :: StorageDead ( prev_temp) ) ;
84- }
8567 }
8668 }
8769}
0 commit comments