@@ -20,6 +20,7 @@ use super::has_only_region_constraints;
20
20
use crate :: coherence;
21
21
use crate :: delegate:: SolverDelegate ;
22
22
use crate :: placeholder:: BoundVarReplacer ;
23
+ use crate :: resolve:: eager_resolve_vars;
23
24
use crate :: solve:: inspect:: { self , ProofTreeBuilder } ;
24
25
use crate :: solve:: search_graph:: SearchGraph ;
25
26
use crate :: solve:: ty:: may_use_unstable_feature;
@@ -440,17 +441,24 @@ where
440
441
return Ok ( (
441
442
NestedNormalizationGoals :: empty ( ) ,
442
443
GoalEvaluation {
444
+ goal,
443
445
certainty : Certainty :: Maybe ( stalled_on. stalled_cause ) ,
444
446
has_changed : HasChanged :: No ,
445
447
stalled_on : Some ( stalled_on) ,
446
448
} ,
447
449
) ) ;
448
450
}
449
451
452
+ // We only care about one entry per `OpaqueTypeKey` here,
453
+ // so we only canonicalize the lookup table and ignore
454
+ // duplicate entries.
455
+ let opaque_types = self . delegate . clone_opaque_types_lookup_table ( ) ;
456
+ let ( goal, opaque_types) = eager_resolve_vars ( self . delegate , ( goal, opaque_types) ) ;
457
+
450
458
let is_hir_typeck_root_goal = matches ! ( goal_evaluation_kind, GoalEvaluationKind :: Root )
451
459
&& self . delegate . in_hir_typeck ( ) ;
452
-
453
- let ( orig_values , canonical_goal ) = self . canonicalize_goal ( is_hir_typeck_root_goal, goal) ;
460
+ let ( orig_values , canonical_goal ) =
461
+ self . canonicalize_goal ( is_hir_typeck_root_goal, goal, opaque_types ) ;
454
462
let mut goal_evaluation =
455
463
self . inspect . new_goal_evaluation ( goal, & orig_values, goal_evaluation_kind) ;
456
464
let canonical_result = self . search_graph . evaluate_goal (
@@ -528,7 +536,10 @@ where
528
536
} ,
529
537
} ;
530
538
531
- Ok ( ( normalization_nested_goals, GoalEvaluation { certainty, has_changed, stalled_on } ) )
539
+ Ok ( (
540
+ normalization_nested_goals,
541
+ GoalEvaluation { goal, certainty, has_changed, stalled_on } ,
542
+ ) )
532
543
}
533
544
534
545
pub ( super ) fn compute_goal ( & mut self , goal : Goal < I , I :: Predicate > ) -> QueryResult < I > {
@@ -664,7 +675,7 @@ where
664
675
665
676
let (
666
677
NestedNormalizationGoals ( nested_goals) ,
667
- GoalEvaluation { certainty, stalled_on, has_changed : _ } ,
678
+ GoalEvaluation { goal , certainty, stalled_on, has_changed : _ } ,
668
679
) = self . evaluate_goal_raw (
669
680
GoalEvaluationKind :: Nested ,
670
681
source,
@@ -702,7 +713,15 @@ where
702
713
// FIXME: Do we need to eagerly resolve here? Or should we check
703
714
// if the cache key has any changed vars?
704
715
let with_resolved_vars = self . resolve_vars_if_possible ( goal) ;
705
- if pred. alias != goal. predicate . as_normalizes_to ( ) . unwrap ( ) . skip_binder ( ) . alias {
716
+ if pred. alias
717
+ != with_resolved_vars
718
+ . predicate
719
+ . as_normalizes_to ( )
720
+ . unwrap ( )
721
+ . no_bound_vars ( )
722
+ . unwrap ( )
723
+ . alias
724
+ {
706
725
unchanged_certainty = None ;
707
726
}
708
727
@@ -714,7 +733,7 @@ where
714
733
}
715
734
}
716
735
} else {
717
- let GoalEvaluation { certainty, has_changed, stalled_on } =
736
+ let GoalEvaluation { goal , certainty, has_changed, stalled_on } =
718
737
self . evaluate_goal ( GoalEvaluationKind :: Nested , source, goal, stalled_on) ?;
719
738
if has_changed == HasChanged :: Yes {
720
739
unchanged_certainty = None ;
0 commit comments