about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-09-27 21:22:11 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-10-09 20:24:59 +0200
commit130fd1a970a89e826f343da160b19bc853ce43cb (patch)
tree4861292a17b15270b725a2aac44c3bd696d1a7f8
parentfc3d8e3fccb86d6798ce89ca9eb28679908dc526 (diff)
downloadrust-130fd1a970a89e826f343da160b19bc853ce43cb.tar.gz
rust-130fd1a970a89e826f343da160b19bc853ce43cb.zip
Don't remove export items so that we can run lints on them
-rw-r--r--src/librustdoc/clean/mod.rs35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index ca9135cd11a..ca9d76f4cf4 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2232,6 +2232,12 @@ impl Clean<Vec<Item>> for doctree::ExternCrate<'_> {
 
 impl Clean<Vec<Item>> for doctree::Import<'_> {
     fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
+        // We need this comparison because some imports (for std types for example)
+        // are "inserted" as well but directly by the compiler and they should not be
+        // taken into account.
+        if self.span.is_dummy() {
+            return Vec::new();
+        }
         // We consider inlining the documentation of `pub use` statements, but we
         // forcefully don't inline if this is not public or if the
         // #[doc(no_inline)] attribute is present.
@@ -2254,11 +2260,20 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
         let inner = if self.glob {
             if !denied {
                 let mut visited = FxHashSet::default();
-                if let Some(items) = inline::try_inline_glob(cx, path.res, &mut visited) {
+                if let Some(mut items) = inline::try_inline_glob(cx, path.res, &mut visited) {
+                    items.push(Item {
+                        name: None,
+                        attrs: self.attrs.clean(cx),
+                        source: self.span.clean(cx),
+                        def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
+                        visibility: self.vis.clean(cx),
+                        stability: None,
+                        deprecation: None,
+                        inner: ImportItem(Import::Glob(resolve_use_source(cx, path))),
+                    });
                     return items;
                 }
             }
-
             Import::Glob(resolve_use_source(cx, path))
         } else {
             let name = self.name;
@@ -2273,7 +2288,8 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
             }
             if !denied {
                 let mut visited = FxHashSet::default();
-                if let Some(items) = inline::try_inline(
+
+                if let Some(mut items) = inline::try_inline(
                     cx,
                     cx.tcx.parent_module(self.id).to_def_id(),
                     path.res,
@@ -2281,6 +2297,19 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
                     Some(self.attrs),
                     &mut visited,
                 ) {
+                    items.push(Item {
+                        name: None,
+                        attrs: self.attrs.clean(cx),
+                        source: self.span.clean(cx),
+                        def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
+                        visibility: self.vis.clean(cx),
+                        stability: None,
+                        deprecation: None,
+                        inner: ImportItem(Import::Simple(
+                            self.name.clean(cx),
+                            resolve_use_source(cx, path),
+                        )),
+                    });
                     return items;
                 }
             }