Skip to content

Commit a621ec3

Browse files
committed
RegionInferenceContext: remove Rc from rev_scc_graph field
1 parent d3edfd1 commit a621ec3

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub struct RegionInferenceContext<'tcx> {
7676
/// Reverse of the SCC constraint graph -- i.e., an edge `A -> B` exists if
7777
/// `B: A`. This is used to compute the universal regions that are required
7878
/// to outlive a given SCC. Computed lazily.
79-
rev_scc_graph: Option<Rc<ReverseSccGraph>>,
79+
rev_scc_graph: Option<ReverseSccGraph>,
8080

8181
/// The "R0 member of [R1..Rn]" constraints, indexed by SCC.
8282
member_constraints: Rc<MemberConstraintSet<'tcx, ConstraintSccIndex>>,
@@ -813,9 +813,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
813813
// free region that must outlive the member region `R0` (`UB:
814814
// R0`). Therefore, we need only keep an option `O` if `UB: O`
815815
// for all UB.
816-
let rev_scc_graph = self.reverse_scc_graph();
816+
self.compute_reverse_scc_graph();
817817
let universal_region_relations = &self.universal_region_relations;
818-
for ub in rev_scc_graph.upper_bounds(scc) {
818+
for ub in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) {
819819
debug!(?ub);
820820
choice_regions.retain(|&o_r| universal_region_relations.outlives(ub, o_r));
821821
}

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_data_structures::graph::vec_graph::VecGraph;
88
use rustc_data_structures::graph::WithSuccessors;
99
use rustc_middle::ty::RegionVid;
1010
use std::ops::Range;
11-
use std::rc::Rc;
1211

1312
pub(crate) struct ReverseSccGraph {
1413
graph: VecGraph<ConstraintSccIndex>,
@@ -40,10 +39,10 @@ impl ReverseSccGraph {
4039
}
4140

4241
impl RegionInferenceContext<'_> {
43-
/// Compute and return the reverse SCC-based constraint graph (lazily).
44-
pub(super) fn reverse_scc_graph(&mut self) -> Rc<ReverseSccGraph> {
45-
if let Some(g) = &self.rev_scc_graph {
46-
return g.clone();
42+
/// Compute the reverse SCC-based constraint graph (lazily).
43+
pub(super) fn compute_reverse_scc_graph(&mut self) {
44+
if matches!(self.rev_scc_graph, Some(_)) {
45+
return;
4746
}
4847

4948
let graph = self.constraint_sccs.reverse();
@@ -63,8 +62,6 @@ impl RegionInferenceContext<'_> {
6362
start += group_size;
6463
}
6564

66-
let rev_graph = Rc::new(ReverseSccGraph { graph, scc_regions, universal_regions });
67-
self.rev_scc_graph = Some(rev_graph.clone());
68-
rev_graph
65+
self.rev_scc_graph = Some(ReverseSccGraph { graph, scc_regions, universal_regions });
6966
}
7067
}

0 commit comments

Comments
 (0)