@@ -23,14 +23,15 @@ use rustc_middle::ty::{
2323use rustc_session:: config:: DumpSolverProofTree ;
2424use rustc_span:: DUMMY_SP ;
2525use std:: io:: Write ;
26+ use std:: iter;
2627use std:: ops:: ControlFlow ;
2728
2829use crate :: traits:: vtable:: { count_own_vtable_entries, prepare_vtable_segments, VtblSegment } ;
2930
3031use super :: inspect:: ProofTreeBuilder ;
31- use super :: SolverMode ;
3232use super :: { search_graph, GoalEvaluationKind } ;
3333use super :: { search_graph:: SearchGraph , Goal } ;
34+ use super :: { GoalSource , SolverMode } ;
3435pub use select:: InferCtxtSelectExt ;
3536
3637mod canonical;
@@ -105,7 +106,7 @@ pub(super) struct NestedGoals<'tcx> {
105106 /// can be unsound with more powerful coinduction in the future.
106107 pub ( super ) normalizes_to_hack_goal : Option < Goal < ' tcx , ty:: NormalizesTo < ' tcx > > > ,
107108 /// The rest of the goals which have not yet processed or remain ambiguous.
108- pub ( super ) goals : Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
109+ pub ( super ) goals : Vec < ( GoalSource , Goal < ' tcx , ty:: Predicate < ' tcx > > ) > ,
109110}
110111
111112impl < ' tcx > NestedGoals < ' tcx > {
@@ -439,7 +440,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
439440 } else {
440441 let kind = self . infcx . instantiate_binder_with_placeholders ( kind) ;
441442 let goal = goal. with ( self . tcx ( ) , ty:: Binder :: dummy ( kind) ) ;
442- self . add_goal ( goal) ;
443+ self . add_goal ( GoalSource :: Misc , goal) ;
443444 self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
444445 }
445446 }
@@ -488,6 +489,13 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
488489 let mut goals = core:: mem:: replace ( & mut self . nested_goals , NestedGoals :: new ( ) ) ;
489490
490491 self . inspect . evaluate_added_goals_loop_start ( ) ;
492+
493+ fn with_misc_source < ' tcx > (
494+ it : impl IntoIterator < Item = Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
495+ ) -> impl Iterator < Item = ( GoalSource , Goal < ' tcx , ty:: Predicate < ' tcx > > ) > {
496+ iter:: zip ( iter:: repeat ( GoalSource :: Misc ) , it)
497+ }
498+
491499 // If this loop did not result in any progress, what's our final certainty.
492500 let mut unchanged_certainty = Some ( Certainty :: Yes ) ;
493501 if let Some ( goal) = goals. normalizes_to_hack_goal . take ( ) {
@@ -503,7 +511,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
503511 GoalEvaluationKind :: Nested { is_normalizes_to_hack : IsNormalizesToHack :: Yes } ,
504512 unconstrained_goal,
505513 ) ?;
506- self . nested_goals . goals . extend ( instantiate_goals) ;
514+ self . nested_goals . goals . extend ( with_misc_source ( instantiate_goals) ) ;
507515
508516 // Finally, equate the goal's RHS with the unconstrained var.
509517 // We put the nested goals from this into goals instead of
@@ -512,7 +520,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
512520 // matters in practice, though.
513521 let eq_goals =
514522 self . eq_and_get_goals ( goal. param_env , goal. predicate . term , unconstrained_rhs) ?;
515- goals. goals . extend ( eq_goals) ;
523+ goals. goals . extend ( with_misc_source ( eq_goals) ) ;
516524
517525 // We only look at the `projection_ty` part here rather than
518526 // looking at the "has changed" return from evaluate_goal,
@@ -533,20 +541,20 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
533541 }
534542 }
535543
536- for goal in goals. goals . drain ( ..) {
544+ for ( source , goal) in goals. goals . drain ( ..) {
537545 let ( has_changed, certainty, instantiate_goals) = self . evaluate_goal (
538546 GoalEvaluationKind :: Nested { is_normalizes_to_hack : IsNormalizesToHack :: No } ,
539547 goal,
540548 ) ?;
541- self . nested_goals . goals . extend ( instantiate_goals) ;
549+ self . nested_goals . goals . extend ( with_misc_source ( instantiate_goals) ) ;
542550 if has_changed {
543551 unchanged_certainty = None ;
544552 }
545553
546554 match certainty {
547555 Certainty :: Yes => { }
548556 Certainty :: Maybe ( _) => {
549- self . nested_goals . goals . push ( goal) ;
557+ self . nested_goals . goals . push ( ( source , goal) ) ;
550558 unchanged_certainty = unchanged_certainty. map ( |c| c. unify_with ( certainty) ) ;
551559 }
552560 }
@@ -670,7 +678,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
670678 . at ( & ObligationCause :: dummy ( ) , param_env)
671679 . eq ( DefineOpaqueTypes :: No , lhs, rhs)
672680 . map ( |InferOk { value : ( ) , obligations } | {
673- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
681+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
674682 } )
675683 . map_err ( |e| {
676684 debug ! ( ?e, "failed to equate" ) ;
@@ -689,7 +697,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
689697 . at ( & ObligationCause :: dummy ( ) , param_env)
690698 . sub ( DefineOpaqueTypes :: No , sub, sup)
691699 . map ( |InferOk { value : ( ) , obligations } | {
692- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
700+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
693701 } )
694702 . map_err ( |e| {
695703 debug ! ( ?e, "failed to subtype" ) ;
@@ -709,7 +717,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
709717 . at ( & ObligationCause :: dummy ( ) , param_env)
710718 . relate ( DefineOpaqueTypes :: No , lhs, variance, rhs)
711719 . map ( |InferOk { value : ( ) , obligations } | {
712- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
720+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
713721 } )
714722 . map_err ( |e| {
715723 debug ! ( ?e, "failed to relate" ) ;
@@ -842,7 +850,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
842850 true ,
843851 & mut obligations,
844852 ) ?;
845- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
853+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
846854 Ok ( ( ) )
847855 }
848856
@@ -862,7 +870,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
862870 hidden_ty,
863871 & mut obligations,
864872 ) ;
865- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
873+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
866874 }
867875
868876 // Do something for each opaque/hidden pair defined with `def_id` in the
0 commit comments