Skip to content

Commit

Permalink
rustdoc: Fix missing enum variant reexports
Browse files Browse the repository at this point in the history
  • Loading branch information
ollie27 committed Jun 12, 2017
1 parent 19193d6 commit 68ccba8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
24 changes: 10 additions & 14 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions src/test/rustdoc/issue-35488.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 68ccba8

Please sign in to comment.