|
| 1 | +use std::cell::OnceCell; |
1 | 2 | use std::collections::VecDeque; |
2 | 3 | use std::rc::Rc; |
3 | 4 |
|
@@ -197,8 +198,8 @@ pub struct RegionInferenceContext<'tcx> { |
197 | 198 |
|
198 | 199 | /// Reverse of the SCC constraint graph -- i.e., an edge `A -> B` exists if |
199 | 200 | /// `B: A`. This is used to compute the universal regions that are required |
200 | | - /// to outlive a given SCC. Computed lazily. |
201 | | - rev_scc_graph: Option<ReverseSccGraph>, |
| 201 | + /// to outlive a given SCC. |
| 202 | + rev_scc_graph: OnceCell<ReverseSccGraph>, |
202 | 203 |
|
203 | 204 | /// The "R0 member of [R1..Rn]" constraints, indexed by SCC. |
204 | 205 | member_constraints: Rc<MemberConstraintSet<'tcx, ConstraintSccIndex>>, |
@@ -502,7 +503,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { |
502 | 503 | constraint_graph, |
503 | 504 | constraint_sccs, |
504 | 505 | scc_annotations, |
505 | | - rev_scc_graph: None, |
| 506 | + rev_scc_graph: OnceCell::new(), |
506 | 507 | member_constraints, |
507 | 508 | member_constraints_applied: Vec::new(), |
508 | 509 | universe_causes, |
@@ -809,9 +810,6 @@ impl<'tcx> RegionInferenceContext<'tcx> { |
809 | 810 | member_constraint_index: NllMemberConstraintIndex, |
810 | 811 | choice_regions: &[ty::RegionVid], |
811 | 812 | ) { |
812 | | - // Lazily compute the reverse graph, we'll need it later. |
813 | | - self.compute_reverse_scc_graph(); |
814 | | - |
815 | 813 | // Create a mutable vector of the options. We'll try to winnow |
816 | 814 | // them down. |
817 | 815 | let mut choice_regions: Vec<ty::RegionVid> = choice_regions.to_vec(); |
@@ -849,7 +847,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { |
849 | 847 | // R0`). Therefore, we need only keep an option `O` if `UB: O` |
850 | 848 | // for all UB. |
851 | 849 | let universal_region_relations = &self.universal_region_relations; |
852 | | - for ub in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) { |
| 850 | + for ub in self.reverse_scc_graph().upper_bounds(scc) { |
853 | 851 | debug!(?ub); |
854 | 852 | choice_regions.retain(|&o_r| universal_region_relations.outlives(ub, o_r)); |
855 | 853 | } |
|
0 commit comments