about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-09-27 21:40:11 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-09-28 18:38:11 +0200
commit84d41e2fc19570e553dc6704e747062373ce4270 (patch)
tree6971b58e37fc0e0676a89a6a7c2fb4799f770a10
parent0956f69cafb4132023b9974f0a4a091bcac76618 (diff)
downloadrust-84d41e2fc19570e553dc6704e747062373ce4270.tar.gz
rust-84d41e2fc19570e553dc6704e747062373ce4270.zip
Add regression tests for mistyped `standalone-crate` attribute
-rw-r--r--tests/rustdoc-ui/doctest/standalone-warning-2024.rs16
-rw-r--r--tests/rustdoc-ui/doctest/standalone-warning-2024.stderr38
-rw-r--r--tests/rustdoc-ui/doctest/standalone-warning.rs10
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs
new file mode 100644
index 00000000000..33ed16a87fa
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs
@@ -0,0 +1,16 @@
+// This test checks that it will output warnings for usage of `standalone` or `standalone_crate`.
+
+//@ compile-flags:--test -Zunstable-options --edition 2024
+//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
+//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
+//@ normalize-stdout-test: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL"
+
+#![deny(warnings)]
+
+//! ```standalone
+//! bla
+//! ```
+//!
+//! ```standalone_crate
+//! bla
+//! ```
diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr
new file mode 100644
index 00000000000..ec9d17bb073
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr
@@ -0,0 +1,38 @@
+error: unknown attribute `standalone`
+  --> $DIR/standalone-warning-2024.rs:10:1
+   |
+10 | / //! ```standalone
+11 | | //! bla
+12 | | //! ```
+13 | | //!
+14 | | //! ```standalone_crate
+15 | | //! bla
+16 | | //! ```
+   | |_______^
+   |
+   = help: there is an attribute with a similar name: `standalone-crate`
+   = help: the code block will either not be tested if not marked as a rust one or the code will be run as part of the merged doctests if compatible
+note: the lint level is defined here
+  --> $DIR/standalone-warning-2024.rs:8:9
+   |
+8  | #![deny(warnings)]
+   |         ^^^^^^^^
+   = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]`
+
+error: unknown attribute `standalone_crate`
+  --> $DIR/standalone-warning-2024.rs:10:1
+   |
+10 | / //! ```standalone
+11 | | //! bla
+12 | | //! ```
+13 | | //!
+14 | | //! ```standalone_crate
+15 | | //! bla
+16 | | //! ```
+   | |_______^
+   |
+   = help: there is an attribute with a similar name: `standalone-crate`
+   = help: the code block will either not be tested if not marked as a rust one or the code will be run as part of the merged doctests if compatible
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/rustdoc-ui/doctest/standalone-warning.rs b/tests/rustdoc-ui/doctest/standalone-warning.rs
new file mode 100644
index 00000000000..323d8f5f580
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/standalone-warning.rs
@@ -0,0 +1,10 @@
+// This test checks that it will not output warning for usage of `standalone` or `standalone_crate`.
+//@ check-pass
+
+//! ```standalone
+//! bla
+//! ```
+//!
+//! ```standalone_crate
+//! bla
+//! ```