@@ -15,7 +15,9 @@ use borrow_check::borrow_set::BorrowSet;
15
15
use borrow_check:: location:: LocationTable ;
16
16
use borrow_check:: nll:: constraints:: { ConstraintCategory , ConstraintSet , OutlivesConstraint } ;
17
17
use borrow_check:: nll:: facts:: AllFacts ;
18
- use borrow_check:: nll:: region_infer:: values:: { LivenessValues , RegionValueElements } ;
18
+ use borrow_check:: nll:: region_infer:: values:: LivenessValues ;
19
+ use borrow_check:: nll:: region_infer:: values:: PlaceholderIndices ;
20
+ use borrow_check:: nll:: region_infer:: values:: RegionValueElements ;
19
21
use borrow_check:: nll:: region_infer:: { ClosureRegionRequirementsExt , TypeTest } ;
20
22
use borrow_check:: nll:: renumber;
21
23
use borrow_check:: nll:: type_check:: free_region_relations:: {
@@ -42,13 +44,13 @@ use rustc::traits::{ObligationCause, PredicateObligations};
42
44
use rustc:: ty:: fold:: TypeFoldable ;
43
45
use rustc:: ty:: subst:: Subst ;
44
46
use rustc:: ty:: { self , CanonicalTy , RegionVid , ToPolyTraitRef , Ty , TyCtxt , TyKind } ;
45
- use std:: { fmt, iter} ;
46
47
use std:: rc:: Rc ;
48
+ use std:: { fmt, iter} ;
47
49
use syntax_pos:: { Span , DUMMY_SP } ;
48
50
use transform:: { MirPass , MirSource } ;
49
51
50
- use rustc_data_structures:: fx:: FxHashSet ;
51
52
use either:: Either ;
53
+ use rustc_data_structures:: fx:: FxHashSet ;
52
54
53
55
macro_rules! span_mirbug {
54
56
( $context: expr, $elem: expr, $( $message: tt) * ) => ( {
@@ -128,6 +130,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
128
130
outlives_constraints : ConstraintSet :: default ( ) ,
129
131
type_tests : Vec :: default ( ) ,
130
132
} ;
133
+ let mut placeholder_indices = PlaceholderIndices :: default ( ) ;
131
134
132
135
let CreateResult {
133
136
universal_region_relations,
@@ -147,6 +150,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
147
150
borrow_set,
148
151
all_facts,
149
152
constraints : & mut constraints,
153
+ placeholder_indices : & mut placeholder_indices,
150
154
} ;
151
155
152
156
type_check_internal (
@@ -162,12 +166,15 @@ pub(crate) fn type_check<'gcx, 'tcx>(
162
166
cx. equate_inputs_and_outputs ( mir, universal_regions, & normalized_inputs_and_output) ;
163
167
liveness:: generate ( cx, mir, elements, flow_inits, move_data, location_table) ;
164
168
165
- cx. borrowck_context . as_mut ( ) . map ( |bcx| translate_outlives_facts ( bcx) ) ;
169
+ cx. borrowck_context
170
+ . as_mut ( )
171
+ . map ( |bcx| translate_outlives_facts ( bcx) ) ;
166
172
} ,
167
173
) ;
168
174
169
175
MirTypeckResults {
170
176
constraints,
177
+ placeholder_indices,
171
178
universal_region_relations,
172
179
}
173
180
}
@@ -210,21 +217,25 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>(
210
217
fn translate_outlives_facts ( cx : & mut BorrowCheckContext ) {
211
218
if let Some ( facts) = cx. all_facts {
212
219
let location_table = cx. location_table ;
213
- facts. outlives . extend (
214
- cx. constraints . outlives_constraints . iter ( ) . flat_map ( |constraint : & OutlivesConstraint | {
215
- if let Some ( from_location) = constraint. locations . from_location ( ) {
216
- Either :: Left ( iter:: once ( (
217
- constraint. sup ,
218
- constraint. sub ,
219
- location_table. mid_index ( from_location) ,
220
- ) ) )
221
- } else {
222
- Either :: Right ( location_table. all_points ( ) . map ( move |location| {
223
- ( constraint. sup , constraint. sub , location)
224
- } ) )
225
- }
226
- } )
227
- ) ;
220
+ facts
221
+ . outlives
222
+ . extend ( cx. constraints . outlives_constraints . iter ( ) . flat_map (
223
+ |constraint : & OutlivesConstraint | {
224
+ if let Some ( from_location) = constraint. locations . from_location ( ) {
225
+ Either :: Left ( iter:: once ( (
226
+ constraint. sup ,
227
+ constraint. sub ,
228
+ location_table. mid_index ( from_location) ,
229
+ ) ) )
230
+ } else {
231
+ Either :: Right (
232
+ location_table
233
+ . all_points ( )
234
+ . map ( move |location| ( constraint. sup , constraint. sub , location) ) ,
235
+ )
236
+ }
237
+ } ,
238
+ ) ) ;
228
239
}
229
240
}
230
241
@@ -718,10 +729,12 @@ struct BorrowCheckContext<'a, 'tcx: 'a> {
718
729
all_facts : & ' a mut Option < AllFacts > ,
719
730
borrow_set : & ' a BorrowSet < ' tcx > ,
720
731
constraints : & ' a mut MirTypeckRegionConstraints < ' tcx > ,
732
+ placeholder_indices : & ' a mut PlaceholderIndices ,
721
733
}
722
734
723
735
crate struct MirTypeckResults < ' tcx > {
724
736
crate constraints : MirTypeckRegionConstraints < ' tcx > ,
737
+ crate placeholder_indices : PlaceholderIndices ,
725
738
crate universal_region_relations : Rc < UniversalRegionRelations < ' tcx > > ,
726
739
}
727
740
0 commit comments