Skip to content

Commit d299baf

Browse files
committed
auto merge of #17492 : alexcrichton/rust/issue-16274, r=aturon
Details in the commits.
2 parents 9ff3081 + 3d8ca59 commit d299baf

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

src/librustdoc/visit_ast.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//! Rust AST Visitor. Extracts useful information and massages it into a form
1212
//! usable for clean
1313
14+
use std::collections::HashSet;
15+
1416
use syntax::abi;
1517
use syntax::ast;
1618
use syntax::ast_util;
@@ -38,16 +40,21 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> {
3840
pub attrs: Vec<ast::Attribute>,
3941
pub cx: &'a core::DocContext<'tcx>,
4042
pub analysis: Option<&'a core::CrateAnalysis>,
43+
view_item_stack: HashSet<ast::NodeId>,
4144
}
4245

4346
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
4447
pub fn new(cx: &'a core::DocContext<'tcx>,
4548
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);
4652
RustdocVisitor {
4753
module: Module::new(None),
4854
attrs: Vec::new(),
4955
cx: cx,
5056
analysis: analysis,
57+
view_item_stack: stack,
5158
}
5259
}
5360

@@ -228,8 +235,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
228235
if !please_inline && analysis.public_items.contains(&def.node) {
229236
return false
230237
}
238+
if !self.view_item_stack.insert(def.node) { return false }
231239

232-
match tcx.map.get(def.node) {
240+
let ret = match tcx.map.get(def.node) {
233241
ast_map::NodeItem(it) => {
234242
if glob {
235243
match it.node {
@@ -249,7 +257,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
249257
true
250258
}
251259
_ => false,
252-
}
260+
};
261+
self.view_item_stack.remove(&id);
262+
return ret;
253263
}
254264

255265
pub fn visit_item(&mut self, item: &ast::Item,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-include ../tools.mk
2+
3+
# FIXME ignore windows
4+
ifndef IS_WINDOWS
5+
all:
6+
$(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
9+
else
10+
all:
11+
endif
12+
+25
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+
#![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+
}
25+
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)