@@ -549,6 +549,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
549
549
/// Performs region inference and report errors if we see any
550
550
/// unsatisfiable constraints. If this is a closure, returns the
551
551
/// region requirements to propagate to our creator, if any.
552
+ #[ instrument( skip( self , infcx, body, polonius_output) , level = "debug" ) ]
552
553
pub ( super ) fn solve (
553
554
& mut self ,
554
555
infcx : & InferCtxt < ' _ , ' tcx > ,
@@ -604,10 +605,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
604
605
/// for each region variable until all the constraints are
605
606
/// satisfied. Note that some values may grow **too** large to be
606
607
/// feasible, but we check this later.
608
+ #[ instrument( skip( self , _body) , level = "debug" ) ]
607
609
fn propagate_constraints ( & mut self , _body : & Body < ' tcx > ) {
608
- debug ! ( "propagate_constraints()" ) ;
609
-
610
- debug ! ( "propagate_constraints: constraints={:#?}" , {
610
+ debug ! ( "constraints={:#?}" , {
611
611
let mut constraints: Vec <_> = self . constraints. outlives( ) . iter( ) . collect( ) ;
612
612
constraints. sort( ) ;
613
613
constraints
@@ -634,12 +634,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
634
634
/// computed, by unioning the values of its successors.
635
635
/// Assumes that all successors have been computed already
636
636
/// (which is assured by iterating over SCCs in dependency order).
637
+ #[ instrument( skip( self ) , level = "debug" ) ]
637
638
fn compute_value_for_scc ( & mut self , scc_a : ConstraintSccIndex ) {
638
639
let constraint_sccs = self . constraint_sccs . clone ( ) ;
639
640
640
641
// Walk each SCC `B` such that `A: B`...
641
642
for & scc_b in constraint_sccs. successors ( scc_a) {
642
- debug ! ( "propagate_constraint_sccs: scc_a = {:?} scc_b = {:?}" , scc_a , scc_b) ;
643
+ debug ! ( ? scc_b) ;
643
644
644
645
// ...and add elements from `B` into `A`. One complication
645
646
// arises because of universes: If `B` contains something
@@ -660,11 +661,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
660
661
self . apply_member_constraint ( scc_a, m_c_i, member_constraints. choice_regions ( m_c_i) ) ;
661
662
}
662
663
663
- debug ! (
664
- "propagate_constraint_sccs: scc_a = {:?} has value {:?}" ,
665
- scc_a,
666
- self . scc_values. region_value_str( scc_a) ,
667
- ) ;
664
+ debug ! ( value = ?self . scc_values. region_value_str( scc_a) ) ;
668
665
}
669
666
670
667
/// Invoked for each `R0 member of [R1..Rn]` constraint.
@@ -678,14 +675,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
678
675
/// is considered a *lower bound*. If possible, we will modify
679
676
/// the constraint to set it equal to one of the option regions.
680
677
/// If we make any changes, returns true, else false.
678
+ #[ instrument( skip( self , member_constraint_index) , level = "debug" ) ]
681
679
fn apply_member_constraint (
682
680
& mut self ,
683
681
scc : ConstraintSccIndex ,
684
682
member_constraint_index : NllMemberConstraintIndex ,
685
683
choice_regions : & [ ty:: RegionVid ] ,
686
684
) -> bool {
687
- debug ! ( "apply_member_constraint(scc={:?}, choice_regions={:#?})" , scc, choice_regions, ) ;
688
-
689
685
// Create a mutable vector of the options. We'll try to winnow
690
686
// them down.
691
687
let mut choice_regions: Vec < ty:: RegionVid > = choice_regions. to_vec ( ) ;
@@ -711,7 +707,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
711
707
. universal_regions_outlived_by ( scc)
712
708
. all ( |lb| self . universal_region_relations . outlives ( o_r, lb) )
713
709
} ) ;
714
- debug ! ( "apply_member_constraint: after lb, choice_regions={:?}" , choice_regions ) ;
710
+ debug ! ( ?choice_regions , " after lb" ) ;
715
711
716
712
// Now find all the *upper bounds* -- that is, each UB is a
717
713
// free region that must outlive the member region `R0` (`UB:
@@ -720,10 +716,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
720
716
let rev_scc_graph = self . reverse_scc_graph ( ) ;
721
717
let universal_region_relations = & self . universal_region_relations ;
722
718
for ub in rev_scc_graph. upper_bounds ( scc) {
723
- debug ! ( "apply_member_constraint: ub={:?}" , ub) ;
719
+ debug ! ( ? ub) ;
724
720
choice_regions. retain ( |& o_r| universal_region_relations. outlives ( ub, o_r) ) ;
725
721
}
726
- debug ! ( "apply_member_constraint: after ub, choice_regions={:?}" , choice_regions ) ;
722
+ debug ! ( ?choice_regions , " after ub" ) ;
727
723
728
724
// If we ruled everything out, we're done.
729
725
if choice_regions. is_empty ( ) {
@@ -732,7 +728,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
732
728
733
729
// Otherwise, we need to find the minimum remaining choice, if
734
730
// any, and take that.
735
- debug ! ( "apply_member_constraint: choice_regions remaining are {:#?}" , choice_regions) ;
731
+ debug ! ( "choice_regions remaining are {:#?}" , choice_regions) ;
736
732
let min = |r1 : ty:: RegionVid , r2 : ty:: RegionVid | -> Option < ty:: RegionVid > {
737
733
let r1_outlives_r2 = self . universal_region_relations . outlives ( r1, r2) ;
738
734
let r2_outlives_r1 = self . universal_region_relations . outlives ( r2, r1) ;
@@ -745,27 +741,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
745
741
} ;
746
742
let mut min_choice = choice_regions[ 0 ] ;
747
743
for & other_option in & choice_regions[ 1 ..] {
748
- debug ! (
749
- "apply_member_constraint: min_choice={:?} other_option={:?}" ,
750
- min_choice, other_option,
751
- ) ;
744
+ debug ! ( ?min_choice, ?other_option, ) ;
752
745
match min ( min_choice, other_option) {
753
746
Some ( m) => min_choice = m,
754
747
None => {
755
- debug ! (
756
- "apply_member_constraint: {:?} and {:?} are incomparable; no min choice" ,
757
- min_choice, other_option,
758
- ) ;
748
+ debug ! ( ?min_choice, ?other_option, "incomparable; no min choice" , ) ;
759
749
return false ;
760
750
}
761
751
}
762
752
}
763
753
764
754
let min_choice_scc = self . constraint_sccs . scc ( min_choice) ;
765
- debug ! (
766
- "apply_member_constraint: min_choice={:?} best_choice_scc={:?}" ,
767
- min_choice, min_choice_scc,
768
- ) ;
755
+ debug ! ( ?min_choice, ?min_choice_scc) ;
769
756
if self . scc_values . add_region ( scc, min_choice_scc) {
770
757
self . member_constraints_applied . push ( AppliedMemberConstraint {
771
758
member_region_scc : scc,
@@ -1088,8 +1075,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1088
1075
/// include the CFG anyhow.
1089
1076
/// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding
1090
1077
/// a result `'y`.
1078
+ #[ instrument( skip( self ) , level = "debug" ) ]
1091
1079
pub ( crate ) fn universal_upper_bound ( & self , r : RegionVid ) -> RegionVid {
1092
- debug ! ( "universal_upper_bound(r={:?}={})" , r , self . region_value_str( r) ) ;
1080
+ debug ! ( r = % self . region_value_str( r) ) ;
1093
1081
1094
1082
// Find the smallest universal region that contains all other
1095
1083
// universal regions within `region`.
@@ -1099,7 +1087,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1099
1087
lub = self . universal_region_relations . postdom_upper_bound ( lub, ur) ;
1100
1088
}
1101
1089
1102
- debug ! ( "universal_upper_bound: r={:?} lub={:?}" , r , lub) ;
1090
+ debug ! ( ? lub) ;
1103
1091
1104
1092
lub
1105
1093
}
@@ -1259,9 +1247,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1259
1247
}
1260
1248
1261
1249
// Evaluate whether `sup_region: sub_region`.
1250
+ #[ instrument( skip( self ) , level = "debug" ) ]
1262
1251
fn eval_outlives ( & self , sup_region : RegionVid , sub_region : RegionVid ) -> bool {
1263
- debug ! ( "eval_outlives({:?}: {:?})" , sup_region, sub_region) ;
1264
-
1265
1252
debug ! (
1266
1253
"eval_outlives: sup_region's value = {:?} universal={:?}" ,
1267
1254
self . region_value_str( sup_region) ,
@@ -1464,15 +1451,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1464
1451
///
1465
1452
/// Things that are to be propagated are accumulated into the
1466
1453
/// `outlives_requirements` vector.
1454
+ #[ instrument(
1455
+ skip( self , body, propagated_outlives_requirements, errors_buffer) ,
1456
+ level = "debug"
1457
+ ) ]
1467
1458
fn check_universal_region (
1468
1459
& self ,
1469
1460
body : & Body < ' tcx > ,
1470
1461
longer_fr : RegionVid ,
1471
1462
propagated_outlives_requirements : & mut Option < & mut Vec < ClosureOutlivesRequirement < ' tcx > > > ,
1472
1463
errors_buffer : & mut RegionErrors < ' tcx > ,
1473
1464
) {
1474
- debug ! ( "check_universal_region(fr={:?})" , longer_fr) ;
1475
-
1476
1465
let longer_fr_scc = self . constraint_sccs . scc ( longer_fr) ;
1477
1466
1478
1467
// Because this free region must be in the ROOT universe, we
@@ -1877,21 +1866,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1877
1866
}
1878
1867
1879
1868
/// Finds some region R such that `fr1: R` and `R` is live at `elem`.
1869
+ #[ instrument( skip( self ) , level = "trace" ) ]
1880
1870
crate fn find_sub_region_live_at ( & self , fr1 : RegionVid , elem : Location ) -> RegionVid {
1881
- debug ! ( "find_sub_region_live_at(fr1={:?}, elem={:?})" , fr1, elem) ;
1882
- debug ! ( "find_sub_region_live_at: {:?} is in scc {:?}" , fr1, self . constraint_sccs. scc( fr1) ) ;
1883
- debug ! (
1884
- "find_sub_region_live_at: {:?} is in universe {:?}" ,
1885
- fr1,
1886
- self . scc_universes[ self . constraint_sccs. scc( fr1) ]
1887
- ) ;
1871
+ trace ! ( scc = ?self . constraint_sccs. scc( fr1) ) ;
1872
+ trace ! ( universe = ?self . scc_universes[ self . constraint_sccs. scc( fr1) ] ) ;
1888
1873
self . find_constraint_paths_between_regions ( fr1, |r| {
1889
1874
// First look for some `r` such that `fr1: r` and `r` is live at `elem`
1890
- debug ! (
1891
- "find_sub_region_live_at: liveness_constraints for {:?} are {:?}" ,
1892
- r,
1893
- self . liveness_constraints. region_value_str( r) ,
1894
- ) ;
1875
+ trace ! ( ?r, liveness_constraints=?self . liveness_constraints. region_value_str( r) ) ;
1895
1876
self . liveness_constraints . contains ( r, elem)
1896
1877
} )
1897
1878
. or_else ( || {
0 commit comments