diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-10-17 03:27:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-17 03:27:17 +0200 |
| commit | 446686f59b9f9d63ede5e8a07a7298c43209e651 (patch) | |
| tree | c1524cd3f47655e853d5374f7923b17ae1fca4db /src | |
| parent | f40ecff9644e723752732d9d1f6723260ee7bb23 (diff) | |
| parent | 0faaa499ccc9fb4835251845cf457bae385f07f5 (diff) | |
Rollup merge of #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27
Remove compiler-synthesized reexports when documenting Fixes #77567 r? @ollie27
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 11 | ||||
| -rw-r--r-- | src/test/rustdoc/no-compiler-reexport.rs | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 776b131a076..0365a8b48db 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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; @@ -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. diff --git a/src/test/rustdoc/no-compiler-reexport.rs b/src/test/rustdoc/no-compiler-reexport.rs new file mode 100644 index 00000000000..6d50325fed5 --- /dev/null +++ b/src/test/rustdoc/no-compiler-reexport.rs @@ -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; |
