Skip to content

Commit

Permalink
Rollup merge of rust-lang#77785 - GuillaumeGomez:remove-compiler-reex…
Browse files Browse the repository at this point in the history
…ports, r=ollie27

Remove compiler-synthesized reexports when documenting

Fixes rust-lang#77567

r? @ollie27
  • Loading branch information
Dylan-DPC committed Oct 17, 2020
2 parents 4bf869c + 0faaa49 commit 68e4cc6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::subst::{InternalSubsts, Subst};
use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt};
use rustc_mir::const_eval::{is_const_fn, is_min_const_fn, is_unstable_const_fn};
use rustc_span::hygiene::MacroKind;
use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{self, Pos};
use rustc_span::{self, ExpnKind, Pos};
use rustc_typeck::hir_ty_to_ty;

use std::collections::hash_map::Entry;
Expand Down Expand Up @@ -2231,6 +2231,13 @@ 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.ctxt().outer_expn_data().kind == ExpnKind::AstPass(AstPass::StdImports) {
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.
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc/no-compiler-reexport.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// compile-flags: --no-defaults

#![crate_name = "foo"]

// @has 'foo/index.html' '//code' 'extern crate std;'
// @!has 'foo/index.html' '//code' 'use std::prelude::v1::*;'
pub struct Foo;

0 comments on commit 68e4cc6

Please sign in to comment.