Skip to content

Commit 3d8ca59

Browse files
committed
rustdoc: Don't try to inline the crate root
Fixes other test cases found in #16274
1 parent d2b30f7 commit 3d8ca59

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

src/librustdoc/visit_ast.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> {
4646
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
4747
pub fn new(cx: &'a core::DocContext<'tcx>,
4848
analysis: Option<&'a core::CrateAnalysis>) -> RustdocVisitor<'a, 'tcx> {
49+
// If the root is reexported, terminate all recursion.
50+
let mut stack = HashSet::new();
51+
stack.insert(ast::CRATE_NODE_ID);
4952
RustdocVisitor {
5053
module: Module::new(None),
5154
attrs: Vec::new(),
5255
cx: cx,
5356
analysis: analysis,
54-
view_item_stack: HashSet::new(),
57+
view_item_stack: stack,
5558
}
5659
}
5760

@@ -232,7 +235,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
232235
if !please_inline && analysis.public_items.contains(&def.node) {
233236
return false
234237
}
235-
if !self.view_item_stack.insert(id) { return false }
238+
if !self.view_item_stack.insert(def.node) { return false }
236239

237240
let ret = match tcx.map.get(def.node) {
238241
ast_map::NodeItem(it) => {

src/test/run-make/rustdoc-recursion/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
ifndef IS_WINDOWS
55
all:
66
$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
7+
$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo2.rs
8+
$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo3.rs
79
else
810
all:
911
endif

src/test/run-make/rustdoc-recursion/foo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "lib"]
12+
#![feature(globs)]
13+
14+
mod m {
15+
pub use self::a::Foo;
16+
17+
mod a {
18+
pub struct Foo;
19+
}
20+
21+
mod b {
22+
pub use super::*;
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(globs)]
12+
13+
pub mod longhands {
14+
pub use super::*;
15+
16+
pub use super::common_types::computed::compute_CSSColor as to_computed_value;
17+
18+
pub fn computed_as_specified() {}
19+
}
20+
21+
pub mod common_types {
22+
pub mod computed {
23+
pub use super::super::longhands::computed_as_specified as compute_CSSColor;
24+
}
25+
}

0 commit comments

Comments
 (0)