File tree 2 files changed +8
-11
lines changed
compiler/rustc_borrowck/src/region_infer
2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ pub struct RegionInferenceContext<'tcx> {
76
76
/// Reverse of the SCC constraint graph -- i.e., an edge `A -> B` exists if
77
77
/// `B: A`. This is used to compute the universal regions that are required
78
78
/// to outlive a given SCC. Computed lazily.
79
- rev_scc_graph : Option < Rc < ReverseSccGraph > > ,
79
+ rev_scc_graph : Option < ReverseSccGraph > ,
80
80
81
81
/// The "R0 member of [R1..Rn]" constraints, indexed by SCC.
82
82
member_constraints : Rc < MemberConstraintSet < ' tcx , ConstraintSccIndex > > ,
@@ -813,9 +813,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
813
813
// free region that must outlive the member region `R0` (`UB:
814
814
// R0`). Therefore, we need only keep an option `O` if `UB: O`
815
815
// for all UB.
816
- let rev_scc_graph = self . reverse_scc_graph ( ) ;
816
+ self . compute_reverse_scc_graph ( ) ;
817
817
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) {
819
819
debug ! ( ?ub) ;
820
820
choice_regions. retain ( |& o_r| universal_region_relations. outlives ( ub, o_r) ) ;
821
821
}
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ use rustc_data_structures::graph::vec_graph::VecGraph;
8
8
use rustc_data_structures:: graph:: WithSuccessors ;
9
9
use rustc_middle:: ty:: RegionVid ;
10
10
use std:: ops:: Range ;
11
- use std:: rc:: Rc ;
12
11
13
12
pub ( crate ) struct ReverseSccGraph {
14
13
graph : VecGraph < ConstraintSccIndex > ,
@@ -40,10 +39,10 @@ impl ReverseSccGraph {
40
39
}
41
40
42
41
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 ;
47
46
}
48
47
49
48
let graph = self . constraint_sccs . reverse ( ) ;
@@ -63,8 +62,6 @@ impl RegionInferenceContext<'_> {
63
62
start += group_size;
64
63
}
65
64
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 } ) ;
69
66
}
70
67
}
You can’t perform that action at this time.
0 commit comments