Introduce DeepRejectCtxt::substs_refs_may_unify.

It factors out a repeated code pattern.
This commit is contained in:
Nicholas Nethercote 2023-03-07 15:42:50 +11:00
parent 478cbb42b7
commit 47225e8700
5 changed files with 23 additions and 17 deletions

View file

@ -2542,8 +2542,10 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
// substitution if we find that any of the input types, when
// simplified, do not match.
let drcx = DeepRejectCtxt { treat_obligation_params: TreatParams::ForLookup };
iter::zip(obligation.predicate.skip_binder().trait_ref.substs, impl_trait_ref.substs)
.any(|(obl, imp)| !drcx.generic_args_may_unify(obl, imp))
!drcx.substs_refs_may_unify(
obligation.predicate.skip_binder().trait_ref.substs,
impl_trait_ref.substs,
)
}
/// Normalize `where_clause_trait_ref` and try to match it against