Apply same treatment to MISSING_DOC_CODE_EXAMPLES

This commit is contained in:
Guillaume Gomez
2020-10-08 18:20:00 +02:00
parent b31f5d05b1
commit 22465b35a6
3 changed files with 34 additions and 6 deletions

View File

@@ -254,12 +254,13 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
let has_doc_example = tests.found_tests != 0;
let hir_id = self.ctx.tcx.hir().local_def_id_to_hir_id(i.def_id.expect_local());
let (level, source) = self.ctx.tcx.lint_level_at_node(MISSING_DOCS, hir_id);
let should_have_docs = level != lint::Level::Allow || !matches!(source, LintSource::Node(..));
let should_have_docs =
level != lint::Level::Allow || !matches!(source, LintSource::Node(..));
debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename);
self.items.entry(i.source.filename.clone()).or_default().count_item(
has_docs,
has_doc_example,
should_have_doc_example(&i.inner),
should_have_doc_example(self.ctx, &i),
should_have_docs,
);
}