diff options
| author | bors <bors@rust-lang.org> | 2023-03-24 21:10:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-24 21:10:51 +0000 |
| commit | 8be3c2bda6b683f87b24714ba595e8b04faef54c (patch) | |
| tree | e62745b744cf51c45e47a6c8322e86de9d82d425 /compiler/rustc_resolve/src | |
| parent | 80a933042e4e07ee9d9c20897d4fab595766fef6 (diff) | |
| parent | bec4eab3f972495df32b4861a3117ef16d73a018 (diff) | |
| download | rust-8be3c2bda6b683f87b24714ba595e8b04faef54c.tar.gz rust-8be3c2bda6b683f87b24714ba595e8b04faef54c.zip | |
Auto merge of #107932 - petrochenkov:onlyexport, r=jyn514
rustdoc: Skip doc link resolution for non-exported items
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/late.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/rustdoc.rs | 16 |
2 files changed, 19 insertions, 2 deletions
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 6af9dc89e56..4ca54bab31a 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -4236,7 +4236,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { { return; } - ResolveDocLinks::Exported if !maybe_exported.eval(self.r) => { + ResolveDocLinks::Exported + if !maybe_exported.eval(self.r) + && !rustdoc::has_primitive_or_keyword_docs(attrs) => + { return; } ResolveDocLinks::ExportedMetadata diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index 0e40f794f18..44a27bbc175 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -3,7 +3,7 @@ use rustc_ast as ast; use rustc_ast::util::comments::beautify_doc_string; use rustc_data_structures::fx::FxHashMap; use rustc_span::def_id::DefId; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; use std::{cmp, mem}; @@ -339,6 +339,20 @@ pub fn inner_docs(attrs: &[ast::Attribute]) -> bool { attrs.iter().find(|a| a.doc_str().is_some()).map_or(true, |a| a.style == ast::AttrStyle::Inner) } +/// Has `#[doc(primitive)]` or `#[doc(keyword)]`. +pub fn has_primitive_or_keyword_docs(attrs: &[ast::Attribute]) -> bool { + for attr in attrs { + if attr.has_name(sym::doc) && let Some(items) = attr.meta_item_list() { + for item in items { + if item.has_name(sym::primitive) || item.has_name(sym::keyword) { + return true; + } + } + } + } + false +} + /// Simplified version of the corresponding function in rustdoc. /// If the rustdoc version returns a successful result, this function must return the same result. /// Otherwise this function may return anything. |
