Skip to content

Commit 6487148

Browse files
authored
Rollup merge of #146495 - fmease:rustdoc-erase-doc-priv-items-attr, r=GuillaumeGomez
rustdoc: Erase `#![doc(document_private_items)]` I just found out about the existence of `#![doc(document_private_items)]`. Apparently it was added by PR #50669 back in 2018 without any tests or docs as a replacement for some specific forms of the removed `#![doc(passes)]` / `#![doc(no_default_passes)]`. However, rustc and rustdoc actually emit the deny-by-default lint `invalid_doc_attributes` for it (but if you allow it, the attribute does function)! To be more precise since PR #82708 (1.52, May 2021) which introduced lint `invalid_doc_attributes`, rust{,do}c has emitted a future-incompat warning for this attribute. And since PR #111505 (1.78, May 2024) that lint is deny by default. I presume nobody knew this attribute existed and thus it was never allowlisted. Given the fact that since 2021 nobody has ever opened a ticket ([via](https://github.com/rust-lang/rust/issues?q=is%3Aissue+document_private_items)) complaining about the lint emission and the fact that GitHub code search doesn't yield any actual uses ([via](https://github.com/search?q=%2F%23%21%5C%5Bdoc%5C%28.*%3Fdocument_private_items%2F+language%3ARust&type=code&ref=advsearch)), I'm led to believe that nobody knows about and uses this attribute. I don't find the existence of this attribute to be justified since in my view the flag `--document-private-items` is strictly superior: In most if not all cases, you don't want to "couple" your crate with this "mode" even if you gate it behind a cfg; instead, you most likely want to set this manually at invocation time, via a build config file like `.cargo/config.toml` or via a command runner like `just` I'd say. Because of this I propose to wipe this attribute from existence. I don't believe it's worth cratering this (i.e., temporarily emitting a hard error for this attribute and running crater) given the fact that it's been undocumented since forever and led to a warning for years.
2 parents 3538bc1 + 044d15b commit 6487148

File tree

6 files changed

+2
-17
lines changed

6 files changed

+2
-17
lines changed

compiler/rustc_passes/messages.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ passes_doc_test_unknown_passes =
219219
unknown `doc` attribute `{$path}`
220220
.note = `doc` attribute `{$path}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
221221
.label = no longer functions
222-
.help = you may want to use `doc(document_private_items)`
223222
.no_op_note = `doc({$path})` is now a no-op
224223
225224
passes_doc_test_unknown_plugins =

compiler/rustc_passes/src/errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ pub(crate) struct DocTestUnknownSpotlight {
347347
#[derive(LintDiagnostic)]
348348
#[diag(passes_doc_test_unknown_passes)]
349349
#[note]
350-
#[help]
351350
#[note(passes_no_op_note)]
352351
pub(crate) struct DocTestUnknownPasses {
353352
pub path: String,

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,6 @@ symbols! {
899899
doc_primitive,
900900
doc_spotlight,
901901
doctest,
902-
document_private_items,
903902
dotdot: "..",
904903
dotdot_in_tuple_patterns,
905904
dotdoteq_in_patterns,

src/librustdoc/core.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,6 @@ pub(crate) fn run_global_ctxt(
416416
);
417417
}
418418

419-
// Process all of the crate attributes, extracting plugin metadata along
420-
// with the passes which we are supposed to run.
421-
for attr in krate.module.attrs.lists(sym::doc) {
422-
if attr.is_word() && attr.has_name(sym::document_private_items) {
423-
ctxt.render_options.document_private = true;
424-
}
425-
}
426-
427419
info!("Executing passes");
428420

429421
let mut visited = FxHashMap::default();

tests/rustdoc-ui/deprecated-attrs.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
//~^ ERROR unknown `doc` attribute `no_default_passes`
55
//~| NOTE no longer functions
66
//~| NOTE see issue #44136
7-
//~| HELP you may want to use `doc(document_private_items)`
87
//~| NOTE `doc(no_default_passes)` is now a no-op
98
//~| NOTE `#[deny(invalid_doc_attributes)]` on by default
109
#![doc(passes = "collapse-docs unindent-comments")]
1110
//~^ ERROR unknown `doc` attribute `passes`
1211
//~| NOTE no longer functions
1312
//~| NOTE see issue #44136
14-
//~| HELP you may want to use `doc(document_private_items)`
1513
//~| NOTE `doc(passes)` is now a no-op
1614
#![doc(plugins = "xxx")]
1715
//~^ ERROR unknown `doc` attribute `plugins`

tests/rustdoc-ui/deprecated-attrs.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ LL | #![doc(no_default_passes)]
1010
| ^^^^^^^^^^^^^^^^^ no longer functions
1111
|
1212
= note: `doc` attribute `no_default_passes` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
13-
= help: you may want to use `doc(document_private_items)`
1413
= note: `doc(no_default_passes)` is now a no-op
1514
= note: `#[deny(invalid_doc_attributes)]` on by default
1615

1716
error: unknown `doc` attribute `passes`
18-
--> $DIR/deprecated-attrs.rs:10:8
17+
--> $DIR/deprecated-attrs.rs:9:8
1918
|
2019
LL | #![doc(passes = "collapse-docs unindent-comments")]
2120
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no longer functions
2221
|
2322
= note: `doc` attribute `passes` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
24-
= help: you may want to use `doc(document_private_items)`
2523
= note: `doc(passes)` is now a no-op
2624

2725
error: unknown `doc` attribute `plugins`
28-
--> $DIR/deprecated-attrs.rs:16:8
26+
--> $DIR/deprecated-attrs.rs:14:8
2927
|
3028
LL | #![doc(plugins = "xxx")]
3129
| ^^^^^^^^^^^^^^^ no longer functions

0 commit comments

Comments
 (0)