From 84d41e2fc19570e553dc6704e747062373ce4270 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 21:40:11 +0200 Subject: [PATCH] Add regression tests for mistyped `standalone-crate` attribute --- .../doctest/standalone-warning-2024.rs | 16 ++++++++ .../doctest/standalone-warning-2024.stderr | 38 +++++++++++++++++++ .../rustdoc-ui/doctest/standalone-warning.rs | 10 +++++ 3 files changed, 64 insertions(+) create mode 100644 tests/rustdoc-ui/doctest/standalone-warning-2024.rs create mode 100644 tests/rustdoc-ui/doctest/standalone-warning-2024.stderr create mode 100644 tests/rustdoc-ui/doctest/standalone-warning.rs 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 +//! ```