mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
resolve: Fix doc links referring to other crates when documenting proc macro crates directly
This commit is contained in:
parent
00cf19a75a
commit
efbf6547cf
@ -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;
|
||||
|
27
tests/rustdoc-ui/intra-doc/proc-macro-doc.rs
Normal file
27
tests/rustdoc-ui/intra-doc/proc-macro-doc.rs
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user