@@ -15,6 +15,7 @@ use borrow_check::borrow_set::BorrowSet;
15
15
use borrow_check:: location:: LocationTable ;
16
16
use borrow_check:: nll:: constraints:: { ConstraintSet , OutlivesConstraint } ;
17
17
use borrow_check:: nll:: facts:: AllFacts ;
18
+ use borrow_check:: nll:: liveness_map:: NllLivenessMap ;
18
19
use borrow_check:: nll:: region_infer:: values:: { RegionValueElements , LivenessValues } ;
19
20
use borrow_check:: nll:: region_infer:: { ClosureRegionRequirementsExt , TypeTest } ;
20
21
use borrow_check:: nll:: type_check:: free_region_relations:: { CreateResult , UniversalRegionRelations } ;
@@ -115,16 +116,12 @@ pub(crate) fn type_check<'gcx, 'tcx>(
115
116
universal_regions : & Rc < UniversalRegions < ' tcx > > ,
116
117
location_table : & LocationTable ,
117
118
borrow_set : & BorrowSet < ' tcx > ,
118
- liveness : & LivenessResults < LocalWithRegion > ,
119
119
all_facts : & mut Option < AllFacts > ,
120
120
flow_inits : & mut FlowAtLocation < MaybeInitializedPlaces < ' _ , ' gcx , ' tcx > > ,
121
121
move_data : & MoveData < ' tcx > ,
122
122
elements : & Rc < RegionValueElements > ,
123
123
errors_buffer : & mut Vec < Diagnostic > ,
124
- ) -> (
125
- MirTypeckRegionConstraints < ' tcx > ,
126
- Rc < UniversalRegionRelations < ' tcx > > ,
127
- ) {
124
+ ) -> MirTypeckResults < ' tcx > {
128
125
let implicit_region_bound = infcx. tcx . mk_region ( ty:: ReVar ( universal_regions. fr_fn_body ) ) ;
129
126
let mut constraints = MirTypeckRegionConstraints {
130
127
liveness_constraints : LivenessValues :: new ( elements) ,
@@ -147,7 +144,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
147
144
all_facts,
148
145
) ;
149
146
150
- {
147
+ let ( liveness , liveness_map ) = {
151
148
let mut borrowck_context = BorrowCheckContext {
152
149
universal_regions,
153
150
location_table,
@@ -166,22 +163,27 @@ pub(crate) fn type_check<'gcx, 'tcx>(
166
163
Some ( & mut borrowck_context) ,
167
164
Some ( errors_buffer) ,
168
165
|cx| {
169
- liveness:: generate ( cx, mir, liveness, flow_inits, move_data) ;
170
166
cx. equate_inputs_and_outputs (
171
167
mir,
172
168
mir_def_id,
173
169
universal_regions,
174
170
& universal_region_relations,
175
171
& normalized_inputs_and_output,
176
172
) ;
173
+ liveness:: generate ( cx, mir, flow_inits, move_data)
177
174
} ,
178
- ) ;
179
- }
175
+ )
176
+ } ;
180
177
181
- ( constraints, universal_region_relations)
178
+ MirTypeckResults {
179
+ constraints,
180
+ universal_region_relations,
181
+ liveness,
182
+ liveness_map,
183
+ }
182
184
}
183
185
184
- fn type_check_internal < ' a , ' gcx , ' tcx , F > (
186
+ fn type_check_internal < ' a , ' gcx , ' tcx , R > (
185
187
infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
186
188
mir_def_id : DefId ,
187
189
param_env : ty:: ParamEnv < ' gcx > ,
@@ -190,10 +192,8 @@ fn type_check_internal<'a, 'gcx, 'tcx, F>(
190
192
implicit_region_bound : Option < ty:: Region < ' tcx > > ,
191
193
borrowck_context : Option < & ' a mut BorrowCheckContext < ' a , ' tcx > > ,
192
194
errors_buffer : Option < & mut Vec < Diagnostic > > ,
193
- mut extra : F ,
194
- ) where
195
- F : FnMut ( & mut TypeChecker < ' a , ' gcx , ' tcx > ) ,
196
- {
195
+ mut extra : impl FnMut ( & mut TypeChecker < ' a , ' gcx , ' tcx > ) -> R ,
196
+ ) -> R where {
197
197
let mut checker = TypeChecker :: new (
198
198
infcx,
199
199
mir,
@@ -214,7 +214,7 @@ fn type_check_internal<'a, 'gcx, 'tcx, F>(
214
214
checker. typeck_mir ( mir, errors_buffer) ;
215
215
}
216
216
217
- extra ( & mut checker) ;
217
+ extra ( & mut checker)
218
218
}
219
219
220
220
fn mirbug ( tcx : TyCtxt , span : Span , msg : & str ) {
@@ -655,6 +655,13 @@ struct BorrowCheckContext<'a, 'tcx: 'a> {
655
655
constraints : & ' a mut MirTypeckRegionConstraints < ' tcx > ,
656
656
}
657
657
658
+ crate struct MirTypeckResults < ' tcx > {
659
+ crate constraints : MirTypeckRegionConstraints < ' tcx > ,
660
+ crate universal_region_relations : Rc < UniversalRegionRelations < ' tcx > > ,
661
+ crate liveness : LivenessResults < LocalWithRegion > ,
662
+ crate liveness_map : NllLivenessMap ,
663
+ }
664
+
658
665
/// A collection of region constraints that must be satisfied for the
659
666
/// program to be considered well-typed.
660
667
crate struct MirTypeckRegionConstraints < ' tcx > {
0 commit comments