Do not list impl when trait has doc(hidden)
This commit is contained in:
parent
3824017f8e
commit
bd7caf477c
@ -1,5 +1,6 @@
|
||||
//! Support for inlining external documentation into the current AST.
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::iter::once;
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -15,7 +16,9 @@ use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::clean::{self, Attributes, AttributesExt, FakeDefId, GetDefId, ToSource};
|
||||
use crate::clean::{
|
||||
self, Attributes, AttributesExt, FakeDefId, GetDefId, NestedAttributesExt, ToSource, Type,
|
||||
};
|
||||
use crate::core::DocContext;
|
||||
use crate::formats::item_type::ItemType;
|
||||
|
||||
@ -420,6 +423,20 @@ crate fn build_impl(
|
||||
if trait_.def_id() == tcx.lang_items().deref_trait() {
|
||||
super::build_deref_target_impls(cx, &trait_items, ret);
|
||||
}
|
||||
|
||||
// Return if the trait itself or any types of the generic parameters are doc(hidden).
|
||||
let mut deque: VecDeque<&Type> = trait_.iter().collect();
|
||||
while let Some(ty) = deque.pop_back() {
|
||||
if let Some(did) = ty.def_id() {
|
||||
if cx.tcx.get_attrs(did).lists(sym::doc).has_word(sym::hidden) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Some(generics) = ty.generics() {
|
||||
deque.extend(generics);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(trait_did) = trait_.def_id() {
|
||||
record_extern_trait(cx, trait_did);
|
||||
}
|
||||
|
2
src/test/rustdoc/auxiliary/cross-crate-hidden.rs
Normal file
2
src/test/rustdoc/auxiliary/cross-crate-hidden.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#[doc(hidden)]
|
||||
pub enum HiddenType {}
|
23
src/test/rustdoc/cross-crate-hidden.rs
Normal file
23
src/test/rustdoc/cross-crate-hidden.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Issue #86448: test for cross-crate `doc(hidden)`
|
||||
#![crate_name = "foo"]
|
||||
|
||||
// aux-build:cross-crate-hidden.rs
|
||||
extern crate cross_crate_hidden;
|
||||
|
||||
pub use ::cross_crate_hidden::HiddenType; // OK, not re-exported
|
||||
|
||||
pub enum MyLibType {}
|
||||
|
||||
// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From<HiddenType> for MyLibType'
|
||||
impl From<HiddenType> for MyLibType {
|
||||
fn from(it: HiddenType) -> MyLibType {
|
||||
match it {}
|
||||
}
|
||||
}
|
||||
|
||||
// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3COption%3COption%3COption%3COption%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From<Option<Option<Option<Option<HiddenType>>>>> for MyLibType'
|
||||
impl From<Option<Option<Option<Option<HiddenType>>>>> for MyLibType {
|
||||
fn from(it: Option<Option<Option<Option<HiddenType>>>>) -> MyLibType {
|
||||
todo!()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user