@@ -40,6 +40,7 @@ pub use global_cache::GlobalCache;
4040pub trait Cx : Copy {
4141 type Input : Debug + Eq + Hash + Copy ;
4242 type Result : Debug + Eq + Hash + Copy ;
43+ type AmbiguityInfo : Debug + Eq + Hash + Copy ;
4344
4445 type DepNodeIndex ;
4546 type Tracked < T : Debug + Clone > : Debug ;
@@ -96,11 +97,13 @@ pub trait Delegate: Sized {
9697 input : <Self :: Cx as Cx >:: Input ,
9798 ) -> <Self :: Cx as Cx >:: Result ;
9899
99- fn is_ambiguous_result ( result : <Self :: Cx as Cx >:: Result ) -> bool ;
100+ fn is_ambiguous_result (
101+ result : <Self :: Cx as Cx >:: Result ,
102+ ) -> Option < <Self :: Cx as Cx >:: AmbiguityInfo > ;
100103 fn propagate_ambiguity (
101104 cx : Self :: Cx ,
102105 for_input : <Self :: Cx as Cx >:: Input ,
103- from_result : <Self :: Cx as Cx >:: Result ,
106+ ambiguity_info : <Self :: Cx as Cx >:: AmbiguityInfo ,
104107 ) -> <Self :: Cx as Cx >:: Result ;
105108
106109 fn compute_goal (
@@ -913,9 +916,9 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
913916/// heads from the stack. This may not necessarily mean that we've actually
914917/// reached a fixpoint for that cycle head, which impacts the way we rebase
915918/// provisional cache entries.
916- enum RebaseReason {
919+ enum RebaseReason < X : Cx > {
917920 NoCycleUsages ,
918- Ambiguity ,
921+ Ambiguity ( X :: AmbiguityInfo ) ,
919922 Overflow ,
920923 /// We've actually reached a fixpoint.
921924 ///
@@ -951,7 +954,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D, X> {
951954 & mut self ,
952955 cx : X ,
953956 stack_entry : & StackEntry < X > ,
954- rebase_reason : RebaseReason ,
957+ rebase_reason : RebaseReason < X > ,
955958 ) {
956959 let popped_head_index = self . stack . next_index ( ) ;
957960 #[ allow( rustc:: potential_query_instability) ]
@@ -969,10 +972,6 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D, X> {
969972 return true ;
970973 } ;
971974
972- let Some ( new_highest_head_index) = heads. opt_highest_cycle_head_index ( ) else {
973- return false ;
974- } ;
975-
976975 // We're rebasing an entry `e` over a head `p`. This head
977976 // has a number of own heads `h` it depends on.
978977 //
@@ -1033,8 +1032,8 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D, X> {
10331032 // is not actually equal to the final provisional result. We
10341033 // need to discard the provisional cache entry in this case.
10351034 RebaseReason :: NoCycleUsages => return false ,
1036- RebaseReason :: Ambiguity => {
1037- * result = D :: propagate_ambiguity ( cx, input, * result ) ;
1035+ RebaseReason :: Ambiguity ( info ) => {
1036+ * result = D :: propagate_ambiguity ( cx, input, info ) ;
10381037 }
10391038 RebaseReason :: Overflow => * result = D :: fixpoint_overflow_result ( cx, input) ,
10401039 RebaseReason :: ReachedFixpoint ( None ) => { }
@@ -1046,6 +1045,10 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D, X> {
10461045 } ;
10471046 }
10481047
1048+ let Some ( new_highest_head_index) = heads. opt_highest_cycle_head_index ( ) else {
1049+ return false ;
1050+ } ;
1051+
10491052 // We now care about the path from the next highest cycle head to the
10501053 // provisional cache entry.
10511054 * path_from_head = path_from_head. extend ( Self :: cycle_path_kind (
@@ -1268,6 +1271,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D, X> {
12681271 }
12691272
12701273 /// Whether we've reached a fixpoint when evaluating a cycle head.
1274+ #[ instrument( level = "trace" , skip( self , stack_entry) , ret) ]
12711275 fn reached_fixpoint (
12721276 & mut self ,
12731277 stack_entry : & StackEntry < X > ,
@@ -1355,8 +1359,12 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D, X> {
13551359 // As we only get to this branch if we haven't yet reached a fixpoint,
13561360 // we also taint all provisional cache entries which depend on the
13571361 // current goal.
1358- if D :: is_ambiguous_result ( result) {
1359- self . rebase_provisional_cache_entries ( cx, & stack_entry, RebaseReason :: Ambiguity ) ;
1362+ if let Some ( info) = D :: is_ambiguous_result ( result) {
1363+ self . rebase_provisional_cache_entries (
1364+ cx,
1365+ & stack_entry,
1366+ RebaseReason :: Ambiguity ( info) ,
1367+ ) ;
13601368 return EvaluationResult :: finalize ( stack_entry, encountered_overflow, result) ;
13611369 } ;
13621370
0 commit comments