From 70bbcceaeccc529670f9c9d60cd4fb038ee49fe4 Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Mon, 29 May 2023 22:30:09 +0300 Subject: [PATCH] Add test for `#![doc(test(...)]` with literal parameter --- compiler/rustc_passes/messages.ftl | 4 ++-- tests/ui/attributes/doc-test-literal.rs | 7 +++++++ tests/ui/attributes/doc-test-literal.stderr | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/ui/attributes/doc-test-literal.rs create mode 100644 tests/ui/attributes/doc-test-literal.stderr diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 139df68bb63d9..e76f1614b9334 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -211,11 +211,11 @@ passes_doc_keyword_not_mod = passes_doc_keyword_only_impl = `#[doc(keyword = "...")]` should be used on impl blocks +passes_doc_test_literal = `#![doc(test(...)]` does not take a literal + passes_doc_test_takes_list = `#[doc(test(...)]` takes a list of attributes -passes_doc_test_literal = `#![doc(test(...)]` does not take a literal - passes_doc_test_unknown = unknown `doc(test)` attribute `{$path}` diff --git a/tests/ui/attributes/doc-test-literal.rs b/tests/ui/attributes/doc-test-literal.rs new file mode 100644 index 0000000000000..a06a1afcb3f2f --- /dev/null +++ b/tests/ui/attributes/doc-test-literal.rs @@ -0,0 +1,7 @@ +#![deny(warnings)] + +#![doc(test(""))] +//~^ ERROR `#![doc(test(...)]` does not take a literal +//~^^ WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() {} diff --git a/tests/ui/attributes/doc-test-literal.stderr b/tests/ui/attributes/doc-test-literal.stderr new file mode 100644 index 0000000000000..ebee09994ba9f --- /dev/null +++ b/tests/ui/attributes/doc-test-literal.stderr @@ -0,0 +1,17 @@ +error: `#![doc(test(...)]` does not take a literal + --> $DIR/doc-test-literal.rs:3:13 + | +LL | #![doc(test(""))] + | ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 +note: the lint level is defined here + --> $DIR/doc-test-literal.rs:1:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` + +error: aborting due to previous error +