1111use  middle:: subst:: { Substs ,  VecPerParamSpace } ; 
1212use  middle:: infer:: InferCtxt ; 
1313use  middle:: ty:: { self ,  Ty ,  AsPredicate ,  ToPolyTraitRef } ; 
14- use  std:: collections:: HashSet ; 
1514use  std:: fmt; 
1615use  std:: rc:: Rc ; 
1716use  syntax:: ast; 
1817use  syntax:: codemap:: Span ; 
1918use  util:: common:: ErrorReported ; 
19+ use  util:: nodemap:: FnvHashSet ; 
2020use  util:: ppaux:: Repr ; 
2121
2222use  super :: { Obligation ,  ObligationCause ,  PredicateObligation , 
@@ -36,7 +36,7 @@ use super::{Obligation, ObligationCause, PredicateObligation,
3636pub  struct  Elaborator < ' cx ,  ' tcx : ' cx >  { 
3737    tcx :  & ' cx  ty:: ctxt < ' tcx > , 
3838    stack :  Vec < StackEntry < ' tcx > > , 
39-     visited :  HashSet < ty:: Predicate < ' tcx > > , 
39+     visited :  FnvHashSet < ty:: Predicate < ' tcx > > , 
4040} 
4141
4242struct  StackEntry < ' tcx >  { 
@@ -65,14 +65,11 @@ pub fn elaborate_trait_refs<'cx, 'tcx>(
6565
6666pub  fn  elaborate_predicates < ' cx ,  ' tcx > ( 
6767    tcx :  & ' cx  ty:: ctxt < ' tcx > , 
68-     predicates :  Vec < ty:: Predicate < ' tcx > > ) 
68+     mut   predicates :  Vec < ty:: Predicate < ' tcx > > ) 
6969    -> Elaborator < ' cx ,  ' tcx > 
7070{ 
71-     let  visited:  HashSet < ty:: Predicate < ' tcx > >  =
72-         predicates. iter ( ) 
73-                   . map ( |b| ( * b) . clone ( ) ) 
74-                   . collect ( ) ; 
75- 
71+     let  mut  visited = FnvHashSet ( ) ; 
72+     predicates. retain ( |pred| visited. insert ( pred. clone ( ) ) ) ; 
7673    let  entry = StackEntry  {  position :  0 ,  predicates :  predicates } ; 
7774    Elaborator  {  tcx :  tcx,  stack :  vec ! [ entry] ,  visited :  visited } 
7875} 
0 commit comments