From 59b8ff97b2e15e4058a9d931e525572728c6ef0e Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 27 Oct 2022 21:41:54 +0400 Subject: [PATCH] rustdoc: Do not add external traits to the crate in `register_res` It's not clear why it was done, and apparently it's no longer necessary now. Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits. --- src/librustdoc/clean/utils.rs | 4 ---- src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs | 4 ++++ src/test/rustdoc/intra-doc/issue-103463.rs | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs create mode 100644 src/test/rustdoc/intra-doc/issue-103463.rs diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 8f3e29a31a072..518e320235ff1 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -7,7 +7,6 @@ use crate::clean::{ PathSegment, Primitive, PrimitiveType, Type, TypeBinding, Visibility, }; use crate::core::DocContext; -use crate::formats::item_type::ItemType; use rustc_ast as ast; use rustc_ast::tokenstream::TokenTree; @@ -503,9 +502,6 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { return did; } inline::record_extern_fqn(cx, did, kind); - if let ItemType::Trait = kind { - inline::record_extern_trait(cx, did); - } did } diff --git a/src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs b/src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs new file mode 100644 index 0000000000000..2b8fdec1f128f --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/issue-103463-aux.rs @@ -0,0 +1,4 @@ +pub trait Trait { + /// [`u8::clone`] + fn method(); +} diff --git a/src/test/rustdoc/intra-doc/issue-103463.rs b/src/test/rustdoc/intra-doc/issue-103463.rs new file mode 100644 index 0000000000000..4adf8a9a8a4a3 --- /dev/null +++ b/src/test/rustdoc/intra-doc/issue-103463.rs @@ -0,0 +1,8 @@ +// The `Trait` is not pulled into the crate resulting in doc links in its methods being resolved. + +// aux-build:issue-103463-aux.rs + +extern crate issue_103463_aux; +use issue_103463_aux::Trait; + +fn main() {}