Skip to content

Commit e3c3efe

Browse files
Filter out imports added by the compiler
1 parent 0e022fc commit e3c3efe

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/librustdoc/clean/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use rustc_middle::ty::fold::TypeFolder;
2424
use rustc_middle::ty::subst::{InternalSubsts, Subst};
2525
use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt};
2626
use rustc_mir::const_eval::{is_const_fn, is_min_const_fn, is_unstable_const_fn};
27-
use rustc_span::hygiene::MacroKind;
27+
use rustc_span::hygiene::{AstPass, MacroKind};
2828
use rustc_span::symbol::{kw, sym, Ident, Symbol};
29-
use rustc_span::{self, Pos};
29+
use rustc_span::{self, ExpnKind, Pos};
3030
use rustc_typeck::hir_ty_to_ty;
3131

3232
use std::collections::hash_map::Entry;
@@ -2232,6 +2232,13 @@ 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.ctxt().outer_expn_data().kind == ExpnKind::AstPass(AstPass::StdImports) {
2239+
return Vec::new();
2240+
}
2241+
22352242
// We consider inlining the documentation of `pub use` statements, but we
22362243
// forcefully don't inline if this is not public or if the
22372244
// #[doc(no_inline)] attribute is present.

0 commit comments

Comments
 (0)