diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-10-12 13:48:45 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-10-12 13:50:31 +0200 |
| commit | 5d20e1aa03c6d86fcf9197ccec16ad5faa94beee (patch) | |
| tree | 5bf4b0065792b7671b9fb66aa906f8eae7076abc | |
| parent | 22465b35a608487773f960574a798262b23c4abd (diff) | |
| download | rust-5d20e1aa03c6d86fcf9197ccec16ad5faa94beee.tar.gz rust-5d20e1aa03c6d86fcf9197ccec16ad5faa94beee.zip | |
Improve lint level handling
| -rw-r--r-- | src/librustdoc/passes/calculate_doc_coverage.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/passes/doc_test_lints.rs | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 7cdd9a590ba..ced26fcf5b0 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -254,8 +254,10 @@ 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); + // `missing_docs` is allow-by-default, so don't treat this as ignoring the item + // unless the user had an explicit `allow` let should_have_docs = - level != lint::Level::Allow || !matches!(source, LintSource::Node(..)); + level != lint::Level::Allow || matches!(source, LintSource::Default); debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename); self.items.entry(i.source.filename.clone()).or_default().count_item( has_docs, diff --git a/src/librustdoc/passes/doc_test_lints.rs b/src/librustdoc/passes/doc_test_lints.rs index 1787d0a99d9..686ec51fb06 100644 --- a/src/librustdoc/passes/doc_test_lints.rs +++ b/src/librustdoc/passes/doc_test_lints.rs @@ -76,7 +76,7 @@ pub fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local()); let (level, source) = cx.tcx.lint_level_at_node(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id); - level != lint::Level::Allow || !matches!(source, LintSource::Node(..)) + level != lint::Level::Allow || matches!(source, LintSource::Default) } pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) { |
