Skip to content

Commit

Permalink
Unrolled build for rust-lang#122970
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#122970 - cuviper:use-chunk_by, r=Mark-Simulacrum

Use `chunk_by` when building `ReverseSccGraph`

With stable `chunk_by` in Rust 1.77, this code doesn't need `Itertools::group_by` anymore.
  • Loading branch information
rust-timer committed Mar 25, 2024
2 parents cb7c636 + 87808e7 commit 668c905
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs
@@ -1,6 +1,5 @@
use crate::constraints::ConstraintSccIndex;
use crate::RegionInferenceContext;
use itertools::Itertools;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::graph::vec_graph::VecGraph;
use rustc_data_structures::graph::WithSuccessors;
Expand Down Expand Up @@ -48,16 +47,16 @@ impl RegionInferenceContext<'_> {
.universal_regions
.universal_regions()
.map(|region| (self.constraint_sccs.scc(region), region))
.collect_vec();
.collect::<Vec<_>>();
paired_scc_regions.sort();
let universal_regions = paired_scc_regions.iter().map(|&(_, region)| region).collect();

let mut scc_regions = FxIndexMap::default();
let mut start = 0;
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
let group_size = group.count();
scc_regions.insert(scc, start..start + group_size);
start += group_size;
for chunk in paired_scc_regions.chunk_by(|&(scc1, _), &(scc2, _)| scc1 == scc2) {
let (scc, _) = chunk[0];
scc_regions.insert(scc, start..start + chunk.len());
start += chunk.len();
}

self.rev_scc_graph = Some(ReverseSccGraph { graph, scc_regions, universal_regions });
Expand Down

0 comments on commit 668c905

Please sign in to comment.