1
1
//! Def-use analysis.
2
2
3
- use rustc:: mir:: { Body , Local , Location , PlaceElem , VarDebugInfo } ;
3
+ use rustc:: mir:: { Body , BodyCache , Local , Location , PlaceElem , ReadOnlyBodyCache , VarDebugInfo } ;
4
4
use rustc:: mir:: visit:: { PlaceContext , MutVisitor , Visitor } ;
5
5
use rustc:: ty:: TyCtxt ;
6
6
use rustc_index:: vec:: IndexVec ;
@@ -30,15 +30,15 @@ impl DefUseAnalysis {
30
30
}
31
31
}
32
32
33
- pub fn analyze ( & mut self , body : & Body < ' _ > ) {
33
+ pub fn analyze ( & mut self , body_cache : & ReadOnlyBodyCache < ' _ , ' _ > ) {
34
34
self . clear ( ) ;
35
35
36
36
let mut finder = DefUseFinder {
37
37
info : mem:: take ( & mut self . info ) ,
38
38
var_debug_info_index : 0 ,
39
39
in_var_debug_info : false ,
40
40
} ;
41
- finder. visit_body ( body ) ;
41
+ finder. visit_body ( body_cache ) ;
42
42
self . info = finder. info
43
43
}
44
44
@@ -55,28 +55,28 @@ impl DefUseAnalysis {
55
55
fn mutate_defs_and_uses (
56
56
& self ,
57
57
local : Local ,
58
- body : & mut Body < ' tcx > ,
58
+ body_cache : & mut BodyCache < & mut Body < ' tcx > > ,
59
59
new_local : Local ,
60
60
tcx : TyCtxt < ' tcx > ,
61
61
) {
62
- let mut visitor = MutateUseVisitor :: new ( local, new_local, body , tcx) ;
62
+ let mut visitor = MutateUseVisitor :: new ( local, new_local, tcx) ;
63
63
let info = & self . info [ local] ;
64
64
for place_use in & info. defs_and_uses {
65
- visitor. visit_location ( body , place_use. location )
65
+ visitor. visit_location ( body_cache , place_use. location )
66
66
}
67
67
// Update debuginfo as well, alongside defs/uses.
68
68
for & i in & info. var_debug_info_indices {
69
- visitor. visit_var_debug_info ( & mut body . var_debug_info [ i] ) ;
69
+ visitor. visit_var_debug_info ( & mut body_cache . var_debug_info [ i] ) ;
70
70
}
71
71
}
72
72
73
73
// FIXME(pcwalton): this should update the def-use chains.
74
74
pub fn replace_all_defs_and_uses_with ( & self ,
75
75
local : Local ,
76
- body : & mut Body < ' tcx > ,
76
+ body_cache : & mut BodyCache < & mut Body < ' tcx > > ,
77
77
new_local : Local ,
78
78
tcx : TyCtxt < ' tcx > ) {
79
- self . mutate_defs_and_uses ( local, body , new_local, tcx)
79
+ self . mutate_defs_and_uses ( local, body_cache , new_local, tcx)
80
80
}
81
81
}
82
82
@@ -156,7 +156,6 @@ impl MutateUseVisitor<'tcx> {
156
156
fn new (
157
157
query : Local ,
158
158
new_local : Local ,
159
- _: & Body < ' tcx > ,
160
159
tcx : TyCtxt < ' tcx > ,
161
160
) -> MutateUseVisitor < ' tcx > {
162
161
MutateUseVisitor { query, new_local, tcx }
0 commit comments