Skip to content

Commit 9217909

Browse files
committed
pass a parameter to enable impl Trait instead of a vec
1 parent 0dd074e commit 9217909

File tree

1 file changed

+7
-11
lines changed
  • src/librustc_mir/borrow_check/nll/region_infer

1 file changed

+7
-11
lines changed

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
682682
// for all UB.
683683
if choice_regions.len() > 1 {
684684
let universal_region_relations = self.universal_region_relations.clone();
685-
for ub in self.upper_bounds(scc) {
685+
let rev_constraint_graph = self.rev_constraint_graph();
686+
for ub in self.upper_bounds(scc, &rev_constraint_graph) {
686687
debug!("apply_member_constraint: ub={:?}", ub);
687688
choice_regions.retain(|&o_r| universal_region_relations.outlives(ub, o_r));
688689
}
@@ -749,22 +750,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
749750

750751
/// Compute and return the reverse SCC-based constraint graph (lazilly).
751752
fn upper_bounds(
752-
&mut self,
753+
&'a mut self,
753754
scc0: ConstraintSccIndex,
754-
) -> Vec<RegionVid> {
755-
// I wanted to return an `impl Iterator` here, but it's
756-
// annoying because the `rev_constraint_graph` is in a local
757-
// variable. We'd need a "once-cell" or some such thing to let
758-
// us borrow it for the right amount of time. -- nikomatsakis
759-
let rev_constraint_graph = self.rev_constraint_graph();
755+
rev_constraint_graph: &'a VecGraph<ConstraintSccIndex>,
756+
) -> impl Iterator<Item = RegionVid> + 'a {
760757
let scc_values = &self.scc_values;
761758
let mut duplicates = FxHashSet::default();
762759
rev_constraint_graph
763760
.depth_first_search(scc0)
764761
.skip(1)
765-
.flat_map(|scc1| scc_values.universal_regions_outlived_by(scc1))
766-
.filter(|&r| duplicates.insert(r))
767-
.collect()
762+
.flat_map(move |scc1| scc_values.universal_regions_outlived_by(scc1))
763+
.filter(move |&r| duplicates.insert(r))
768764
}
769765

770766
/// Compute and return the reverse SCC-based constraint graph (lazilly).

0 commit comments

Comments
 (0)