1
Fork 0

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. //! Support for inlining external documentation into the current AST.
use std::collections::VecDeque;
use std::iter::once; use std::iter::once;
use std::sync::Arc; 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). // Return if the trait itself or any types of the generic parameters are doc(hidden).
let mut deque: VecDeque<&Type> = trait_.iter().collect(); let mut stack: Vec<&Type> = trait_.iter().collect();
while let Some(ty) = deque.pop_back() { stack.push(&for_);
while let Some(ty) = stack.pop() {
if let Some(did) = ty.def_id() { if let Some(did) = ty.def_id() {
if cx.tcx.get_attrs(did).lists(sym::doc).has_word(sym::hidden) { if cx.tcx.get_attrs(did).lists(sym::doc).has_word(sym::hidden) {
return; return;
} }
} }
if let Some(generics) = ty.generics() { if let Some(generics) = ty.generics() {
deque.extend(generics); stack.extend(generics);
} }
} }

View file

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

View file

@ -4,7 +4,7 @@
// aux-build:cross-crate-hidden.rs // aux-build:cross-crate-hidden.rs
extern crate cross_crate_hidden; 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 {} 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' pub struct T<T>(T);
impl From<Option<Option<Option<Option<HiddenType>>>>> for MyLibType {
fn from(it: Option<Option<Option<Option<HiddenType>>>>) -> MyLibType { // @!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!() 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 {}
}
}