@@ -23,14 +23,15 @@ use rustc_middle::ty::{
23
23
use rustc_session:: config:: DumpSolverProofTree ;
24
24
use rustc_span:: DUMMY_SP ;
25
25
use std:: io:: Write ;
26
+ use std:: iter;
26
27
use std:: ops:: ControlFlow ;
27
28
28
29
use crate :: traits:: vtable:: { count_own_vtable_entries, prepare_vtable_segments, VtblSegment } ;
29
30
30
31
use super :: inspect:: ProofTreeBuilder ;
31
- use super :: SolverMode ;
32
32
use super :: { search_graph, GoalEvaluationKind } ;
33
33
use super :: { search_graph:: SearchGraph , Goal } ;
34
+ use super :: { GoalSource , SolverMode } ;
34
35
pub use select:: InferCtxtSelectExt ;
35
36
36
37
mod canonical;
@@ -105,7 +106,7 @@ pub(super) struct NestedGoals<'tcx> {
105
106
/// can be unsound with more powerful coinduction in the future.
106
107
pub ( super ) normalizes_to_hack_goal : Option < Goal < ' tcx , ty:: NormalizesTo < ' tcx > > > ,
107
108
/// 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 > > ) > ,
109
110
}
110
111
111
112
impl < ' tcx > NestedGoals < ' tcx > {
@@ -439,7 +440,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
439
440
} else {
440
441
let kind = self . infcx . instantiate_binder_with_placeholders ( kind) ;
441
442
let goal = goal. with ( self . tcx ( ) , ty:: Binder :: dummy ( kind) ) ;
442
- self . add_goal ( goal) ;
443
+ self . add_goal ( GoalSource :: Misc , goal) ;
443
444
self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
444
445
}
445
446
}
@@ -488,6 +489,13 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
488
489
let mut goals = core:: mem:: replace ( & mut self . nested_goals , NestedGoals :: new ( ) ) ;
489
490
490
491
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
+
491
499
// If this loop did not result in any progress, what's our final certainty.
492
500
let mut unchanged_certainty = Some ( Certainty :: Yes ) ;
493
501
if let Some ( goal) = goals. normalizes_to_hack_goal . take ( ) {
@@ -503,7 +511,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
503
511
GoalEvaluationKind :: Nested { is_normalizes_to_hack : IsNormalizesToHack :: Yes } ,
504
512
unconstrained_goal,
505
513
) ?;
506
- self . nested_goals . goals . extend ( instantiate_goals) ;
514
+ self . nested_goals . goals . extend ( with_misc_source ( instantiate_goals) ) ;
507
515
508
516
// Finally, equate the goal's RHS with the unconstrained var.
509
517
// We put the nested goals from this into goals instead of
@@ -512,7 +520,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
512
520
// matters in practice, though.
513
521
let eq_goals =
514
522
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) ) ;
516
524
517
525
// We only look at the `projection_ty` part here rather than
518
526
// looking at the "has changed" return from evaluate_goal,
@@ -533,20 +541,20 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
533
541
}
534
542
}
535
543
536
- for goal in goals. goals . drain ( ..) {
544
+ for ( source , goal) in goals. goals . drain ( ..) {
537
545
let ( has_changed, certainty, instantiate_goals) = self . evaluate_goal (
538
546
GoalEvaluationKind :: Nested { is_normalizes_to_hack : IsNormalizesToHack :: No } ,
539
547
goal,
540
548
) ?;
541
- self . nested_goals . goals . extend ( instantiate_goals) ;
549
+ self . nested_goals . goals . extend ( with_misc_source ( instantiate_goals) ) ;
542
550
if has_changed {
543
551
unchanged_certainty = None ;
544
552
}
545
553
546
554
match certainty {
547
555
Certainty :: Yes => { }
548
556
Certainty :: Maybe ( _) => {
549
- self . nested_goals . goals . push ( goal) ;
557
+ self . nested_goals . goals . push ( ( source , goal) ) ;
550
558
unchanged_certainty = unchanged_certainty. map ( |c| c. unify_with ( certainty) ) ;
551
559
}
552
560
}
@@ -670,7 +678,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
670
678
. at ( & ObligationCause :: dummy ( ) , param_env)
671
679
. eq ( DefineOpaqueTypes :: No , lhs, rhs)
672
680
. 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 ( ) ) ) ;
674
682
} )
675
683
. map_err ( |e| {
676
684
debug ! ( ?e, "failed to equate" ) ;
@@ -689,7 +697,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
689
697
. at ( & ObligationCause :: dummy ( ) , param_env)
690
698
. sub ( DefineOpaqueTypes :: No , sub, sup)
691
699
. 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 ( ) ) ) ;
693
701
} )
694
702
. map_err ( |e| {
695
703
debug ! ( ?e, "failed to subtype" ) ;
@@ -709,7 +717,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
709
717
. at ( & ObligationCause :: dummy ( ) , param_env)
710
718
. relate ( DefineOpaqueTypes :: No , lhs, variance, rhs)
711
719
. 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 ( ) ) ) ;
713
721
} )
714
722
. map_err ( |e| {
715
723
debug ! ( ?e, "failed to relate" ) ;
@@ -842,7 +850,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
842
850
true ,
843
851
& mut obligations,
844
852
) ?;
845
- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
853
+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
846
854
Ok ( ( ) )
847
855
}
848
856
@@ -862,7 +870,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
862
870
hidden_ty,
863
871
& mut obligations,
864
872
) ;
865
- self . add_goals ( obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
873
+ self . add_goals ( GoalSource :: Misc , obligations. into_iter ( ) . map ( |o| o. into ( ) ) ) ;
866
874
}
867
875
868
876
// Do something for each opaque/hidden pair defined with `def_id` in the
0 commit comments