Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 130fd1a

Browse files
Don't remove export items so that we can run lints on them
1 parent fc3d8e3 commit 130fd1a

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,12 @@ impl Clean<Vec<Item>> for doctree::ExternCrate<'_> {
22322232

22332233
impl Clean<Vec<Item>> for doctree::Import<'_> {
22342234
fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
2235+
// We need this comparison because some imports (for std types for example)
2236+
// are "inserted" as well but directly by the compiler and they should not be
2237+
// taken into account.
2238+
if self.span.is_dummy() {
2239+
return Vec::new();
2240+
}
22352241
// We consider inlining the documentation of `pub use` statements, but we
22362242
// forcefully don't inline if this is not public or if the
22372243
// #[doc(no_inline)] attribute is present.
@@ -2254,11 +2260,20 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22542260
let inner = if self.glob {
22552261
if !denied {
22562262
let mut visited = FxHashSet::default();
2257-
if let Some(items) = inline::try_inline_glob(cx, path.res, &mut visited) {
2263+
if let Some(mut items) = inline::try_inline_glob(cx, path.res, &mut visited) {
2264+
items.push(Item {
2265+
name: None,
2266+
attrs: self.attrs.clean(cx),
2267+
source: self.span.clean(cx),
2268+
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
2269+
visibility: self.vis.clean(cx),
2270+
stability: None,
2271+
deprecation: None,
2272+
inner: ImportItem(Import::Glob(resolve_use_source(cx, path))),
2273+
});
22582274
return items;
22592275
}
22602276
}
2261-
22622277
Import::Glob(resolve_use_source(cx, path))
22632278
} else {
22642279
let name = self.name;
@@ -2273,14 +2288,28 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22732288
}
22742289
if !denied {
22752290
let mut visited = FxHashSet::default();
2276-
if let Some(items) = inline::try_inline(
2291+
2292+
if let Some(mut items) = inline::try_inline(
22772293
cx,
22782294
cx.tcx.parent_module(self.id).to_def_id(),
22792295
path.res,
22802296
name,
22812297
Some(self.attrs),
22822298
&mut visited,
22832299
) {
2300+
items.push(Item {
2301+
name: None,
2302+
attrs: self.attrs.clean(cx),
2303+
source: self.span.clean(cx),
2304+
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
2305+
visibility: self.vis.clean(cx),
2306+
stability: None,
2307+
deprecation: None,
2308+
inner: ImportItem(Import::Simple(
2309+
self.name.clean(cx),
2310+
resolve_use_source(cx, path),
2311+
)),
2312+
});
22842313
return items;
22852314
}
22862315
}

0 commit comments

Comments
 (0)