]> git.lizzy.rs Git - rust.git/commitdiff
Assert goal is fully normalized during assemble
authorMichael Goulet <michael@errs.io>
Thu, 19 Jan 2023 15:32:20 +0000 (15:32 +0000)
committerMichael Goulet <michael@errs.io>
Thu, 19 Jan 2023 16:15:28 +0000 (16:15 +0000)
compiler/rustc_trait_selection/src/solve/assembly.rs

index 2c92e7eb9ad3fa6ca5bc6d05d1c798b8ba4d2c53..45bce34b1edd83686c42d16d43a3b7834455001f 100644 (file)
@@ -79,7 +79,7 @@ pub(super) enum CandidateSource {
     AliasBound(usize),
 }
 
-pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy {
+pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy + Eq {
     fn self_ty(self) -> Ty<'tcx>;
 
     fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self;
@@ -124,6 +124,8 @@ pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<'tcx>>(
         &mut self,
         goal: Goal<'tcx, G>,
     ) -> Vec<Candidate<'tcx>> {
+        debug_assert_eq!(goal, self.infcx.resolve_vars_if_possible(goal));
+
         // HACK: `_: Trait` is ambiguous, because it may be satisfied via a builtin rule,
         // object bound, alias bound, etc. We are unable to determine this until we can at
         // least structually resolve the type one layer.
@@ -179,6 +181,7 @@ fn assemble_candidates_after_normalizing_self_ty<G: GoalKind<'tcx>>(
                 Ok((_, certainty)) => certainty,
                 Err(NoSolution) => return,
             };
+            let normalized_ty = self.infcx.resolve_vars_if_possible(normalized_ty);
 
             // NOTE: Alternatively we could call `evaluate_goal` here and only have a `Normalized` candidate.
             // This doesn't work as long as we use `CandidateSource` in winnowing.