@@ -20,6 +20,7 @@ use super::has_only_region_constraints;
2020use crate :: coherence;
2121use crate :: delegate:: SolverDelegate ;
2222use crate :: placeholder:: BoundVarReplacer ;
23+ use crate :: resolve:: eager_resolve_vars;
2324use crate :: solve:: inspect:: { self , ProofTreeBuilder } ;
2425use crate :: solve:: search_graph:: SearchGraph ;
2526use crate :: solve:: ty:: may_use_unstable_feature;
@@ -440,17 +441,24 @@ where
440441 return Ok ( (
441442 NestedNormalizationGoals :: empty ( ) ,
442443 GoalEvaluation {
444+ goal,
443445 certainty : Certainty :: Maybe ( stalled_on. stalled_cause ) ,
444446 has_changed : HasChanged :: No ,
445447 stalled_on : Some ( stalled_on) ,
446448 } ,
447449 ) ) ;
448450 }
449451
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+
450458 let is_hir_typeck_root_goal = matches ! ( goal_evaluation_kind, GoalEvaluationKind :: Root )
451459 && 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 ) ;
454462 let mut goal_evaluation =
455463 self . inspect . new_goal_evaluation ( goal, & orig_values, goal_evaluation_kind) ;
456464 let canonical_result = self . search_graph . evaluate_goal (
@@ -528,7 +536,10 @@ where
528536 } ,
529537 } ;
530538
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+ ) )
532543 }
533544
534545 pub ( super ) fn compute_goal ( & mut self , goal : Goal < I , I :: Predicate > ) -> QueryResult < I > {
@@ -664,7 +675,7 @@ where
664675
665676 let (
666677 NestedNormalizationGoals ( nested_goals) ,
667- GoalEvaluation { certainty, stalled_on, has_changed : _ } ,
678+ GoalEvaluation { goal , certainty, stalled_on, has_changed : _ } ,
668679 ) = self . evaluate_goal_raw (
669680 GoalEvaluationKind :: Nested ,
670681 source,
@@ -702,7 +713,15 @@ where
702713 // FIXME: Do we need to eagerly resolve here? Or should we check
703714 // if the cache key has any changed vars?
704715 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+ {
706725 unchanged_certainty = None ;
707726 }
708727
@@ -714,7 +733,7 @@ where
714733 }
715734 }
716735 } else {
717- let GoalEvaluation { certainty, has_changed, stalled_on } =
736+ let GoalEvaluation { goal , certainty, has_changed, stalled_on } =
718737 self . evaluate_goal ( GoalEvaluationKind :: Nested , source, goal, stalled_on) ?;
719738 if has_changed == HasChanged :: Yes {
720739 unchanged_certainty = None ;
0 commit comments