resolve: Fix doc links referring to other crates when documenting proc macro crates directly

This commit is contained in:
Vadim Petrochenkov 2023-02-12 14:55:38 +04:00
parent 00cf19a75a
commit efbf6547cf
2 changed files with 33 additions and 1 deletions

View File

@ -4206,7 +4206,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
if let Some(res) = res
&& let Some(def_id) = res.opt_def_id()
&& !def_id.is_local()
&& self.r.session.crate_types().contains(&CrateType::ProcMacro) {
&& self.r.session.crate_types().contains(&CrateType::ProcMacro)
&& matches!(self.r.session.opts.resolve_doc_links, ResolveDocLinks::ExportedMetadata) {
// Encoding foreign def ids in proc macro crate metadata will ICE.
return None;
}
@ -4276,6 +4277,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
.filter_map(|tr| {
if !tr.def_id.is_local()
&& self.r.session.crate_types().contains(&CrateType::ProcMacro)
&& matches!(
self.r.session.opts.resolve_doc_links,
ResolveDocLinks::ExportedMetadata
)
{
// Encoding foreign def ids in proc macro crate metadata will ICE.
return None;

View File

@ -0,0 +1,27 @@
// check-pass
// force-host
// no-prefer-dynamic
// compile-flags: --crate-type proc-macro
#![deny(rustdoc::broken_intra_doc_links)]
extern crate proc_macro;
use proc_macro::*;
/// [`Unpin`]
#[proc_macro_derive(F)]
pub fn derive_(t: proc_macro::TokenStream) -> proc_macro::TokenStream {
t
}
/// [`Vec`]
#[proc_macro_attribute]
pub fn attr(t: proc_macro::TokenStream, _: proc_macro::TokenStream) -> proc_macro::TokenStream {
t
}
/// [`std::fs::File`]
#[proc_macro]
pub fn func(t: proc_macro::TokenStream) -> proc_macro::TokenStream {
t
}