about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDebugSteven <debugsteven@gmail.com>2019-01-10 20:27:44 -0500
committerDebugSteven <debugsteven@gmail.com>2019-01-10 20:27:44 -0500
commit3f032979562e9b245ac452ec91ec3204176c27fe (patch)
treeefbecb8a37909add9ac3e7000116f726bc47fc72 /src
parent6ecad338381cc3b8d56e2df22e5971a598eddd6c (diff)
downloadrust-3f032979562e9b245ac452ec91ec3204176c27fe.tar.gz
rust-3f032979562e9b245ac452ec91ec3204176c27fe.zip
inline pub extern crate statements
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 37c6407fbd1..6eea95b61c9 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -587,7 +587,7 @@ impl Clean<Item> for doctree::Module {
         let attrs = self.attrs.clean(cx);
 
         let mut items: Vec<Item> = vec![];
-        items.extend(self.extern_crates.iter().map(|x| x.clean(cx)));
+        items.extend(self.extern_crates.iter().flat_map(|x| x.clean(cx)));
         items.extend(self.imports.iter().flat_map(|x| x.clean(cx)));
         items.extend(self.structs.iter().map(|x| x.clean(cx)));
         items.extend(self.unions.iter().map(|x| x.clean(cx)));
@@ -3503,9 +3503,30 @@ fn build_deref_target_impls(cx: &DocContext,
     }
 }
 
-impl Clean<Item> for doctree::ExternCrate {
-    fn clean(&self, cx: &DocContext) -> Item {
-        Item {
+impl Clean<Vec<Item>> for doctree::ExternCrate {
+    fn clean(&self, cx: &DocContext) -> Vec<Item> {
+
+        let please_inline = self.vis.node.is_pub() && self.attrs.iter().any(|a| {
+            a.name() == "doc" && match a.meta_item_list() {
+                Some(l) => attr::list_contains_name(&l, "inline"),
+                None => false,
+            }
+        });
+
+        if please_inline {
+            let mut visited = FxHashSet::default();
+
+            let def = Def::Mod(DefId {
+                krate: self.cnum,
+                index: CRATE_DEF_INDEX,
+            });
+
+            if let Some(items) = inline::try_inline(cx, def, self.name, &mut visited) {
+                return items;
+            }
+        }
+
+        vec![Item {
             name: None,
             attrs: self.attrs.clean(cx),
             source: self.whence.clean(cx),
@@ -3514,7 +3535,7 @@ impl Clean<Item> for doctree::ExternCrate {
             stability: None,
             deprecation: None,
             inner: ExternCrateItem(self.name.clean(cx), self.path.clone())
-        }
+        }]
     }
 }