Skip to content

Commit 4b7fdb3

Browse files
Ignore non-self item bounds for rigid projections
1 parent 5257aee commit 4b7fdb3

File tree

1 file changed

+13
-6
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+13
-6
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1619,16 +1619,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16191619
for bound in
16201620
self.tcx().item_bounds(alias_ty.def_id).instantiate(self.tcx(), alias_ty.args)
16211621
{
1622-
// HACK: On subsequent recursions, we only care about bounds that don't
1622+
// HACK: In the initial recursion, we only care about bounds for the
1623+
// `self_ty`. On subsequent recursions, we care about bounds that don't
16231624
// share the same type as `self_ty`. This is because for truly rigid
16241625
// projections, we will never be able to equate, e.g. `<T as Tr>::A`
16251626
// with `<<T as Tr>::A as Tr>::A`.
1626-
if in_parent_alias_type {
1627-
match bound.kind().skip_binder() {
1628-
ty::ClauseKind::Trait(tr) if tr.self_ty() == self_ty => continue,
1629-
ty::ClauseKind::Projection(p) if p.self_ty() == self_ty => continue,
1630-
_ => {}
1627+
match bound.kind().skip_binder() {
1628+
ty::ClauseKind::Trait(tr)
1629+
if (tr.self_ty() == self_ty) ^ !in_parent_alias_type =>
1630+
{
1631+
continue;
1632+
}
1633+
ty::ClauseKind::Projection(p)
1634+
if (p.self_ty() == self_ty) ^ !in_parent_alias_type =>
1635+
{
1636+
continue;
16311637
}
1638+
_ => {}
16321639
}
16331640

16341641
for_each(self, bound, idx)?;

0 commit comments

Comments
 (0)