diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2021-04-09 09:00:12 -0400 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2021-04-09 09:09:19 -0400 |
| commit | 40ca3521ad1b0b42980ff16d5b9d1d3d8b68a50e (patch) | |
| tree | 7ed03f2cbf3e64dc0d6bf1e91721f533d23867cd /src | |
| parent | 69e1d22ddbc67b25141a735a22a8895a678b32ca (diff) | |
| download | rust-40ca3521ad1b0b42980ff16d5b9d1d3d8b68a50e.tar.gz rust-40ca3521ad1b0b42980ff16d5b9d1d3d8b68a50e.zip | |
rustdoc: Don't generate blanket impls when running --show-coverage
get_blanket_impls is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/passes/calculate_doc_coverage.rs | 50 | ||||
| -rw-r--r-- | src/librustdoc/passes/mod.rs | 1 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/traits.rs | 1 |
3 files changed, 8 insertions, 44 deletions
diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index ad269413ac6..fdac33fd60e 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -7,7 +7,6 @@ use crate::passes::Pass; use rustc_lint::builtin::MISSING_DOCS; use rustc_middle::lint::LintLevelSource; use rustc_session::lint; -use rustc_span::symbol::sym; use rustc_span::FileName; use serde::Serialize; @@ -193,48 +192,13 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> { // don't count items in stripped modules return Some(i); } - clean::ImportItem(..) | clean::ExternCrateItem { .. } => { - // docs on `use` and `extern crate` statements are not displayed, so they're not - // worth counting - return Some(i); - } - clean::ImplItem(ref impl_) - if i.attrs - .other_attrs - .iter() - .any(|item| item.has_name(sym::automatically_derived)) - || impl_.synthetic - || impl_.blanket_impl.is_some() => - { - // built-in derives get the `#[automatically_derived]` attribute, and - // synthetic/blanket impls are made up by rustdoc and can't be documented - // FIXME(misdreavus): need to also find items that came out of a derive macro - return Some(i); - } - clean::ImplItem(ref impl_) => { - let filename = i.span.filename(self.ctx.sess()); - if let Some(ref tr) = impl_.trait_ { - debug!( - "impl {:#} for {:#} in {}", - tr.print(&self.ctx.cache, self.ctx.tcx), - impl_.for_.print(&self.ctx.cache, self.ctx.tcx), - filename, - ); - - // don't count trait impls, the missing-docs lint doesn't so we shouldn't - // either - return Some(i); - } else { - // inherent impls *can* be documented, and those docs show up, but in most - // cases it doesn't make sense, as all methods on a type are in one single - // impl block - debug!( - "impl {:#} in {}", - impl_.for_.print(&self.ctx.cache, self.ctx.tcx), - filename - ); - } - } + // docs on `use` and `extern crate` statements are not displayed, so they're not + // worth counting + clean::ImportItem(..) | clean::ExternCrateItem { .. } => {} + // Don't count trait impls, the missing-docs lint doesn't so we shouldn't either. + // Inherent impls *can* be documented, and those docs show up, but in most cases it + // doesn't make sense, as all methods on a type are in one single impl block + clean::ImplItem(_) => {} _ => { let has_docs = !i.attrs.doc_strings.is_empty(); let mut tests = Tests { found_tests: 0 }; diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 755217a4629..f3a65cad46c 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -110,7 +110,6 @@ crate const DEFAULT_PASSES: &[ConditionalPass] = &[ /// The list of default passes run when `--doc-coverage` is passed to rustdoc. crate const COVERAGE_PASSES: &[ConditionalPass] = &[ - ConditionalPass::always(COLLECT_TRAIT_IMPLS), ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden), ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate), ConditionalPass::always(CALCULATE_DOC_COVERAGE), diff --git a/src/test/rustdoc-ui/coverage/traits.rs b/src/test/rustdoc-ui/coverage/traits.rs index 7d5cf049e7f..2bcb50aea77 100644 --- a/src/test/rustdoc-ui/coverage/traits.rs +++ b/src/test/rustdoc-ui/coverage/traits.rs @@ -16,6 +16,7 @@ pub trait ThisTrait { } /// so what happens if we take some struct... +#[derive(Clone)] pub struct SomeStruct; /// ...and slap this trait on it? |
