about summary refs log tree commit diff
diff options
context:
space:
mode:
authorObei Sideg <obei.sideg@gmail.com>2023-05-29 22:30:09 +0300
committerObei Sideg <obei.sideg@gmail.com>2023-05-29 22:33:46 +0300
commit70bbcceaeccc529670f9c9d60cd4fb038ee49fe4 (patch)
treede8209cc915c3d08e245f1708f67e0d4dfb19a28
parent33eef8221db63c6871f5c1957521b40e65eb3c5d (diff)
downloadrust-70bbcceaeccc529670f9c9d60cd4fb038ee49fe4.tar.gz
rust-70bbcceaeccc529670f9c9d60cd4fb038ee49fe4.zip
Add test for `#![doc(test(...)]` with literal parameter
-rw-r--r--compiler/rustc_passes/messages.ftl4
-rw-r--r--tests/ui/attributes/doc-test-literal.rs7
-rw-r--r--tests/ui/attributes/doc-test-literal.stderr17
3 files changed, 26 insertions, 2 deletions
diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl
index 139df68bb63..e76f1614b93 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 00000000000..a06a1afcb3f
--- /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 00000000000..ebee09994ba
--- /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 <https://github.com/rust-lang/rust/issues/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
+