@@ -44,49 +44,48 @@ pub struct RegionInferenceContext<'tcx> {
4444 /// variables are identified by their index (`RegionVid`). The
4545 /// definition contains information about where the region came
4646 /// from as well as its final inferred value.
47- pub ( in crate :: borrow_check ) definitions : IndexVec < RegionVid , RegionDefinition < ' tcx > > ,
47+ definitions : IndexVec < RegionVid , RegionDefinition < ' tcx > > ,
4848
4949 /// The liveness constraints added to each region. For most
5050 /// regions, these start out empty and steadily grow, though for
5151 /// each universally quantified region R they start out containing
5252 /// the entire CFG and `end(R)`.
53- pub ( in crate :: borrow_check ) liveness_constraints : LivenessValues < RegionVid > ,
53+ liveness_constraints : LivenessValues < RegionVid > ,
5454
5555 /// The outlives constraints computed by the type-check.
56- pub ( in crate :: borrow_check ) constraints : Rc < OutlivesConstraintSet > ,
56+ constraints : Rc < OutlivesConstraintSet > ,
5757
5858 /// The constraint-set, but in graph form, making it easy to traverse
5959 /// the constraints adjacent to a particular region. Used to construct
6060 /// the SCC (see `constraint_sccs`) and for error reporting.
61- pub ( in crate :: borrow_check ) constraint_graph : Rc < NormalConstraintGraph > ,
61+ constraint_graph : Rc < NormalConstraintGraph > ,
6262
6363 /// The SCC computed from `constraints` and the constraint
6464 /// graph. We have an edge from SCC A to SCC B if `A: B`. Used to
6565 /// compute the values of each region.
66- pub ( in crate :: borrow_check ) constraint_sccs : Rc < Sccs < RegionVid , ConstraintSccIndex > > ,
66+ constraint_sccs : Rc < Sccs < RegionVid , ConstraintSccIndex > > ,
6767
6868 /// Reverse of the SCC constraint graph -- i.e., an edge `A -> B`
6969 /// exists if `B: A`. Computed lazilly.
70- pub ( in crate :: borrow_check ) rev_constraint_graph : Option < Rc < VecGraph < ConstraintSccIndex > > > ,
70+ rev_constraint_graph : Option < Rc < VecGraph < ConstraintSccIndex > > > ,
7171
7272 /// The "R0 member of [R1..Rn]" constraints, indexed by SCC.
73- pub ( in crate :: borrow_check) member_constraints :
74- Rc < MemberConstraintSet < ' tcx , ConstraintSccIndex > > ,
73+ member_constraints : Rc < MemberConstraintSet < ' tcx , ConstraintSccIndex > > ,
7574
7675 /// Records the member constraints that we applied to each scc.
7776 /// This is useful for error reporting. Once constraint
7877 /// propagation is done, this vector is sorted according to
7978 /// `member_region_scc`.
80- pub ( in crate :: borrow_check ) member_constraints_applied : Vec < AppliedMemberConstraint > ,
79+ member_constraints_applied : Vec < AppliedMemberConstraint > ,
8180
8281 /// Map closure bounds to a `Span` that should be used for error reporting.
83- pub ( in crate :: borrow_check ) closure_bounds_mapping :
82+ closure_bounds_mapping :
8483 FxHashMap < Location , FxHashMap < ( RegionVid , RegionVid ) , ( ConstraintCategory , Span ) > > ,
8584
8685 /// Contains the minimum universe of any variable within the same
8786 /// SCC. We will ensure that no SCC contains values that are not
8887 /// visible from this index.
89- pub ( in crate :: borrow_check ) scc_universes : IndexVec < ConstraintSccIndex , ty:: UniverseIndex > ,
88+ scc_universes : IndexVec < ConstraintSccIndex , ty:: UniverseIndex > ,
9089
9190 /// Contains a "representative" from each SCC. This will be the
9291 /// minimal RegionVid belonging to that universe. It is used as a
@@ -95,23 +94,23 @@ pub struct RegionInferenceContext<'tcx> {
9594 /// of its SCC and be sure that -- if they have the same repr --
9695 /// they *must* be equal (though not having the same repr does not
9796 /// mean they are unequal).
98- pub ( in crate :: borrow_check ) scc_representatives : IndexVec < ConstraintSccIndex , ty:: RegionVid > ,
97+ scc_representatives : IndexVec < ConstraintSccIndex , ty:: RegionVid > ,
9998
10099 /// The final inferred values of the region variables; we compute
101100 /// one value per SCC. To get the value for any given *region*,
102101 /// you first find which scc it is a part of.
103- pub ( in crate :: borrow_check ) scc_values : RegionValues < ConstraintSccIndex > ,
102+ scc_values : RegionValues < ConstraintSccIndex > ,
104103
105104 /// Type constraints that we check after solving.
106- pub ( in crate :: borrow_check ) type_tests : Vec < TypeTest < ' tcx > > ,
105+ type_tests : Vec < TypeTest < ' tcx > > ,
107106
108107 /// Information about the universally quantified regions in scope
109108 /// on this function.
110- pub ( in crate :: borrow_check ) universal_regions : Rc < UniversalRegions < ' tcx > > ,
109+ universal_regions : Rc < UniversalRegions < ' tcx > > ,
111110
112111 /// Information about how the universally quantified regions in
113112 /// scope on this function relate to one another.
114- pub ( in crate :: borrow_check ) universal_region_relations : Rc < UniversalRegionRelations < ' tcx > > ,
113+ universal_region_relations : Rc < UniversalRegionRelations < ' tcx > > ,
115114}
116115
117116/// Each time that `apply_member_constraint` is successful, it appends
@@ -1840,6 +1839,38 @@ impl<'tcx> RegionInferenceContext<'tcx> {
18401839 . unwrap ( )
18411840 }
18421841
1842+ /// Get the region outlived by `longer_fr` and live at `element`.
1843+ crate fn region_from_element ( & self , longer_fr : RegionVid , element : RegionElement ) -> RegionVid {
1844+ match element {
1845+ RegionElement :: Location ( l) => self . find_sub_region_live_at ( longer_fr, l) ,
1846+ RegionElement :: RootUniversalRegion ( r) => r,
1847+ RegionElement :: PlaceholderRegion ( error_placeholder) => self
1848+ . definitions
1849+ . iter_enumerated ( )
1850+ . filter_map ( |( r, definition) | match definition. origin {
1851+ NLLRegionVariableOrigin :: Placeholder ( p) if p == error_placeholder => Some ( r) ,
1852+ _ => None ,
1853+ } )
1854+ . next ( )
1855+ . unwrap ( ) ,
1856+ }
1857+ }
1858+
1859+ /// Get the region definition of `r`.
1860+ crate fn region_definition ( & self , r : RegionVid ) -> & RegionDefinition < ' tcx > {
1861+ & self . definitions [ r]
1862+ }
1863+
1864+ /// Check if the SCC of `r` contains `upper`.
1865+ crate fn upper_bound_in_region_scc ( & self , r : RegionVid , upper : RegionVid ) -> bool {
1866+ let r_scc = self . constraint_sccs . scc ( r) ;
1867+ self . scc_values . contains ( r_scc, upper)
1868+ }
1869+
1870+ crate fn universal_regions ( & self ) -> Rc < UniversalRegions < ' tcx > > {
1871+ self . universal_regions . clone ( )
1872+ }
1873+
18431874 /// Tries to find the best constraint to blame for the fact that
18441875 /// `R: from_region`, where `R` is some region that meets
18451876 /// `target_test`. This works by following the constraint graph,
0 commit comments