@@ -67,8 +67,8 @@ impl<'tcx> MirPass<'tcx> for Validator {
6767 unwind_edge_count : 0 ,
6868 reachable_blocks : traversal:: reachable_as_bitset ( body) ,
6969 storage_liveness,
70- place_cache : Vec :: new ( ) ,
71- value_cache : Vec :: new ( ) ,
70+ place_cache : FxHashSet :: default ( ) ,
71+ value_cache : FxHashSet :: default ( ) ,
7272 } ;
7373 checker. visit_body ( body) ;
7474 checker. check_cleanup_control_flow ( ) ;
@@ -95,8 +95,8 @@ struct TypeChecker<'a, 'tcx> {
9595 unwind_edge_count : usize ,
9696 reachable_blocks : BitSet < BasicBlock > ,
9797 storage_liveness : ResultsCursor < ' a , ' tcx , MaybeStorageLive < ' static > > ,
98- place_cache : Vec < PlaceRef < ' tcx > > ,
99- value_cache : Vec < u128 > ,
98+ place_cache : FxHashSet < PlaceRef < ' tcx > > ,
99+ value_cache : FxHashSet < u128 > ,
100100}
101101
102102impl < ' a , ' tcx > TypeChecker < ' a , ' tcx > {
@@ -951,10 +951,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
951951
952952 self . value_cache . clear ( ) ;
953953 self . value_cache . extend ( targets. iter ( ) . map ( |( value, _) | value) ) ;
954- let all_len = self . value_cache . len ( ) ;
955- self . value_cache . sort_unstable ( ) ;
956- self . value_cache . dedup ( ) ;
957- let has_duplicates = all_len != self . value_cache . len ( ) ;
954+ let has_duplicates = targets. iter ( ) . len ( ) != self . value_cache . len ( ) ;
958955 if has_duplicates {
959956 self . fail (
960957 location,
@@ -987,16 +984,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
987984 // passed by a reference to the callee. Consequently they must be non-overlapping.
988985 // Currently this simply checks for duplicate places.
989986 self . place_cache . clear ( ) ;
990- self . place_cache . push ( destination. as_ref ( ) ) ;
987+ self . place_cache . insert ( destination. as_ref ( ) ) ;
988+ let mut has_duplicates = false ;
991989 for arg in args {
992990 if let Operand :: Move ( place) = arg {
993- self . place_cache . push ( place. as_ref ( ) ) ;
991+ has_duplicates |= ! self . place_cache . insert ( place. as_ref ( ) ) ;
994992 }
995993 }
996- let all_len = self . place_cache . len ( ) ;
997- let mut dedup = FxHashSet :: default ( ) ;
998- self . place_cache . retain ( |p| dedup. insert ( * p) ) ;
999- let has_duplicates = all_len != self . place_cache . len ( ) ;
994+
1000995 if has_duplicates {
1001996 self . fail (
1002997 location,
0 commit comments