@@ -22,7 +22,6 @@ use rustc_data_structures::graph::implementation::{
22
22
use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
23
23
use smallvec:: SmallVec ;
24
24
use std:: fmt;
25
- use std:: u32;
26
25
use syntax_pos:: Span ;
27
26
28
27
mod graphviz;
@@ -623,7 +622,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
623
622
// idea is to report errors that derive from independent
624
623
// regions of the graph, but not those that derive from
625
624
// 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 ( ) ) ;
627
626
628
627
for ( node_vid, value) in var_data. values . iter_enumerated ( ) {
629
628
match * value {
@@ -702,7 +701,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
702
701
fn collect_error_for_expanding_node (
703
702
& self ,
704
703
graph : & RegionGraph < ' tcx > ,
705
- dup_vec : & mut [ u32 ] ,
704
+ dup_vec : & mut IndexVec < RegionVid , Option < RegionVid > > ,
706
705
node_idx : RegionVid ,
707
706
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
708
707
) {
@@ -781,7 +780,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
781
780
graph : & RegionGraph < ' tcx > ,
782
781
orig_node_idx : RegionVid ,
783
782
dir : Direction ,
784
- mut dup_vec : Option < & mut [ u32 ] > ,
783
+ mut dup_vec : Option < & mut IndexVec < RegionVid , Option < RegionVid > > > ,
785
784
) -> ( Vec < RegionAndOrigin < ' tcx > > , bool ) {
786
785
struct WalkState < ' tcx > {
787
786
set : FxHashSet < RegionVid > ,
@@ -806,9 +805,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
806
805
807
806
// check whether we've visited this node on some previous walk
808
807
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 ) {
812
811
state. dup_found = true ;
813
812
}
814
813
0 commit comments