@@ -789,19 +789,31 @@ macro_rules! make_mir_visitor {
789
789
}
790
790
791
791
// Convenience methods
792
-
793
- fn visit_location( & mut self , body: & $( $mutability) ? Body <' tcx>, location: Location ) {
794
- let basic_block = & $( $mutability) ? body[ location. block] ;
795
- if basic_block. statements. len( ) == location. statement_index {
796
- // TODO(nashenas88) how to ensure we clear the cache only in the mutable case...
797
- if let Some ( ref $( $mutability) ? terminator) = basic_block. terminator {
798
- self . visit_terminator( terminator, location)
799
- }
800
- } else {
801
- let statement = & $( $mutability) ?
802
- basic_block. statements[ location. statement_index] ;
803
- self . visit_statement( statement, location)
792
+ make_mir_visitor!{ @make_visit_location, $( $mutability) ?}
793
+ }
794
+ } ;
795
+ ( @make_visit_location, mut ) => {
796
+ fn visit_location( & mut self , body: & mut Body <' tcx>, location: Location ) {
797
+ if body[ location. block] . statements. len( ) == location. statement_index {
798
+ if let Some ( ref mut terminator) = body. basic_block_terminator_opt_mut( location. block) {
799
+ self . visit_terminator( terminator, location)
800
+ }
801
+ } else {
802
+ let statement = & mut body[ location. block] . statements[ location. statement_index] ;
803
+ self . visit_statement( statement, location)
804
+ }
805
+ }
806
+ } ;
807
+ ( @make_visit_location, ) => {
808
+ fn visit_location( & mut self , body: & Body <' tcx>, location: Location ) {
809
+ let basic_block = & body[ location. block] ;
810
+ if basic_block. statements. len( ) == location. statement_index {
811
+ if let Some ( ref terminator) = basic_block. terminator_opt( ) {
812
+ self . visit_terminator( terminator, location)
804
813
}
814
+ } else {
815
+ let statement = & basic_block. statements[ location. statement_index] ;
816
+ self . visit_statement( statement, location)
805
817
}
806
818
}
807
819
}
0 commit comments