@@ -5,6 +5,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
55use rustc_infer:: infer:: outlives:: for_liveness;
66use rustc_middle:: mir:: { BasicBlock , Body , ConstraintCategory , Local , Location } ;
77use rustc_middle:: traits:: query:: DropckOutlivesResult ;
8+ use rustc_middle:: ty:: relate:: Relate ;
89use rustc_middle:: ty:: { Ty , TyCtxt , TypeVisitable , TypeVisitableExt } ;
910use rustc_mir_dataflow:: ResultsCursor ;
1011use rustc_mir_dataflow:: impls:: MaybeInitializedPlaces ;
@@ -532,11 +533,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
532533
533534 /// Stores the result that all regions in `value` are live for the
534535 /// points `live_at`.
535- fn add_use_live_facts_for (
536- & mut self ,
537- value : impl TypeVisitable < TyCtxt < ' tcx > > ,
538- live_at : & IntervalSet < PointIndex > ,
539- ) {
536+ fn add_use_live_facts_for ( & mut self , value : Ty < ' tcx > , live_at : & IntervalSet < PointIndex > ) {
540537 debug ! ( "add_use_live_facts_for(value={:?})" , value) ;
541538 Self :: make_all_regions_live ( self . elements , self . typeck , value, live_at) ;
542539 }
@@ -603,7 +600,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
603600 fn make_all_regions_live (
604601 elements : & DenseLocationMap ,
605602 typeck : & mut TypeChecker < ' _ , ' tcx > ,
606- value : impl TypeVisitable < TyCtxt < ' tcx > > ,
603+ value : impl TypeVisitable < TyCtxt < ' tcx > > + Relate < TyCtxt < ' tcx > > ,
607604 live_at : & IntervalSet < PointIndex > ,
608605 ) {
609606 debug ! ( "make_all_regions_live(value={:?})" , value) ;
@@ -621,6 +618,15 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
621618 typeck. constraints . liveness_constraints . add_points ( live_region_vid, live_at) ;
622619 } ,
623620 } ) ;
621+
622+ // When using `-Zpolonius=next`, we record the variance of each live region.
623+ if let Some ( polonius_context) = typeck. polonius_context {
624+ polonius_context. record_live_region_variance (
625+ typeck. infcx . tcx ,
626+ typeck. universal_regions ,
627+ value,
628+ ) ;
629+ }
624630 }
625631
626632 fn compute_drop_data ( typeck : & TypeChecker < ' _ , ' tcx > , dropped_ty : Ty < ' tcx > ) -> DropData < ' tcx > {
0 commit comments