rustdoc: Fix missing enum variant reexports

This commit is contained in:
Oliver Middleton 2017-06-12 19:00:09 +01:00
parent 19193d6390
commit 68ccba81ae
3 changed files with 37 additions and 18 deletions

View File

@ -77,10 +77,10 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name)
ret.extend(build_impls(cx, did));
clean::EnumItem(build_enum(cx, did))
}
// Assume that the enum type is reexported next to the variant, and
// variants don't show up in documentation specially.
// Similarly, consider that struct type is reexported next to its constructor.
Def::Variant(..) |
// Never inline enum variants but leave them shown as reexports.
Def::Variant(..) => return None,
// Assume that enum variants and struct types are reexported next to
// their constructors.
Def::VariantCtor(..) |
Def::StructCtor(..) => return Some(Vec::new()),
Def::Mod(did) => {

View File

@ -329,25 +329,21 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
if !self.view_item_stack.insert(def_node_id) { return false }
let ret = match tcx.hir.get(def_node_id) {
hir_map::NodeItem(it) => {
hir_map::NodeItem(&hir::Item { node: hir::ItemMod(ref m), .. }) if glob => {
let prev = mem::replace(&mut self.inlining, true);
if glob {
match it.node {
hir::ItemMod(ref m) => {
for i in &m.item_ids {
let i = self.cx.tcx.hir.expect_item(i.id);
self.visit_item(i, None, om);
}
}
hir::ItemEnum(..) => {}
_ => { panic!("glob not mapped to a module or enum"); }
}
} else {
self.visit_item(it, renamed, om);
for i in &m.item_ids {
let i = self.cx.tcx.hir.expect_item(i.id);
self.visit_item(i, None, om);
}
self.inlining = prev;
true
}
hir_map::NodeItem(it) if !glob => {
let prev = mem::replace(&mut self.inlining, true);
self.visit_item(it, renamed, om);
self.inlining = prev;
true
}
_ => false,
};
self.view_item_stack.remove(&def_node_id);

View File

@ -0,0 +1,23 @@
// Copyright 2017 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.
mod foo {
pub enum Foo {
Bar,
}
pub use self::Foo::*;
}
// @has 'issue_35488/index.html' '//code' 'pub use self::Foo::*;'
// @has 'issue_35488/enum.Foo.html'
pub use self::foo::*;
// @has 'issue_35488/index.html' '//code' 'pub use std::option::Option::None;'
pub use std::option::Option::None;