Skip to content

Commit 5d20e1a

Browse files
Improve lint level handling
1 parent 22465b3 commit 5d20e1a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/librustdoc/passes/calculate_doc_coverage.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,10 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
254254
let has_doc_example = tests.found_tests != 0;
255255
let hir_id = self.ctx.tcx.hir().local_def_id_to_hir_id(i.def_id.expect_local());
256256
let (level, source) = self.ctx.tcx.lint_level_at_node(MISSING_DOCS, hir_id);
257+
// `missing_docs` is allow-by-default, so don't treat this as ignoring the item
258+
// unless the user had an explicit `allow`
257259
let should_have_docs =
258-
level != lint::Level::Allow || !matches!(source, LintSource::Node(..));
260+
level != lint::Level::Allow || matches!(source, LintSource::Default);
259261
debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename);
260262
self.items.entry(i.source.filename.clone()).or_default().count_item(
261263
has_docs,

src/librustdoc/passes/doc_test_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool
7676
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local());
7777
let (level, source) =
7878
cx.tcx.lint_level_at_node(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id);
79-
level != lint::Level::Allow || !matches!(source, LintSource::Node(..))
79+
level != lint::Level::Allow || matches!(source, LintSource::Default)
8080
}
8181

8282
pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {

0 commit comments

Comments
 (0)