@@ -28,8 +28,6 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
28
28
let mut last_len = 0 ;
29
29
let mut last_deref_idx = 0 ;
30
30
31
- let mut prev_temp: Option < Local > = None ;
32
-
33
31
for ( idx, elem) in place. projection [ 0 ..] . iter ( ) . enumerate ( ) {
34
32
if * elem == ProjectionElem :: Deref {
35
33
last_deref_idx = idx;
@@ -39,14 +37,12 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
39
37
for ( idx, ( p_ref, p_elem) ) in place. iter_projections ( ) . enumerate ( ) {
40
38
if !p_ref. projection . is_empty ( ) && p_elem == ProjectionElem :: Deref {
41
39
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 (
43
41
ty,
44
42
self . local_decls [ p_ref. local ] . source_info . span ,
45
43
Some ( Box :: new ( LocalInfo :: DerefTemp ) ) ,
46
44
) ;
47
45
48
- self . patcher . add_statement ( loc, StatementKind :: StorageLive ( temp) ) ;
49
-
50
46
// We are adding current p_ref's projections to our
51
47
// temp value, excluding projections we already covered.
52
48
let deref_place = Place :: from ( place_local)
@@ -66,22 +62,8 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
66
62
Place :: from ( temp) . project_deeper ( & place. projection [ idx..] , self . tcx ) ;
67
63
* place = temp_place;
68
64
}
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) ;
76
65
}
77
66
}
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
- }
85
67
}
86
68
}
87
69
}
0 commit comments