]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/borrow_check/nll/region_infer/mod.rs
more nits + typos
[rust.git] / src / librustc_mir / borrow_check / nll / region_infer / mod.rs
index 7e83ea2aa4ed98ee7097fee4ebb9900dd7498ad0..4e609460c1f70aeb92ac635c032b79a7e23ae7f1 100644 (file)
@@ -598,7 +598,7 @@ fn propagate_constraint_sccs_new(
             }
         }
 
-        // Now take member constraints into account. 
+        // Now take member constraints into account.
         let member_constraints = self.member_constraints.clone();
         for m_c_i in member_constraints.indices(scc_a) {
             self.apply_member_constraint(
@@ -682,7 +682,8 @@ fn apply_member_constraint(
         // 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 @@ fn apply_member_constraint(
 
     /// 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).
@@ -1564,7 +1560,7 @@ fn check_member_constraints(
             let choice_regions = member_constraints.choice_regions(m_c_i);
             debug!("check_member_constraint: choice_regions={:?}", choice_regions);
 
-            // did the pick-region wind up equal to any of the option regions?
+            // Did the member region wind up equal to any of the option regions?
             if let Some(o) = choice_regions.iter().find(|&&o_r| {
                 self.eval_equal(o_r, m_c.member_region_vid)
             }) {
@@ -1572,7 +1568,7 @@ fn check_member_constraints(
                 continue;
             }
 
-            // if not, report an error
+            // If not, report an error.
             let region_scope_tree = &infcx.tcx.region_scope_tree(mir_def_id);
             let member_region = infcx.tcx.mk_region(ty::ReVar(member_region_vid));
             opaque_types::unexpected_hidden_region_diagnostic(