From 47c97b1d5143e8504c2f4e10394efdda7d5cb1e6 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 2 Feb 2024 21:23:13 +0000 Subject: [PATCH] Add rustdoc hack --- compiler/rustc_hir_analysis/src/coherence/builtin.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 5a3878445937b..1cf9cc76e39f9 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -104,7 +104,12 @@ fn visit_implementation_of_copy( Err(infringing_fields_error(tcx, fields, LangItem::Copy, impl_did, span)) } Err(CopyImplementationError::NotAnAdt) => { - Err(tcx.dcx().emit_err(errors::CopyImplOnNonAdt { span })) + if tcx.sess.opts.actually_rustdoc { + // HACK(rustdoc): `impl Copy for fn(T) -> Ret` just for docs. + Ok(()) + } else { + Err(tcx.dcx().emit_err(errors::CopyImplOnNonAdt { span })) + } } Err(CopyImplementationError::HasDestructor) => { Err(tcx.dcx().emit_err(errors::CopyImplOnTypeWithDtor { span }))