Skip to content

Commit d5c300b

Browse files
committed
Report that doc(plugins) doesn't work using diagnostics instead of println!
This also adds a test for the output and fixes `rustc_attr` to properly know that `plugins` is a valid attribute.
1 parent 44c2794 commit d5c300b

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

compiler/rustc_passes/src/check_attr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ impl CheckAttrVisitor<'tcx> {
559559
sym::masked,
560560
sym::no_default_passes, // deprecated
561561
sym::no_inline,
562-
sym::passes, // deprecated
562+
sym::passes, // deprecated
563+
sym::plugins, // removed, but rustdoc warns about it itself
563564
sym::primitive,
564565
sym::spotlight,
565566
sym::test,

src/librustdoc/core.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@ crate fn run_global_ctxt(
572572

573573
if name == "no_default_passes" {
574574
msg.help("you may want to use `#![doc(document_private_items)]`");
575+
} else if name.starts_with("plugins") {
576+
msg.warn("`#![doc(plugins = \"...\")]` no longer functions; see CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>");
575577
}
576578

577579
msg.emit();
@@ -618,10 +620,6 @@ crate fn run_global_ctxt(
618620
}
619621
sym::plugins => {
620622
report_deprecated_attr("plugins = \"...\"", diag, attr.span());
621-
eprintln!(
622-
"WARNING: `#![doc(plugins = \"...\")]` \
623-
no longer functions; see CVE-2018-1000622"
624-
);
625623
continue;
626624
}
627625
_ => continue,

src/test/rustdoc-ui/deprecated-attrs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
//~| NOTE see issue #44136
1212
//~| WARNING ignoring unknown pass
1313
//~| NOTE `collapse-docs` pass was removed
14+
#![doc(plugins = "xxx")]
15+
//~^ WARNING attribute is deprecated
16+
//~| NOTE see issue #44136
17+
//~| WARNING no longer functions; see CVE

src/test/rustdoc-ui/deprecated-attrs.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,14 @@ LL | #![doc(passes = "collapse-docs unindent-comments")]
2929
|
3030
= note: the `collapse-docs` pass was removed in #80261 <https://github.com/rust-lang/rust/pull/80261>
3131

32-
warning: 4 warnings emitted
32+
warning: the `#![doc(plugins = "...")]` attribute is deprecated
33+
--> $DIR/deprecated-attrs.rs:14:8
34+
|
35+
LL | #![doc(plugins = "xxx")]
36+
| ^^^^^^^^^^^^^^^
37+
|
38+
= note: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
39+
= warning: `#![doc(plugins = "...")]` no longer functions; see CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>
40+
41+
warning: 5 warnings emitted
3342

0 commit comments

Comments
 (0)