Skip to content

Commit c076799

Browse files
authored
Rollup merge of #109259 - GuillaumeGomez:fix-missing-private-inlining, r=notriddle
rustdoc: Fix missing private inlining Fixes #109258. If the item isn't inlined, it shouldn't have been added into `view_item_stack`. The problem here was that it was not removed, preventing sub items to be inlined if they have a re-export in "upper levels". cc `@epage` r? `@notriddle`
2 parents ede3c39 + e9f29c4 commit c076799

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/librustdoc/visit_ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
265265
return false;
266266
}
267267

268-
if !self.view_item_stack.insert(res_did) {
269-
return false;
270-
}
271-
272268
if !please_inline &&
273269
let mut visitor = OneLevelVisitor::new(self.cx.tcx.hir(), res_did) &&
274270
let Some(item) = visitor.find_target(self.cx.tcx, def_id.to_def_id(), path) &&
@@ -285,6 +281,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
285281
return false;
286282
}
287283

284+
if !self.view_item_stack.insert(res_did) {
285+
return false;
286+
}
287+
288288
let ret = match tcx.hir().get_by_def_id(res_did) {
289289
Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => {
290290
let prev = mem::replace(&mut self.inlining, true);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/109258>.
2+
3+
#![crate_name = "foo"]
4+
5+
// @has 'foo/index.html'
6+
// We should only have a "Re-exports" and a "Modules" headers.
7+
// @count - '//*[@id="main-content"]/h2[@class="small-section-header"]' 2
8+
// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Re-exports'
9+
// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Modules'
10+
11+
// @has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;'
12+
// @has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo'
13+
// @!has 'foo/struct.Foo.html'
14+
pub use crate::issue_109258::Foo;
15+
16+
// @has 'foo/issue_109258/index.html'
17+
// We should only have a "Structs" header.
18+
// @count - '//*[@id="main-content"]/h2[@class="small-section-header"]' 1
19+
// @has - '//*[@id="main-content"]/h2[@class="small-section-header"]' 'Structs'
20+
// @has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo'
21+
// @has 'foo/issue_109258/struct.Foo.html'
22+
pub mod issue_109258 {
23+
mod priv_mod {
24+
pub struct Foo;
25+
}
26+
pub use self::priv_mod::Foo;
27+
}

0 commit comments

Comments
 (0)