Skip to content

Commit e6b64c6

Browse files
Ignore non-self item bounds for rigid projections
1 parent a128516 commit e6b64c6

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
@@ -1620,16 +1620,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16201620
for bound in
16211621
self.tcx().item_bounds(alias_ty.def_id).instantiate(self.tcx(), alias_ty.args)
16221622
{
1623-
// HACK: On subsequent recursions, we only care about bounds that don't
1623+
// HACK: In the initial recursion, we only care about bounds for the
1624+
// `self_ty`. On subsequent recursions, we care about bounds that don't
16241625
// share the same type as `self_ty`. This is because for truly rigid
16251626
// projections, we will never be able to equate, e.g. `<T as Tr>::A`
16261627
// with `<<T as Tr>::A as Tr>::A`.
1627-
if in_parent_alias_type {
1628-
match bound.kind().skip_binder() {
1629-
ty::ClauseKind::Trait(tr) if tr.self_ty() == self_ty => continue,
1630-
ty::ClauseKind::Projection(p) if p.self_ty() == self_ty => continue,
1631-
_ => {}
1628+
match bound.kind().skip_binder() {
1629+
ty::ClauseKind::Trait(tr)
1630+
if (tr.self_ty() == self_ty) ^ !in_parent_alias_type =>
1631+
{
1632+
continue;
1633+
}
1634+
ty::ClauseKind::Projection(p)
1635+
if (p.self_ty() == self_ty) ^ !in_parent_alias_type =>
1636+
{
1637+
continue;
16321638
}
1639+
_ => {}
16331640
}
16341641

16351642
for_each(self, bound, idx)?;

0 commit comments

Comments
 (0)