about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Middleton <olliemail27@gmail.com>2017-06-12 19:00:09 +0100
committerOliver Middleton <olliemail27@gmail.com>2017-06-12 22:42:20 +0100
commit68ccba81aea7f4ae86c97d88a6d7a3ea3f758f7e (patch)
tree1d0cb95fe02d4e5426ffb08443762cf28bacd787
parent19193d6390644b5d621934bac6a33caacfb9ad31 (diff)
downloadrust-68ccba81aea7f4ae86c97d88a6d7a3ea3f758f7e.tar.gz
rust-68ccba81aea7f4ae86c97d88a6d7a3ea3f758f7e.zip
rustdoc: Fix missing enum variant reexports
-rw-r--r--src/librustdoc/clean/inline.rs8
-rw-r--r--src/librustdoc/visit_ast.rs24
-rw-r--r--src/test/rustdoc/issue-35488.rs23
3 files changed, 37 insertions, 18 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 8f7add14d0a..e617402d8db 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -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) => {
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index 39ebe490d0e..657aab958bb 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -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);
diff --git a/src/test/rustdoc/issue-35488.rs b/src/test/rustdoc/issue-35488.rs
new file mode 100644
index 00000000000..f24166a65f0
--- /dev/null
+++ b/src/test/rustdoc/issue-35488.rs
@@ -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;