Skip to content

Commit 446686f

Browse files
authored
Rollup merge of #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27
Remove compiler-synthesized reexports when documenting Fixes #77567 r? @ollie27
2 parents f40ecff + 0faaa49 commit 446686f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/librustdoc/clean/mod.rs

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

3131
use std::collections::hash_map::Entry;
@@ -2231,6 +2231,13 @@ impl Clean<Vec<Item>> for doctree::ExternCrate<'_> {
22312231

22322232
impl Clean<Vec<Item>> for doctree::Import<'_> {
22332233
fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
2234+
// We need this comparison because some imports (for std types for example)
2235+
// are "inserted" as well but directly by the compiler and they should not be
2236+
// taken into account.
2237+
if self.span.ctxt().outer_expn_data().kind == ExpnKind::AstPass(AstPass::StdImports) {
2238+
return Vec::new();
2239+
}
2240+
22342241
// We consider inlining the documentation of `pub use` statements, but we
22352242
// forcefully don't inline if this is not public or if the
22362243
// #[doc(no_inline)] attribute is present.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// compile-flags: --no-defaults
2+
3+
#![crate_name = "foo"]
4+
5+
// @has 'foo/index.html' '//code' 'extern crate std;'
6+
// @!has 'foo/index.html' '//code' 'use std::prelude::v1::*;'
7+
pub struct Foo;

0 commit comments

Comments
 (0)