@@ -15,7 +15,8 @@ use rustc::infer::NLLRegionVariableOrigin;
15
15
use rustc:: infer:: RegionVariableOrigin ;
16
16
use rustc:: infer:: SubregionOrigin ;
17
17
use rustc:: infer:: region_constraints:: { GenericKind , VarOrigins } ;
18
- use rustc:: mir:: { ClosureOutlivesRequirement , ClosureRegionRequirements , Location , Mir } ;
18
+ use rustc:: mir:: { ClosureOutlivesRequirement , ClosureOutlivesSubject , ClosureRegionRequirements ,
19
+ Location , Mir } ;
19
20
use rustc:: ty:: { self , RegionVid } ;
20
21
use rustc_data_structures:: indexed_vec:: IndexVec ;
21
22
use std:: fmt;
@@ -339,12 +340,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
339
340
/// Perform region inference and report errors if we see any
340
341
/// unsatisfiable constraints. If this is a closure, returns the
341
342
/// region requirements to propagate to our creator, if any.
342
- pub ( super ) fn solve (
343
+ pub ( super ) fn solve < ' gcx > (
343
344
& mut self ,
344
- infcx : & InferCtxt < ' _ , ' _ , ' tcx > ,
345
+ infcx : & InferCtxt < ' _ , ' gcx , ' tcx > ,
345
346
mir : & Mir < ' tcx > ,
346
347
mir_def_id : DefId ,
347
- ) -> Option < ClosureRegionRequirements > {
348
+ ) -> Option < ClosureRegionRequirements < ' gcx > > {
348
349
assert ! ( self . inferred_values. is_none( ) , "values already inferred" ) ;
349
350
350
351
self . propagate_constraints ( mir) ;
@@ -559,10 +560,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
559
560
/// If `propagated_outlives_requirements` is `Some`, then we will
560
561
/// push unsatisfied obligations into there. Otherwise, we'll
561
562
/// report them as errors.
562
- fn check_universal_regions (
563
+ fn check_universal_regions < ' gcx > (
563
564
& self ,
564
- infcx : & InferCtxt < ' _ , ' _ , ' tcx > ,
565
- mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement > > ,
565
+ infcx : & InferCtxt < ' _ , ' gcx , ' tcx > ,
566
+ mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement < ' gcx > > > ,
566
567
) {
567
568
// The universal regions are always found in a prefix of the
568
569
// full list.
@@ -583,9 +584,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
583
584
propagated_outlives_requirements. extend ( outlives_requirements. drain ( ..) ) ;
584
585
} else {
585
586
for outlives_requirement in outlives_requirements. drain ( ..) {
587
+ let fr = match outlives_requirement. subject {
588
+ ClosureOutlivesSubject :: Region ( fr) => fr,
589
+ _ => span_bug ! (
590
+ outlives_requirement. blame_span,
591
+ "check_universal_region() produced requirement w/ non-region subject"
592
+ ) ,
593
+ } ;
594
+
586
595
self . report_error (
587
596
infcx,
588
- outlives_requirement . free_region ,
597
+ fr ,
589
598
outlives_requirement. outlived_free_region ,
590
599
outlives_requirement. blame_span ,
591
600
) ;
@@ -602,11 +611,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
602
611
///
603
612
/// Things that are to be propagated are accumulated into the
604
613
/// `outlives_requirements` vector.
605
- fn check_universal_region (
614
+ fn check_universal_region < ' gcx > (
606
615
& self ,
607
- infcx : & InferCtxt < ' _ , ' _ , ' tcx > ,
616
+ infcx : & InferCtxt < ' _ , ' gcx , ' tcx > ,
608
617
longer_fr : RegionVid ,
609
- propagated_outlives_requirements : & mut Vec < ClosureOutlivesRequirement > ,
618
+ propagated_outlives_requirements : & mut Vec < ClosureOutlivesRequirement < ' gcx > > ,
610
619
) {
611
620
let inferred_values = self . inferred_values . as_ref ( ) . unwrap ( ) ;
612
621
@@ -645,7 +654,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
645
654
646
655
// Push the constraint `fr-: shorter_fr+`
647
656
propagated_outlives_requirements. push ( ClosureOutlivesRequirement {
648
- free_region : fr_minus,
657
+ subject : ClosureOutlivesSubject :: Region ( fr_minus) ,
649
658
outlived_free_region : shorter_fr_plus,
650
659
blame_span : blame_span,
651
660
} ) ;
@@ -773,7 +782,7 @@ pub trait ClosureRegionRequirementsExt {
773
782
) ;
774
783
}
775
784
776
- impl ClosureRegionRequirementsExt for ClosureRegionRequirements {
785
+ impl < ' gcx > ClosureRegionRequirementsExt for ClosureRegionRequirements < ' gcx > {
777
786
/// Given an instance T of the closure type, this method
778
787
/// instantiates the "extra" requirements that we computed for the
779
788
/// closure into the inference context. This has the effect of
@@ -815,17 +824,29 @@ impl ClosureRegionRequirementsExt for ClosureRegionRequirements {
815
824
816
825
// Create the predicates.
817
826
for outlives_requirement in & self . outlives_requirements {
818
- let region = closure_mapping[ outlives_requirement. free_region ] ;
819
827
let outlived_region = closure_mapping[ outlives_requirement. outlived_free_region ] ;
820
- debug ! (
821
- "apply_requirements: region={:?} outlived_region={:?} outlives_requirements={:?}" ,
822
- region,
823
- outlived_region,
824
- outlives_requirement
825
- ) ;
828
+
826
829
// FIXME, this origin is not entirely suitable.
827
830
let origin = SubregionOrigin :: CallRcvr ( outlives_requirement. blame_span ) ;
828
- infcx. sub_regions ( origin, outlived_region, region) ;
831
+
832
+ match outlives_requirement. subject {
833
+ ClosureOutlivesSubject :: Region ( region) => {
834
+ let region = closure_mapping[ region] ;
835
+ debug ! (
836
+ "apply_requirements: region={:?} \
837
+ outlived_region={:?} \
838
+ outlives_requirements={:?}",
839
+ region,
840
+ outlived_region,
841
+ outlives_requirement
842
+ ) ;
843
+ infcx. sub_regions ( origin, outlived_region, region) ;
844
+ }
845
+
846
+ ClosureOutlivesSubject :: Ty ( _ty) => {
847
+ bug ! ( "TODO not yet implemented -- closure outlives subject of a type" ) ;
848
+ }
849
+ }
829
850
}
830
851
}
831
852
}
0 commit comments