From d5c300b1f2e9a6f7f05b2fa51ca2b4d011d289f4 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 28 Feb 2021 22:51:35 -0500 Subject: [PATCH] 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. --- compiler/rustc_passes/src/check_attr.rs | 3 ++- src/librustdoc/core.rs | 6 ++---- src/test/rustdoc-ui/deprecated-attrs.rs | 4 ++++ src/test/rustdoc-ui/deprecated-attrs.stderr | 11 ++++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index afd1642bbd5..d0ab0d657d9 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -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, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index a935bd6b456..19821c3ccef 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -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 "); } msg.emit(); @@ -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, diff --git a/src/test/rustdoc-ui/deprecated-attrs.rs b/src/test/rustdoc-ui/deprecated-attrs.rs index a0439acc024..5febc5eb9cd 100644 --- a/src/test/rustdoc-ui/deprecated-attrs.rs +++ b/src/test/rustdoc-ui/deprecated-attrs.rs @@ -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 diff --git a/src/test/rustdoc-ui/deprecated-attrs.stderr b/src/test/rustdoc-ui/deprecated-attrs.stderr index 42a229abf58..b855cedf522 100644 --- a/src/test/rustdoc-ui/deprecated-attrs.stderr +++ b/src/test/rustdoc-ui/deprecated-attrs.stderr @@ -29,5 +29,14 @@ LL | #![doc(passes = "collapse-docs unindent-comments")] | = note: the `collapse-docs` pass was removed in #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 for more information + = warning: `#![doc(plugins = "...")]` no longer functions; see CVE-2018-1000622 + +warning: 5 warnings emitted