File tree 4 files changed +15
-10
lines changed
4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -1080,7 +1080,7 @@ pub enum LocalInfo<'tcx> {
1080
1080
/// (e.g. a temporary for `foo` in `MyStruct { my_field: foo }`)
1081
1081
AggregateTemp ,
1082
1082
/// A temporary created during the pass `Derefer` to avoid it's retagging
1083
- Temp ,
1083
+ DerefTemp ,
1084
1084
}
1085
1085
1086
1086
impl < ' tcx > LocalDecl < ' tcx > {
Original file line number Diff line number Diff line change @@ -78,20 +78,22 @@ impl<'tcx> MirPatch<'tcx> {
78
78
Location { block : bb, statement_index : offset }
79
79
}
80
80
81
- pub fn new_local_temp ( & mut self , ty : Ty < ' tcx > , span : Span ) -> Local {
81
+ pub fn new_local_with_info (
82
+ & mut self ,
83
+ ty : Ty < ' tcx > ,
84
+ span : Span ,
85
+ local_info : Option < Box < LocalInfo < ' tcx > > > ,
86
+ ) -> Local {
82
87
let index = self . next_local ;
83
88
self . next_local += 1 ;
84
89
let mut new_decl = LocalDecl :: new ( ty, span) ;
85
- new_decl. local_info = Some ( Box :: new ( LocalInfo :: Temp ) ) ;
90
+ new_decl. local_info = local_info ;
86
91
self . new_locals . push ( new_decl) ;
87
92
Local :: new ( index as usize )
88
93
}
89
94
90
95
pub fn new_temp ( & mut self , ty : Ty < ' tcx > , span : Span ) -> Local {
91
- let index = self . next_local ;
92
- self . next_local += 1 ;
93
- self . new_locals . push ( LocalDecl :: new ( ty, span) ) ;
94
- Local :: new ( index as usize )
96
+ self . new_local_with_info ( ty, span, None )
95
97
}
96
98
97
99
pub fn new_internal ( & mut self , ty : Ty < ' tcx > , span : Span ) -> Local {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ fn may_be_reference(ty: Ty<'_>) -> bool {
61
61
fn is_not_temp < ' tcx > ( local_decl : & LocalDecl < ' tcx > ) -> bool {
62
62
if let Some ( local_info) = & local_decl. local_info {
63
63
match local_info. as_ref ( ) {
64
- LocalInfo :: Temp => return false ,
64
+ LocalInfo :: DerefTemp => return false ,
65
65
_ => ( ) ,
66
66
} ;
67
67
}
Original file line number Diff line number Diff line change @@ -33,8 +33,11 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
33
33
for ( idx, ( p_ref, p_elem) ) in place. iter_projections ( ) . enumerate ( ) {
34
34
if p_elem == ProjectionElem :: Deref && !p_ref. projection . is_empty ( ) {
35
35
let ty = p_ref. ty ( & self . local_decls , self . tcx ) . ty ;
36
- let temp =
37
- self . patcher . new_local_temp ( ty, self . local_decls [ p_ref. local ] . source_info . span ) ;
36
+ let temp = self . patcher . new_local_with_info (
37
+ ty,
38
+ self . local_decls [ p_ref. local ] . source_info . span ,
39
+ Some ( Box :: new ( LocalInfo :: DerefTemp ) ) ,
40
+ ) ;
38
41
39
42
self . patcher . add_statement ( loc, StatementKind :: StorageLive ( temp) ) ;
40
43
You can’t perform that action at this time.
0 commit comments