1
Fork 0

rustdoc: Handle duplicate reexports listed

This ends up causing duplicate output in rustdoc. The source of these duplicates
is that the item is defined in both resolve namespaces, so it's listed twice.

Closes #23207
This commit is contained in:
Alex Crichton 2015-04-07 16:18:49 -07:00
parent dbaa242418
commit 61d0365aac
4 changed files with 55 additions and 2 deletions

View file

@ -10,6 +10,8 @@
//! Support for inlining external documentation into the current AST.
use std::collections::HashSet;
use syntax::ast;
use syntax::ast_util;
use syntax::attr::AttrMetaMethods;
@ -400,16 +402,19 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt,
is_crate: false,
};
// FIXME: this doesn't handle reexports inside the module itself.
// Should they be handled?
fn fill_in(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId,
items: &mut Vec<clean::Item>) {
// If we're reexporting a reexport it may actually reexport something in
// two namespaces, so the target may be listed twice. Make sure we only
// visit each node at most once.
let mut visited = HashSet::new();
csearch::each_child_of_item(&tcx.sess.cstore, did, |def, _, vis| {
match def {
decoder::DlDef(def::DefForeignMod(did)) => {
fill_in(cx, tcx, did, items);
}
decoder::DlDef(def) if vis == ast::Public => {
if !visited.insert(def) { return }
match try_inline_def(cx, tcx, def) {
Some(i) => items.extend(i.into_iter()),
None => {}

View file

@ -0,0 +1,13 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub mod fmt {
pub struct Error;
}

View file

@ -0,0 +1,16 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate issue_23207_1;
pub mod fmt {
pub use issue_23207_1::fmt::Error;
}

View file

@ -0,0 +1,19 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:issue-23207-1.rs
// aux-build:issue-23207-2.rs
extern crate issue_23207_2;
// @has issue_23207/fmt/index.html
// @count - '//*[@class="struct"]' 1
pub use issue_23207_2::fmt;