|
1 | 1 | use crate::borrow_check::nll::constraints::OutlivesConstraint; |
2 | | -use crate::borrow_check::nll::region_infer::AppliedMemberConstraint; |
3 | 2 | use crate::borrow_check::nll::region_infer::RegionInferenceContext; |
4 | 3 | use crate::borrow_check::nll::type_check::Locations; |
5 | 4 | use crate::borrow_check::nll::universal_regions::DefiningTy; |
@@ -253,29 +252,33 @@ impl<'tcx> RegionInferenceContext<'tcx> { |
253 | 252 | let outgoing_edges_from_graph = self.constraint_graph |
254 | 253 | .outgoing_edges(r, &self.constraints, fr_static); |
255 | 254 |
|
256 | | - |
257 | | - // But member constraints can also give rise to `'r: 'x` |
258 | | - // edges that were not part of the graph initially, so |
259 | | - // watch out for those. |
260 | | - let outgoing_edges_from_picks = self.applied_member_constraints(r) |
261 | | - .iter() |
262 | | - .map(|&AppliedMemberConstraint { min_choice, member_constraint_index, .. }| { |
263 | | - let p_c = &self.member_constraints[member_constraint_index]; |
264 | | - OutlivesConstraint { |
265 | | - sup: r, |
266 | | - sub: min_choice, |
267 | | - locations: Locations::All(p_c.definition_span), |
268 | | - category: ConstraintCategory::OpaqueType, |
269 | | - } |
270 | | - }); |
271 | | - |
272 | | - for constraint in outgoing_edges_from_graph.chain(outgoing_edges_from_picks) { |
| 255 | + // Always inline this closure because it can be hot. |
| 256 | + let mut handle_constraint = #[inline(always)] |constraint: OutlivesConstraint| { |
273 | 257 | debug_assert_eq!(constraint.sup, r); |
274 | 258 | let sub_region = constraint.sub; |
275 | 259 | if let Trace::NotVisited = context[sub_region] { |
276 | 260 | context[sub_region] = Trace::FromOutlivesConstraint(constraint); |
277 | 261 | deque.push_back(sub_region); |
278 | 262 | } |
| 263 | + }; |
| 264 | + |
| 265 | + // This loop can be hot. |
| 266 | + for constraint in outgoing_edges_from_graph { |
| 267 | + handle_constraint(constraint); |
| 268 | + } |
| 269 | + |
| 270 | + // Member constraints can also give rise to `'r: 'x` edges that |
| 271 | + // were not part of the graph initially, so watch out for those. |
| 272 | + // (But they are extremely rare; this loop is very cold.) |
| 273 | + for constraint in self.applied_member_constraints(r) { |
| 274 | + let p_c = &self.member_constraints[constraint.member_constraint_index]; |
| 275 | + let constraint = OutlivesConstraint { |
| 276 | + sup: r, |
| 277 | + sub: constraint.min_choice, |
| 278 | + locations: Locations::All(p_c.definition_span), |
| 279 | + category: ConstraintCategory::OpaqueType, |
| 280 | + }; |
| 281 | + handle_constraint(constraint); |
279 | 282 | } |
280 | 283 | } |
281 | 284 |
|
|
0 commit comments