@@ -22,7 +22,6 @@ use rustc_data_structures::graph::implementation::{
2222use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
2323use smallvec:: SmallVec ;
2424use std:: fmt;
25- use std:: u32;
2625use syntax_pos:: Span ;
2726
2827mod 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