6
6
7
7
use std:: fmt:: Debug ;
8
8
9
- use rustc_data_structures:: fx:: FxIndexSet ;
9
+ use rustc_data_structures:: fx:: { FxHashSet , FxIndexSet } ;
10
10
use rustc_errors:: { Diag , EmissionGuarantee } ;
11
11
use rustc_hir:: def:: DefKind ;
12
12
use rustc_hir:: def_id:: DefId ;
@@ -627,6 +627,7 @@ fn compute_intercrate_ambiguity_causes<'tcx>(
627
627
}
628
628
629
629
struct AmbiguityCausesVisitor < ' a , ' tcx > {
630
+ cache : FxHashSet < Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
630
631
causes : & ' a mut FxIndexSet < IntercrateAmbiguityCause < ' tcx > > ,
631
632
}
632
633
@@ -636,6 +637,10 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
636
637
}
637
638
638
639
fn visit_goal ( & mut self , goal : & InspectGoal < ' _ , ' tcx > ) {
640
+ if !self . cache . insert ( goal. goal ( ) ) {
641
+ return ;
642
+ }
643
+
639
644
let infcx = goal. infcx ( ) ;
640
645
for cand in goal. candidates ( ) {
641
646
cand. visit_nested_in_probe ( self ) ;
@@ -760,5 +765,10 @@ fn search_ambiguity_causes<'tcx>(
760
765
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
761
766
causes : & mut FxIndexSet < IntercrateAmbiguityCause < ' tcx > > ,
762
767
) {
763
- infcx. probe ( |_| infcx. visit_proof_tree ( goal, & mut AmbiguityCausesVisitor { causes } ) ) ;
768
+ infcx. probe ( |_| {
769
+ infcx. visit_proof_tree ( goal, & mut AmbiguityCausesVisitor {
770
+ cache : Default :: default ( ) ,
771
+ causes,
772
+ } )
773
+ } ) ;
764
774
}
0 commit comments