about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-18 03:21:12 +0000
committerbors <bors@rust-lang.org>2021-08-18 03:21:12 +0000
commitcbe3afece59d85a53b9c7e085c1426c9bac2b526 (patch)
tree4b3cd7cbc8c801d736dedc2b3afef1bc0998774e /src/test/ui
parent02b27f1e70fc60a8f2aa0982e80d7cde5889112e (diff)
parentd4293ffcb34b17af42815b1669aeec50e9cf50b8 (diff)
Auto merge of #87728 - GuillaumeGomez:doc-test-attr-checks, r=jyn514
Add "doc(test(...))" attribute checks

Fixes #82672.

r? `@camelid`
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/rustdoc/doc-test-attr-pass.rs9
-rw-r--r--src/test/ui/rustdoc/doc-test-attr.rs14
-rw-r--r--src/test/ui/rustdoc/doc-test-attr.stderr34
3 files changed, 57 insertions, 0 deletions
diff --git a/src/test/ui/rustdoc/doc-test-attr-pass.rs b/src/test/ui/rustdoc/doc-test-attr-pass.rs
new file mode 100644
index 00000000000..7884addd15f
--- /dev/null
+++ b/src/test/ui/rustdoc/doc-test-attr-pass.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![crate_type = "lib"]
+#![deny(invalid_doc_attributes)]
+#![doc(test(no_crate_inject))]
+#![doc(test(attr(deny(warnings))))]
+#![doc(test())]
+
+pub fn foo() {}
diff --git a/src/test/ui/rustdoc/doc-test-attr.rs b/src/test/ui/rustdoc/doc-test-attr.rs
new file mode 100644
index 00000000000..46178ad865a
--- /dev/null
+++ b/src/test/ui/rustdoc/doc-test-attr.rs
@@ -0,0 +1,14 @@
+#![crate_type = "lib"]
+#![deny(invalid_doc_attributes)]
+
+#![doc(test)]
+//~^ ERROR `#[doc(test(...)]` takes a list of attributes
+//~^^ WARN this was previously accepted by the compiler
+#![doc(test = "hello")]
+//~^ ERROR `#[doc(test(...)]` takes a list of attributes
+//~^^ WARN this was previously accepted by the compiler
+#![doc(test(a))]
+//~^ ERROR unknown `doc(test)` attribute `a`
+//~^^ WARN this was previously accepted by the compiler
+
+pub fn foo() {}
diff --git a/src/test/ui/rustdoc/doc-test-attr.stderr b/src/test/ui/rustdoc/doc-test-attr.stderr
new file mode 100644
index 00000000000..7f5e2d6bc70
--- /dev/null
+++ b/src/test/ui/rustdoc/doc-test-attr.stderr
@@ -0,0 +1,34 @@
+error: `#[doc(test(...)]` takes a list of attributes
+  --> $DIR/doc-test-attr.rs:4:8
+   |
+LL | #![doc(test)]
+   |        ^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/doc-test-attr.rs:2:9
+   |
+LL | #![deny(invalid_doc_attributes)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+   = 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>
+
+error: `#[doc(test(...)]` takes a list of attributes
+  --> $DIR/doc-test-attr.rs:7:8
+   |
+LL | #![doc(test = "hello")]
+   |        ^^^^^^^^^^^^^^
+   |
+   = 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>
+
+error: unknown `doc(test)` attribute `a`
+  --> $DIR/doc-test-attr.rs:10:13
+   |
+LL | #![doc(test(a))]
+   |             ^
+   |
+   = 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>
+
+error: aborting due to 3 previous errors
+