Account for more cases

This commit is contained in:
Deadbeef 2021-06-22 11:16:59 +08:00
parent bd7caf477c
commit 0aaefff009
No known key found for this signature in database
GPG key ID: 6525773485376D92
3 changed files with 23 additions and 8 deletions

View file

@ -1,6 +1,5 @@
//! Support for inlining external documentation into the current AST.
use std::collections::VecDeque;
use std::iter::once;
use std::sync::Arc;
@ -425,15 +424,16 @@ crate fn build_impl(
}
// 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() {
let mut stack: Vec<&Type> = trait_.iter().collect();
stack.push(&for_);
while let Some(ty) = stack.pop() {
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);
stack.extend(generics);
}
}

View file

@ -1,2 +1,5 @@
#[doc(hidden)]
pub enum HiddenType {}
#[doc(hidden)]
pub trait HiddenTrait {}

View file

@ -4,7 +4,7 @@
// aux-build:cross-crate-hidden.rs
extern crate cross_crate_hidden;
pub use ::cross_crate_hidden::HiddenType; // OK, not re-exported
pub use ::cross_crate_hidden::{HiddenType, HiddenTrait}; // OK, not re-exported
pub enum MyLibType {}
@ -15,9 +15,21 @@ impl From<HiddenType> for MyLibType {
}
}
// @!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 {
pub struct T<T>(T);
// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From<T<T<T<T<HiddenType>>>>> for MyLibType'
impl From<T<T<T<T<HiddenType>>>>> for MyLibType {
fn from(it: T<T<T<T<HiddenType>>>>) -> MyLibType {
todo!()
}
}
// @!has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType'
impl HiddenTrait for MyLibType {}
// @!has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From<MyLibType> for T<T<T<T<HiddenType>>>>'
impl From<MyLibType> for T<T<T<T<HiddenType>>>> {
fn from(it: MyLibType) -> T<T<T<T<HiddenType>>>> {
match it {}
}
}