Skip to content

Commit 9588f7f

Browse files
committed
rewrite dup_vec to use IndexVec instead of u32
1 parent b4a3753 commit 9588f7f

File tree

1 file changed

+6
-7
lines changed
  • src/librustc/infer/lexical_region_resolve

1 file changed

+6
-7
lines changed

src/librustc/infer/lexical_region_resolve/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use rustc_data_structures::graph::implementation::{
2222
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
2323
use smallvec::SmallVec;
2424
use std::fmt;
25-
use std::u32;
2625
use syntax_pos::Span;
2726

2827
mod graphviz;
@@ -623,7 +622,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
623622
// idea is to report errors that derive from independent
624623
// regions of the graph, but not those that derive from
625624
// overlapping locations.
626-
let mut dup_vec = vec![u32::MAX; self.num_vars()];
625+
let mut dup_vec = IndexVec::from_elem_n(None, self.num_vars());
627626

628627
for (node_vid, value) in var_data.values.iter_enumerated() {
629628
match *value {
@@ -702,7 +701,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
702701
fn collect_error_for_expanding_node(
703702
&self,
704703
graph: &RegionGraph<'tcx>,
705-
dup_vec: &mut [u32],
704+
dup_vec: &mut IndexVec<RegionVid, Option<RegionVid>>,
706705
node_idx: RegionVid,
707706
errors: &mut Vec<RegionResolutionError<'tcx>>,
708707
) {
@@ -781,7 +780,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
781780
graph: &RegionGraph<'tcx>,
782781
orig_node_idx: RegionVid,
783782
dir: Direction,
784-
mut dup_vec: Option<&mut [u32]>,
783+
mut dup_vec: Option<&mut IndexVec<RegionVid, Option<RegionVid>>>,
785784
) -> (Vec<RegionAndOrigin<'tcx>>, bool) {
786785
struct WalkState<'tcx> {
787786
set: FxHashSet<RegionVid>,
@@ -806,9 +805,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
806805

807806
// check whether we've visited this node on some previous walk
808807
if let Some(dup_vec) = &mut dup_vec {
809-
if dup_vec[node_idx.index() as usize] == u32::MAX {
810-
dup_vec[node_idx.index() as usize] = orig_node_idx.index() as u32;
811-
} else if dup_vec[node_idx.index() as usize] != orig_node_idx.index() as u32 {
808+
if dup_vec[node_idx].is_none() {
809+
dup_vec[node_idx] = Some(orig_node_idx);
810+
} else if dup_vec[node_idx] != Some(orig_node_idx) {
812811
state.dup_found = true;
813812
}
814813

0 commit comments

Comments
 (0)