@@ -52,7 +52,7 @@ pub(super) fn convert_typeck_constraints<'tcx>(
5252 // this information better in MIR typeck instead, for example with a new `Locations`
5353 // variant that contains which node is crossing over between entry and exit.
5454 let point = liveness. point_from_location ( location) ;
55- let ( from , to ) = if let Some ( stmt) =
55+ let localized_constraint = if let Some ( stmt) =
5656 body[ location. block ] . statements . get ( location. statement_index )
5757 {
5858 localize_statement_constraint (
@@ -78,19 +78,14 @@ pub(super) fn convert_typeck_constraints<'tcx>(
7878 universal_regions,
7979 )
8080 } ;
81- localized_outlives_constraints. push ( LocalizedOutlivesConstraint {
82- source : outlives_constraint. sup ,
83- from,
84- target : outlives_constraint. sub ,
85- to,
86- } ) ;
81+ localized_outlives_constraints. push ( localized_constraint) ;
8782 }
8883 }
8984 }
9085}
9186
92- /// For a given outlives constraint arising from a MIR statement, computes the CFG `from`-`to`
93- /// intra-block nodes to localize the constraint .
87+ /// For a given outlives constraint arising from a MIR statement, localize the constraint with the
88+ /// needed CFG `from`-`to` intra-block nodes .
9489fn localize_statement_constraint < ' tcx > (
9590 tcx : TyCtxt < ' tcx > ,
9691 body : & Body < ' tcx > ,
@@ -100,7 +95,7 @@ fn localize_statement_constraint<'tcx>(
10095 current_location : Location ,
10196 current_point : PointIndex ,
10297 universal_regions : & UniversalRegions < ' tcx > ,
103- ) -> ( PointIndex , PointIndex ) {
98+ ) -> LocalizedOutlivesConstraint {
10499 match & stmt. kind {
105100 StatementKind :: Assign ( box ( lhs, rhs) ) => {
106101 // To create localized outlives constraints without midpoints, we rely on the property
@@ -157,13 +152,18 @@ fn localize_statement_constraint<'tcx>(
157152 }
158153 _ => {
159154 // For the other cases, we localize an outlives constraint to where it arises.
160- ( current_point, current_point)
155+ LocalizedOutlivesConstraint {
156+ source : outlives_constraint. sup ,
157+ from : current_point,
158+ target : outlives_constraint. sub ,
159+ to : current_point,
160+ }
161161 }
162162 }
163163}
164164
165- /// For a given outlives constraint arising from a MIR terminator, computes the CFG `from`-`to`
166- /// inter-block nodes to localize the constraint .
165+ /// For a given outlives constraint arising from a MIR terminator, localize the constraint with the
166+ /// needed CFG `from`-`to` inter-block nodes .
167167fn localize_terminator_constraint < ' tcx > (
168168 tcx : TyCtxt < ' tcx > ,
169169 body : & Body < ' tcx > ,
@@ -172,7 +172,7 @@ fn localize_terminator_constraint<'tcx>(
172172 outlives_constraint : & OutlivesConstraint < ' tcx > ,
173173 current_point : PointIndex ,
174174 universal_regions : & UniversalRegions < ' tcx > ,
175- ) -> ( PointIndex , PointIndex ) {
175+ ) -> LocalizedOutlivesConstraint {
176176 // FIXME: check if other terminators need the same handling as `Call`s, in particular
177177 // Assert/Yield/Drop. A handful of tests are failing with Drop related issues, as well as some
178178 // coroutine tests, and that may be why.
@@ -198,22 +198,27 @@ fn localize_terminator_constraint<'tcx>(
198198 // Typeck constraints guide loans between regions at the current point, so we do that in
199199 // the general case, and liveness will take care of making them flow to the terminator's
200200 // successors.
201- ( current_point, current_point)
201+ LocalizedOutlivesConstraint {
202+ source : outlives_constraint. sup ,
203+ from : current_point,
204+ target : outlives_constraint. sub ,
205+ to : current_point,
206+ }
202207 }
203208 }
204209}
205-
206- /// For a given constraint, returns the `from`-`to` edge according to whether the constraint flows
207- /// to or from a free region in the given `value`, some kind of result for an effectful operation,
208- /// like the LHS of an assignment.
210+ /// For a given outlives constraint and CFG edge, returns the localized constraint with the
211+ /// appropriate `from`-`to` direction. This is computed according to whether the constraint flows to
212+ /// or from a free region in the given `value`, some kind of result for an effectful operation, like
213+ /// the LHS of an assignment.
209214fn compute_constraint_direction < ' tcx > (
210215 tcx : TyCtxt < ' tcx > ,
211216 outlives_constraint : & OutlivesConstraint < ' tcx > ,
212217 value : & impl TypeVisitable < TyCtxt < ' tcx > > ,
213218 current_point : PointIndex ,
214219 successor_point : PointIndex ,
215220 universal_regions : & UniversalRegions < ' tcx > ,
216- ) -> ( PointIndex , PointIndex ) {
221+ ) -> LocalizedOutlivesConstraint {
217222 let mut to = current_point;
218223 let mut from = current_point;
219224 tcx. for_each_free_region ( value, |region| {
@@ -227,5 +232,10 @@ fn compute_constraint_direction<'tcx>(
227232 }
228233 } ) ;
229234
230- ( from, to)
235+ LocalizedOutlivesConstraint {
236+ source : outlives_constraint. sup ,
237+ from,
238+ target : outlives_constraint. sub ,
239+ to,
240+ }
231241}
0 commit comments