diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-03-13 13:33:39 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-06-16 16:16:41 +0000 |
| commit | 4fdd07fe88c8965daea60c5109913095e3042c9c (patch) | |
| tree | 33b101e33af1a505bb4f2351bbae25c0c3dd03fc | |
| parent | 2304917aad2f18ee9a1c6969e1197c96dee907b6 (diff) | |
| download | rust-4fdd07fe88c8965daea60c5109913095e3042c9c.tar.gz rust-4fdd07fe88c8965daea60c5109913095e3042c9c.zip | |
Merge the orphan logic for all alias kinds
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/orphan.rs | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 23beacd2a8c..c270bebd678 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -200,35 +200,29 @@ fn do_orphan_check_impl<'tcx>( NonlocalImpl::DisallowOther, ), - // trait Id { type This: ?Sized; } - // impl<T: ?Sized> Id for T { - // type This = T; - // } - // impl<T: ?Sized> AutoTrait for <T as Id>::This {} - ty::Alias(AliasKind::Projection, _) => ( - LocalImpl::Disallow { problematic_kind: "associated type" }, - NonlocalImpl::DisallowOther, - ), - - // ``` - // struct S<T>(T); - // impl<T: ?Sized> S<T> { - // type This = T; - // } - // 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, _) => ( - LocalImpl::Disallow { problematic_kind: "associated type" }, - NonlocalImpl::DisallowOther, - ), - - // type Opaque = impl Trait; - // impl AutoTrait for Opaque {} - ty::Alias(AliasKind::Opaque, _) => ( - LocalImpl::Disallow { problematic_kind: "opaque type" }, - NonlocalImpl::DisallowOther, - ), + ty::Alias(kind, _) => { + let problematic_kind = match kind { + // trait Id { type This: ?Sized; } + // impl<T: ?Sized> Id for T { + // type This = T; + // } + // impl<T: ?Sized> AutoTrait for <T as Id>::This {} + 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> { + // type This = T; + // } + // impl<T: ?Sized> AutoTrait for S<T>::This {} + // ``` + // FIXME(inherent_associated_types): The example code above currently leads to a cycle + AliasKind::Inherent => "associated type", + }; + (LocalImpl::Disallow { problematic_kind }, NonlocalImpl::DisallowOther) + } ty::Bool | ty::Char |
