@@ -52,7 +52,7 @@ pub(super) fn convert_typeck_constraints<'tcx>(
52
52
// this information better in MIR typeck instead, for example with a new `Locations`
53
53
// variant that contains which node is crossing over between entry and exit.
54
54
let point = liveness. point_from_location ( location) ;
55
- let ( from , to ) = if let Some ( stmt) =
55
+ let localized_constraint = if let Some ( stmt) =
56
56
body[ location. block ] . statements . get ( location. statement_index )
57
57
{
58
58
localize_statement_constraint (
@@ -78,19 +78,14 @@ pub(super) fn convert_typeck_constraints<'tcx>(
78
78
universal_regions,
79
79
)
80
80
} ;
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) ;
87
82
}
88
83
}
89
84
}
90
85
}
91
86
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 .
94
89
fn localize_statement_constraint < ' tcx > (
95
90
tcx : TyCtxt < ' tcx > ,
96
91
body : & Body < ' tcx > ,
@@ -100,7 +95,7 @@ fn localize_statement_constraint<'tcx>(
100
95
current_location : Location ,
101
96
current_point : PointIndex ,
102
97
universal_regions : & UniversalRegions < ' tcx > ,
103
- ) -> ( PointIndex , PointIndex ) {
98
+ ) -> LocalizedOutlivesConstraint {
104
99
match & stmt. kind {
105
100
StatementKind :: Assign ( box ( lhs, rhs) ) => {
106
101
// To create localized outlives constraints without midpoints, we rely on the property
@@ -157,13 +152,18 @@ fn localize_statement_constraint<'tcx>(
157
152
}
158
153
_ => {
159
154
// 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
+ }
161
161
}
162
162
}
163
163
}
164
164
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 .
167
167
fn localize_terminator_constraint < ' tcx > (
168
168
tcx : TyCtxt < ' tcx > ,
169
169
body : & Body < ' tcx > ,
@@ -172,7 +172,7 @@ fn localize_terminator_constraint<'tcx>(
172
172
outlives_constraint : & OutlivesConstraint < ' tcx > ,
173
173
current_point : PointIndex ,
174
174
universal_regions : & UniversalRegions < ' tcx > ,
175
- ) -> ( PointIndex , PointIndex ) {
175
+ ) -> LocalizedOutlivesConstraint {
176
176
// FIXME: check if other terminators need the same handling as `Call`s, in particular
177
177
// Assert/Yield/Drop. A handful of tests are failing with Drop related issues, as well as some
178
178
// coroutine tests, and that may be why.
@@ -198,22 +198,27 @@ fn localize_terminator_constraint<'tcx>(
198
198
// Typeck constraints guide loans between regions at the current point, so we do that in
199
199
// the general case, and liveness will take care of making them flow to the terminator's
200
200
// 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
+ }
202
207
}
203
208
}
204
209
}
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.
209
214
fn compute_constraint_direction < ' tcx > (
210
215
tcx : TyCtxt < ' tcx > ,
211
216
outlives_constraint : & OutlivesConstraint < ' tcx > ,
212
217
value : & impl TypeVisitable < TyCtxt < ' tcx > > ,
213
218
current_point : PointIndex ,
214
219
successor_point : PointIndex ,
215
220
universal_regions : & UniversalRegions < ' tcx > ,
216
- ) -> ( PointIndex , PointIndex ) {
221
+ ) -> LocalizedOutlivesConstraint {
217
222
let mut to = current_point;
218
223
let mut from = current_point;
219
224
tcx. for_each_free_region ( value, |region| {
@@ -227,5 +232,10 @@ fn compute_constraint_direction<'tcx>(
227
232
}
228
233
} ) ;
229
234
230
- ( from, to)
235
+ LocalizedOutlivesConstraint {
236
+ source : outlives_constraint. sup ,
237
+ from,
238
+ target : outlives_constraint. sub ,
239
+ to,
240
+ }
231
241
}
0 commit comments