Skip to content

Commit b9671ae

Browse files
authored
Rollup merge of #78114 - jyn514:private, r=oli-obk
Recognize `private_intra_doc_links` as a lint Previously, trying to allow this would give another error! ``` warning: unknown lint: `private_intra_doc_links` --> private.rs:1:10 | 1 | #![allow(private_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `broken_intra_doc_links` | = note: `#[warn(unknown_lints)]` on by default warning: public documentation for `DocMe` links to private item `DontDocMe` --> private.rs:2:11 | 2 | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | = note: `#[warn(private_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items` ``` Fixes the issue found in #77249 (comment). r? ````````@Manishearth```````` Does anyone know why this additional step is necessary? It seems weird this has to be declared in 3 different places.
2 parents 41134be + 47b21b8 commit b9671ae

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2801,6 +2801,7 @@ declare_lint_pass! {
28012801
UNSTABLE_NAME_COLLISIONS,
28022802
IRREFUTABLE_LET_PATTERNS,
28032803
BROKEN_INTRA_DOC_LINKS,
2804+
PRIVATE_INTRA_DOC_LINKS,
28042805
INVALID_CODEBLOCK_ATTRIBUTES,
28052806
MISSING_CRATE_LEVEL_DOCS,
28062807
MISSING_DOC_CODE_EXAMPLES,

src/librustdoc/core.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ pub fn run_core(
322322
let cpath = Some(input.clone());
323323
let input = Input::File(input);
324324

325-
let intra_link_resolution_failure_name = lint::builtin::BROKEN_INTRA_DOC_LINKS.name;
325+
let broken_intra_doc_links = lint::builtin::BROKEN_INTRA_DOC_LINKS.name;
326+
let private_intra_doc_links = lint::builtin::PRIVATE_INTRA_DOC_LINKS.name;
326327
let missing_docs = rustc_lint::builtin::MISSING_DOCS.name;
327328
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
328329
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;
@@ -336,7 +337,8 @@ pub fn run_core(
336337
// In addition to those specific lints, we also need to allow those given through
337338
// command line, otherwise they'll get ignored and we don't want that.
338339
let lints_to_show = vec![
339-
intra_link_resolution_failure_name.to_owned(),
340+
broken_intra_doc_links.to_owned(),
341+
private_intra_doc_links.to_owned(),
340342
missing_docs.to_owned(),
341343
missing_doc_example.to_owned(),
342344
private_doc_tests.to_owned(),
@@ -349,9 +351,8 @@ pub fn run_core(
349351
];
350352

351353
let (lint_opts, lint_caps) = init_lints(lints_to_show, lint_opts, |lint| {
352-
if lint.name == intra_link_resolution_failure_name
353-
|| lint.name == invalid_codeblock_attributes_name
354-
{
354+
// FIXME: why is this necessary?
355+
if lint.name == broken_intra_doc_links || lint.name == invalid_codeblock_attributes_name {
355356
None
356357
} else {
357358
Some((lint.name_lower(), lint::Allow))

0 commit comments

Comments
 (0)