Correctly handle multiple re-exports of bang macros at the same level
This commit is contained in:
parent
c908d1e4de
commit
898dfc680f
3 changed files with 52 additions and 4 deletions
|
@ -305,7 +305,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.view_item_stack.insert(res_did) {
|
let is_bang_macro = matches!(
|
||||||
|
tcx.hir().get_by_def_id(res_did),
|
||||||
|
Node::Item(&hir::Item { kind: hir::ItemKind::Macro(_, MacroKind::Bang), .. })
|
||||||
|
);
|
||||||
|
|
||||||
|
if !self.view_item_stack.insert(res_did) && !is_bang_macro {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,8 +318,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
// Bang macros are handled a bit on their because of how they are handled by the
|
// Bang macros are handled a bit on their because of how they are handled by the
|
||||||
// compiler. If they have `#[doc(hidden)]` and the re-export doesn't have
|
// compiler. If they have `#[doc(hidden)]` and the re-export doesn't have
|
||||||
// `#[doc(inline)]`, then we don't inline it.
|
// `#[doc(inline)]`, then we don't inline it.
|
||||||
Node::Item(&hir::Item { kind: hir::ItemKind::Macro(_, MacroKind::Bang), .. })
|
Node::Item(_)
|
||||||
if !please_inline
|
if is_bang_macro
|
||||||
|
&& !please_inline
|
||||||
&& renamed.is_some()
|
&& renamed.is_some()
|
||||||
&& self.cx.tcx.is_doc_hidden(ori_res_did) =>
|
&& self.cx.tcx.is_doc_hidden(ori_res_did) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
// @has 'foo/index.html'
|
// @has 'foo/index.html'
|
||||||
// @has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2'
|
// @has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2'
|
||||||
|
// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
|
||||||
|
|
||||||
// @has 'foo/macro.Macro2.html'
|
// @has 'foo/macro.Macro2.html'
|
||||||
// @has - '//*[@class="docblock"]' 'Displayed'
|
// @has - '//*[@class="docblock"]' 'Displayed'
|
||||||
|
@ -15,7 +16,6 @@ macro_rules! foo {
|
||||||
() => {};
|
() => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
|
|
||||||
pub use crate::foo as Macro;
|
pub use crate::foo as Macro;
|
||||||
/// Displayed
|
/// Displayed
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
|
42
tests/rustdoc/reexport-of-doc-hidden.rs
Normal file
42
tests/rustdoc/reexport-of-doc-hidden.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// This test ensures that all re-exports of doc hidden elements are displayed.
|
||||||
|
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub struct Bar;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
#[doc(hidden)]
|
||||||
|
macro_rules! foo {
|
||||||
|
() => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has 'foo/index.html'
|
||||||
|
// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
|
||||||
|
pub use crate::foo as Macro;
|
||||||
|
// @has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;'
|
||||||
|
pub use crate::foo as Macro2;
|
||||||
|
// @has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;'
|
||||||
|
pub use crate::Bar as Boo;
|
||||||
|
// @has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;'
|
||||||
|
pub use crate::Bar as Boo2;
|
||||||
|
|
||||||
|
pub fn fofo() {}
|
||||||
|
|
||||||
|
// @has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;'
|
||||||
|
pub use crate::fofo as f1;
|
||||||
|
// @has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;'
|
||||||
|
pub use crate::fofo as f2;
|
||||||
|
|
||||||
|
pub mod sub {
|
||||||
|
// @has 'foo/sub/index.html'
|
||||||
|
// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
|
||||||
|
pub use crate::foo as Macro;
|
||||||
|
// @has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;'
|
||||||
|
pub use crate::foo as Macro2;
|
||||||
|
|
||||||
|
// @has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;'
|
||||||
|
pub use crate::fofo as f1;
|
||||||
|
// @has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;'
|
||||||
|
pub use crate::fofo as f2;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue