about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-06-24 15:52:46 -0400
committerNiko Matsakis <niko@alum.mit.edu>2019-07-02 12:25:23 -0400
commit9217909518cecc3b8636e970bfcb6c0be231e3f2 (patch)
tree3314abe2c0c262b5971cf8fc42a135f23e0d8bf6
parent0dd074e8548ce386d38e647a47d41ec75c93f307 (diff)
downloadrust-9217909518cecc3b8636e970bfcb6c0be231e3f2.tar.gz
rust-9217909518cecc3b8636e970bfcb6c0be231e3f2.zip
pass a parameter to enable impl Trait instead of a vec
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/mod.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
index 7e83ea2aa4e..89d0be3a10c 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
@@ -682,7 +682,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         // for all UB.
         if choice_regions.len() > 1 {
             let universal_region_relations = self.universal_region_relations.clone();
-            for ub in self.upper_bounds(scc) {
+            let rev_constraint_graph = self.rev_constraint_graph();
+            for ub in self.upper_bounds(scc, &rev_constraint_graph) {
                 debug!("apply_member_constraint: ub={:?}", ub);
                 choice_regions.retain(|&o_r| universal_region_relations.outlives(ub, o_r));
             }
@@ -749,22 +750,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
 
     /// Compute and return the reverse SCC-based constraint graph (lazilly).
     fn upper_bounds(
-        &mut self,
+        &'a mut self,
         scc0: ConstraintSccIndex,
-    ) -> Vec<RegionVid> {
-        // I wanted to return an `impl Iterator` here, but it's
-        // annoying because the `rev_constraint_graph` is in a local
-        // variable. We'd need a "once-cell" or some such thing to let
-        // us borrow it for the right amount of time. -- nikomatsakis
-        let rev_constraint_graph = self.rev_constraint_graph();
+        rev_constraint_graph: &'a VecGraph<ConstraintSccIndex>,
+    ) -> impl Iterator<Item = RegionVid> + 'a {
         let scc_values = &self.scc_values;
         let mut duplicates = FxHashSet::default();
         rev_constraint_graph
             .depth_first_search(scc0)
             .skip(1)
-            .flat_map(|scc1| scc_values.universal_regions_outlived_by(scc1))
-            .filter(|&r| duplicates.insert(r))
-            .collect()
+            .flat_map(move |scc1| scc_values.universal_regions_outlived_by(scc1))
+            .filter(move |&r| duplicates.insert(r))
     }
 
     /// Compute and return the reverse SCC-based constraint graph (lazilly).