11//! Def-use analysis.
22
3- use rustc:: mir:: { Body , Local , Location , PlaceElem , VarDebugInfo } ;
3+ use rustc:: mir:: { Body , BodyCache , Local , Location , PlaceElem , ReadOnlyBodyCache , VarDebugInfo } ;
44use rustc:: mir:: visit:: { PlaceContext , MutVisitor , Visitor } ;
55use rustc:: ty:: TyCtxt ;
66use rustc_index:: vec:: IndexVec ;
@@ -30,15 +30,15 @@ impl DefUseAnalysis {
3030 }
3131 }
3232
33- pub fn analyze ( & mut self , body : & Body < ' _ > ) {
33+ pub fn analyze ( & mut self , body_cache : & ReadOnlyBodyCache < ' _ , ' _ > ) {
3434 self . clear ( ) ;
3535
3636 let mut finder = DefUseFinder {
3737 info : mem:: take ( & mut self . info ) ,
3838 var_debug_info_index : 0 ,
3939 in_var_debug_info : false ,
4040 } ;
41- finder. visit_body ( body ) ;
41+ finder. visit_body ( body_cache ) ;
4242 self . info = finder. info
4343 }
4444
@@ -55,28 +55,28 @@ impl DefUseAnalysis {
5555 fn mutate_defs_and_uses (
5656 & self ,
5757 local : Local ,
58- body : & mut Body < ' tcx > ,
58+ body_cache : & mut BodyCache < & mut Body < ' tcx > > ,
5959 new_local : Local ,
6060 tcx : TyCtxt < ' tcx > ,
6161 ) {
62- let mut visitor = MutateUseVisitor :: new ( local, new_local, body , tcx) ;
62+ let mut visitor = MutateUseVisitor :: new ( local, new_local, tcx) ;
6363 let info = & self . info [ local] ;
6464 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 )
6666 }
6767 // Update debuginfo as well, alongside defs/uses.
6868 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] ) ;
7070 }
7171 }
7272
7373 // FIXME(pcwalton): this should update the def-use chains.
7474 pub fn replace_all_defs_and_uses_with ( & self ,
7575 local : Local ,
76- body : & mut Body < ' tcx > ,
76+ body_cache : & mut BodyCache < & mut Body < ' tcx > > ,
7777 new_local : Local ,
7878 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)
8080 }
8181}
8282
@@ -156,7 +156,6 @@ impl MutateUseVisitor<'tcx> {
156156 fn new (
157157 query : Local ,
158158 new_local : Local ,
159- _: & Body < ' tcx > ,
160159 tcx : TyCtxt < ' tcx > ,
161160 ) -> MutateUseVisitor < ' tcx > {
162161 MutateUseVisitor { query, new_local, tcx }
0 commit comments