@@ -5,7 +5,6 @@ use crate::util::liveness::{categorize, DefUse};
5
5
use rustc:: mir:: visit:: { MutatingUseContext , PlaceContext , Visitor } ;
6
6
use rustc:: mir:: { Local , Location , Place , ReadOnlyBodyAndCache } ;
7
7
use rustc:: ty:: subst:: GenericArg ;
8
- use rustc:: ty:: Ty ;
9
8
10
9
use super :: TypeChecker ;
11
10
@@ -84,17 +83,6 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> {
84
83
}
85
84
}
86
85
87
- fn add_var_uses_regions ( typeck : & mut TypeChecker < ' _ , ' tcx > , local : Local , ty : Ty < ' tcx > ) {
88
- debug ! ( "add_regions(local={:?}, type={:?})" , local, ty) ;
89
- typeck. tcx ( ) . for_each_free_region ( & ty, |region| {
90
- let region_vid = typeck. borrowck_context . universal_regions . to_region_vid ( region) ;
91
- debug ! ( "add_regions for region {:?}" , region_vid) ;
92
- if let Some ( facts) = typeck. borrowck_context . all_facts {
93
- facts. var_uses_region . push ( ( local, region_vid) ) ;
94
- }
95
- } ) ;
96
- }
97
-
98
86
pub ( super ) fn populate_access_facts (
99
87
typeck : & mut TypeChecker < ' _ , ' tcx > ,
100
88
body : ReadOnlyBodyAndCache < ' _ , ' tcx > ,
@@ -118,10 +106,15 @@ pub(super) fn populate_access_facts(
118
106
facts. var_drop_used . extend ( drop_used. iter ( ) . map ( |& ( local, location) | {
119
107
( local, location_table. mid_index ( location) )
120
108
} ) ) ;
121
- }
122
109
123
- for ( local, local_decl) in body. local_decls . iter_enumerated ( ) {
124
- add_var_uses_regions ( typeck, local, local_decl. ty ) ;
110
+ for ( local, local_decl) in body. local_decls . iter_enumerated ( ) {
111
+ debug ! ( "add var_uses_regions facts - local={:?}, type={:?}" , local, local_decl. ty) ;
112
+ let universal_regions = & typeck. borrowck_context . universal_regions ;
113
+ typeck. infcx . tcx . for_each_free_region ( & local_decl. ty , |region| {
114
+ let region_vid = universal_regions. to_region_vid ( region) ;
115
+ facts. var_uses_region . push ( ( local, region_vid) ) ;
116
+ } ) ;
117
+ }
125
118
}
126
119
}
127
120
@@ -133,12 +126,11 @@ pub(super) fn add_var_drops_regions(
133
126
kind : & GenericArg < ' tcx > ,
134
127
) {
135
128
debug ! ( "add_var_drops_region(local={:?}, kind={:?}" , local, kind) ;
136
- let tcx = typeck. tcx ( ) ;
137
-
138
- tcx. for_each_free_region ( kind, |drop_live_region| {
139
- let region_vid = typeck. borrowck_context . universal_regions . to_region_vid ( drop_live_region) ;
140
- if let Some ( facts) = typeck. borrowck_context . all_facts . as_mut ( ) {
129
+ if let Some ( facts) = typeck. borrowck_context . all_facts . as_mut ( ) {
130
+ let universal_regions = & typeck. borrowck_context . universal_regions ;
131
+ typeck. infcx . tcx . for_each_free_region ( kind, |drop_live_region| {
132
+ let region_vid = universal_regions. to_region_vid ( drop_live_region) ;
141
133
facts. var_drops_region . push ( ( local, region_vid) ) ;
142
- } ;
143
- } ) ;
134
+ } ) ;
135
+ }
144
136
}
0 commit comments