diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-10-01 11:53:47 +0000 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-10-01 12:38:16 +0000 |
| commit | b810a68197515bfbe5afd8557b566d6817035389 (patch) | |
| tree | 9b4aab8bc0e541b68b377146c96b908920b8700c /compiler | |
| parent | 42d009c0a9be0f7020a03f85dd47faa00d6d7bdf (diff) | |
| download | rust-b810a68197515bfbe5afd8557b566d6817035389.tar.gz rust-b810a68197515bfbe5afd8557b566d6817035389.zip | |
added error for closures case in impl
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/orphan.rs | 10 |
2 files changed, 10 insertions, 9 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs index 38ae7852ca9..b069a74bf5a 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs @@ -195,11 +195,10 @@ impl<'tcx> InherentCollect<'tcx> { | ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) - | ty::CoroutineWitness(..) - | ty::Alias(ty::Free, _) - | ty::Bound(..) - | ty::Placeholder(_) - | ty::Infer(_) => { + | ty::CoroutineWitness(..) => { + Err(self.tcx.dcx().delayed_bug("cannot define inherent `impl` for closure types")) + } + ty::Alias(ty::Free, _) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => { bug!("unexpected impl self type of impl: {:?} {:?}", id, self_ty); } // We could bail out here, but that will silence other useful errors. diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 621431ae234..5a61248cab8 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -230,10 +230,12 @@ pub(crate) fn orphan_check_impl( ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) - | ty::CoroutineWitness(..) - | ty::Bound(..) - | ty::Placeholder(..) - | ty::Infer(..) => { + | ty::CoroutineWitness(..) => { + return Err(tcx + .dcx() + .delayed_bug("cannot define inherent `impl` for closure types")); + } + ty::Bound(..) | ty::Placeholder(..) | ty::Infer(..) => { let sp = tcx.def_span(impl_def_id); span_bug!(sp, "weird self type for autotrait impl") } |
