1
Fork 0

Assert goal is fully normalized during assemble

This commit is contained in:
Michael Goulet 2023-01-19 15:32:20 +00:00
parent c9c8e294d2
commit aee75f25cb

View file

@ -79,7 +79,7 @@ pub(super) enum CandidateSource {
AliasBound(usize), 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 self_ty(self) -> Ty<'tcx>;
fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self; fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self;
@ -124,6 +124,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
&mut self, &mut self,
goal: Goal<'tcx, G>, goal: Goal<'tcx, G>,
) -> Vec<Candidate<'tcx>> { ) -> 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, // 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 // object bound, alias bound, etc. We are unable to determine this until we can at
// least structually resolve the type one layer. // least structually resolve the type one layer.
@ -179,6 +181,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
Ok((_, certainty)) => certainty, Ok((_, certainty)) => certainty,
Err(NoSolution) => return, 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. // 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. // This doesn't work as long as we use `CandidateSource` in winnowing.