Don't match any projection predicates when the obligation has inference types or consts in GAT substs
This commit is contained in:
parent
c5e414843e
commit
3602e0e262
4 changed files with 64 additions and 2 deletions
|
@ -2470,8 +2470,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let projection_ty = ty::ProjectionTy {
|
||||
// `T`
|
||||
substs: self.tcx.mk_substs_trait(
|
||||
trait_pred.self_ty().skip_binder(),
|
||||
self.fresh_substs_for_item(span, item_def_id),
|
||||
trait_ref.self_ty().skip_binder(),
|
||||
&self.fresh_substs_for_item(span, item_def_id)[1..],
|
||||
),
|
||||
// `Future::Output`
|
||||
item_def_id,
|
||||
|
|
|
@ -1521,6 +1521,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
infer_predicate.projection_ty
|
||||
};
|
||||
|
||||
// If the obligation contains any inference types or consts in associated
|
||||
// type substs, then we don't match any projection candidates against it.
|
||||
// This isn't really correct, but otherwise we can end up in a case where
|
||||
// we constrain inference variables by selecting a single predicate, when
|
||||
// we need to stay general. See issue #91762.
|
||||
let (_, predicate_own_substs) =
|
||||
obligation.predicate.trait_ref_and_own_substs(self.infcx.tcx);
|
||||
if predicate_own_substs.iter().any(|g| g.has_infer_types_or_consts()) {
|
||||
return false;
|
||||
}
|
||||
self.infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.sup(obligation.predicate, infer_projection)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue