From e9eeaec34ff8c74fec5494f290f03153db2e10d6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 28 Sep 2024 22:37:59 +0200 Subject: [PATCH] Rename doctest attribute `standalone-crate` into `standalone_crate` for coherency --- library/core/src/panic/location.rs | 2 +- .../src/write-documentation/documentation-tests.md | 4 ++-- src/librustdoc/html/markdown.rs | 6 +++--- tests/rustdoc-ui/doctest/standalone-warning-2024.rs | 2 +- .../rustdoc-ui/doctest/standalone-warning-2024.stderr | 10 +++++----- tests/rustdoc-ui/doctest/standalone-warning.rs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 97408a4ac180e..1ad5c07d15cd0 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -44,7 +44,7 @@ impl<'a> Location<'a> { /// /// # Examples /// - /// ```standalone-crate + /// ```standalone_crate /// use std::panic::Location; /// /// /// Returns the [`Location`] at which it is called. diff --git a/src/doc/rustdoc/src/write-documentation/documentation-tests.md b/src/doc/rustdoc/src/write-documentation/documentation-tests.md index 94ef34ea5a51a..c93893b5ada84 100644 --- a/src/doc/rustdoc/src/write-documentation/documentation-tests.md +++ b/src/doc/rustdoc/src/write-documentation/documentation-tests.md @@ -414,11 +414,11 @@ In some cases, doctests cannot be merged. For example, if you have: The problem with this code is that, if you change any other doctests, it'll likely break when runing `rustdoc --test`, making it tricky to maintain. -This is where the `standalone-crate` attribute comes in: it tells `rustdoc` that a doctest +This is where the `standalone_crate` attribute comes in: it tells `rustdoc` that a doctest should not be merged with the others. So the previous code should use it: ```rust -//! ```standalone-crate +//! ```standalone_crate //! let location = std::panic::Location::caller(); //! assert_eq!(location.line(), 4); //! ``` diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index e1a8dc6e50cc3..8ae5484feda7a 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1264,7 +1264,7 @@ impl LangString { seen_rust_tags = !seen_other_tags || seen_rust_tags; data.no_run = true; } - LangStringToken::LangToken("standalone-crate") => { + LangStringToken::LangToken("standalone_crate") => { data.standalone_crate = true; seen_rust_tags = !seen_other_tags || seen_rust_tags; } @@ -1315,12 +1315,12 @@ impl LangString { "use `test_harness` to run functions marked `#[test]` instead of a \ potentially-implicit `main` function", ), - "standalone" | "standalone_crate" => { + "standalone" | "standalone_crate" | "standalone-crate" => { if let Some(extra) = extra && extra.sp.at_least_rust_2024() { Some( - "use `standalone-crate` to compile this code block \ + "use `standalone_crate` to compile this code block \ separately", ) } else { diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs index 33ed16a87fa38..aac4303154697 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs @@ -11,6 +11,6 @@ //! bla //! ``` //! -//! ```standalone_crate +//! ```standalone-crate //! bla //! ``` diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr index ef2e236431985..d69d03d8657c1 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr @@ -5,12 +5,12 @@ error: unknown attribute `standalone` 11 | | //! bla 12 | | //! ``` 13 | | //! -14 | | //! ```standalone_crate +14 | | //! ```standalone-crate 15 | | //! bla 16 | | //! ``` | |_______^ | - = help: use `standalone-crate` to compile this code block separately + = help: use `standalone_crate` to compile this code block separately = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` note: the lint level is defined here --> $DIR/standalone-warning-2024.rs:8:9 @@ -19,19 +19,19 @@ note: the lint level is defined here | ^^^^^^^^ = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` -error: unknown attribute `standalone_crate` +error: unknown attribute `standalone-crate` --> $DIR/standalone-warning-2024.rs:10:1 | 10 | / //! ```standalone 11 | | //! bla 12 | | //! ``` 13 | | //! -14 | | //! ```standalone_crate +14 | | //! ```standalone-crate 15 | | //! bla 16 | | //! ``` | |_______^ | - = help: use `standalone-crate` to compile this code block separately + = help: use `standalone_crate` to compile this code block separately = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` 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 index 323d8f5f58065..ce081c7641c61 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning.rs +++ b/tests/rustdoc-ui/doctest/standalone-warning.rs @@ -5,6 +5,6 @@ //! bla //! ``` //! -//! ```standalone_crate +//! ```standalone-crate //! bla //! ```