From 6f5f21adfc88a914c507ba8c9a0f1f34ae292d44 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/run-make/doctests-merge/doctest-standalone.rs | 4 ++-- 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 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 97408a4ac18..1ad5c07d15c 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 94ef34ea5a5..c93893b5ada 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 e1a8dc6e50c..8ae5484feda 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/run-make/doctests-merge/doctest-standalone.rs b/tests/run-make/doctests-merge/doctest-standalone.rs index 4b6a1c6ab61..ac9f8f9272a 100644 --- a/tests/run-make/doctests-merge/doctest-standalone.rs +++ b/tests/run-make/doctests-merge/doctest-standalone.rs @@ -1,11 +1,11 @@ #![crate_name = "foo"] #![crate_type = "lib"] -//! ```standalone-crate +//! ```standalone_crate //! foo::init(); //! ``` -/// ```standalone-crate +/// ```standalone_crate /// foo::init(); /// ``` pub fn init() { diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs index 33ed16a87fa..aac43031546 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 ef2e2364319..d69d03d8657 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 323d8f5f580..ce081c7641c 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 //! ```