Skip to content

Commit

Permalink
Report that doc(plugins) doesn't work using diagnostics instead of …
Browse files Browse the repository at this point in the history
…`println!`

This also adds a test for the output and fixes `rustc_attr` to properly
know that `plugins` is a valid attribute.
  • Loading branch information
jyn514 committed Mar 2, 2021
1 parent 44c2794 commit d5c300b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ impl CheckAttrVisitor<'tcx> {
sym::masked,
sym::no_default_passes, // deprecated
sym::no_inline,
sym::passes, // deprecated
sym::passes, // deprecated
sym::plugins, // removed, but rustdoc warns about it itself
sym::primitive,
sym::spotlight,
sym::test,
Expand Down
6 changes: 2 additions & 4 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ crate fn run_global_ctxt(

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

msg.emit();
Expand Down Expand Up @@ -618,10 +620,6 @@ crate fn run_global_ctxt(
}
sym::plugins => {
report_deprecated_attr("plugins = \"...\"", diag, attr.span());
eprintln!(
"WARNING: `#![doc(plugins = \"...\")]` \
no longer functions; see CVE-2018-1000622"
);
continue;
}
_ => continue,
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/deprecated-attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
//~| NOTE see issue #44136
//~| WARNING ignoring unknown pass
//~| NOTE `collapse-docs` pass was removed
#![doc(plugins = "xxx")]
//~^ WARNING attribute is deprecated
//~| NOTE see issue #44136
//~| WARNING no longer functions; see CVE
11 changes: 10 additions & 1 deletion src/test/rustdoc-ui/deprecated-attrs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@ LL | #![doc(passes = "collapse-docs unindent-comments")]
|
= note: the `collapse-docs` pass was removed in #80261 <https://github.com/rust-lang/rust/pull/80261>

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

warning: 5 warnings emitted

0 comments on commit d5c300b

Please sign in to comment.