Skip to content

Commit 39d8081

Browse files
committed
encapsulate access to member constraints
1 parent b5d4f10 commit 39d8081

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

compiler/rustc_borrowck/src/dataflow.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
330330
// region that outlives free regions via outlives constraints.)
331331

332332
let sccs = self.regioncx.constraint_sccs();
333-
let member_constraints = &self.regioncx.member_constraints;
334333

335334
let issuing_region_scc = sccs.scc(issuing_region);
336335
self.reachability_stack.push(issuing_region_scc);
@@ -352,15 +351,15 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
352351
//
353352
// If the issuing region outlives such a region, its loan escapes the function and
354353
// cannot go out of scope. We can early return.
355-
if member_constraints.indices(scc).next().is_some()
354+
if self.regioncx.scc_has_member_constraints(scc)
356355
|| self.sccs_live_at_all_points.contains(&scc)
357356
{
358357
self.reachability_stack.clear();
359358
self.reachability.clear();
360359
return;
361360
}
362361

363-
// 3. Via outlives successors, which we want to record and traverse, so we add them
362+
// 3. Via outlives successors, which we want to record and traverse: we add them
364363
// to the worklist stack
365364
for &succ_scc in sccs.successors(scc) {
366365
if self.reachability.insert(succ_scc) {

compiler/rustc_borrowck/src/region_infer/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub struct RegionInferenceContext<'tcx> {
7979
rev_scc_graph: Option<ReverseSccGraph>,
8080

8181
/// The "R0 member of [R1..Rn]" constraints, indexed by SCC.
82-
pub(crate) member_constraints: Rc<MemberConstraintSet<'tcx, ConstraintSccIndex>>,
82+
member_constraints: Rc<MemberConstraintSet<'tcx, ConstraintSccIndex>>,
8383

8484
/// Records the member constraints that we applied to each scc.
8585
/// This is useful for error reporting. Once constraint
@@ -2289,6 +2289,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
22892289
pub(crate) fn liveness_values(&self) -> &LivenessValues<RegionVid> {
22902290
&self.liveness_constraints
22912291
}
2292+
2293+
/// Returns whether the given SCC has any member constraints.
2294+
pub(crate) fn scc_has_member_constraints(&self, scc: ConstraintSccIndex) -> bool {
2295+
self.member_constraints.indices(scc).next().is_some()
2296+
}
22922297
}
22932298

22942299
impl<'tcx> RegionDefinition<'tcx> {

0 commit comments

Comments
 (0)