Merge the orphan logic for all alias kinds

This commit is contained in:
Oli Scherer 2023-03-13 13:33:39 +00:00
parent 2304917aad
commit 4fdd07fe88

View file

@ -200,35 +200,29 @@ fn do_orphan_check_impl<'tcx>(
NonlocalImpl::DisallowOther, NonlocalImpl::DisallowOther,
), ),
// trait Id { type This: ?Sized; } ty::Alias(kind, _) => {
// impl<T: ?Sized> Id for T { let problematic_kind = match kind {
// type This = T; // trait Id { type This: ?Sized; }
// } // impl<T: ?Sized> Id for T {
// impl<T: ?Sized> AutoTrait for <T as Id>::This {} // type This = T;
ty::Alias(AliasKind::Projection, _) => ( // }
LocalImpl::Disallow { problematic_kind: "associated type" }, // impl<T: ?Sized> AutoTrait for <T as Id>::This {}
NonlocalImpl::DisallowOther, AliasKind::Projection => "associated type",
), // type Opaque = impl Trait;
// impl AutoTrait for Opaque {}
// ``` AliasKind::Opaque => "opaque type",
// struct S<T>(T); // ```
// impl<T: ?Sized> S<T> { // struct S<T>(T);
// type This = T; // impl<T: ?Sized> S<T> {
// } // type This = T;
// impl<T: ?Sized> AutoTrait for S<T>::This {} // }
// ``` // impl<T: ?Sized> AutoTrait for S<T>::This {}
// FIXME(inherent_associated_types): The example code above currently leads to a cycle // ```
ty::Alias(AliasKind::Inherent, _) => ( // FIXME(inherent_associated_types): The example code above currently leads to a cycle
LocalImpl::Disallow { problematic_kind: "associated type" }, AliasKind::Inherent => "associated type",
NonlocalImpl::DisallowOther, };
), (LocalImpl::Disallow { problematic_kind }, NonlocalImpl::DisallowOther)
}
// type Opaque = impl Trait;
// impl AutoTrait for Opaque {}
ty::Alias(AliasKind::Opaque, _) => (
LocalImpl::Disallow { problematic_kind: "opaque type" },
NonlocalImpl::DisallowOther,
),
ty::Bool ty::Bool
| ty::Char | ty::Char