Rename doctest attribute standalone-crate into standalone_crate for coherency

This commit is contained in:
Guillaume Gomez 2024-09-28 22:37:59 +02:00
parent 632fed891d
commit 6f5f21adfc
7 changed files with 15 additions and 15 deletions

View File

@ -44,7 +44,7 @@ impl<'a> Location<'a> {
/// ///
/// # Examples /// # Examples
/// ///
/// ```standalone-crate /// ```standalone_crate
/// use std::panic::Location; /// use std::panic::Location;
/// ///
/// /// Returns the [`Location`] at which it is called. /// /// Returns the [`Location`] at which it is called.

View File

@ -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 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. 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: should not be merged with the others. So the previous code should use it:
```rust ```rust
//! ```standalone-crate //! ```standalone_crate
//! let location = std::panic::Location::caller(); //! let location = std::panic::Location::caller();
//! assert_eq!(location.line(), 4); //! assert_eq!(location.line(), 4);
//! ``` //! ```

View File

@ -1264,7 +1264,7 @@ impl LangString {
seen_rust_tags = !seen_other_tags || seen_rust_tags; seen_rust_tags = !seen_other_tags || seen_rust_tags;
data.no_run = true; data.no_run = true;
} }
LangStringToken::LangToken("standalone-crate") => { LangStringToken::LangToken("standalone_crate") => {
data.standalone_crate = true; data.standalone_crate = true;
seen_rust_tags = !seen_other_tags || seen_rust_tags; 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 \ "use `test_harness` to run functions marked `#[test]` instead of a \
potentially-implicit `main` function", potentially-implicit `main` function",
), ),
"standalone" | "standalone_crate" => { "standalone" | "standalone_crate" | "standalone-crate" => {
if let Some(extra) = extra if let Some(extra) = extra
&& extra.sp.at_least_rust_2024() && extra.sp.at_least_rust_2024()
{ {
Some( Some(
"use `standalone-crate` to compile this code block \ "use `standalone_crate` to compile this code block \
separately", separately",
) )
} else { } else {

View File

@ -1,11 +1,11 @@
#![crate_name = "foo"] #![crate_name = "foo"]
#![crate_type = "lib"] #![crate_type = "lib"]
//! ```standalone-crate //! ```standalone_crate
//! foo::init(); //! foo::init();
//! ``` //! ```
/// ```standalone-crate /// ```standalone_crate
/// foo::init(); /// foo::init();
/// ``` /// ```
pub fn init() { pub fn init() {

View File

@ -11,6 +11,6 @@
//! bla //! bla
//! ``` //! ```
//! //!
//! ```standalone_crate //! ```standalone-crate
//! bla //! bla
//! ``` //! ```

View File

@ -5,12 +5,12 @@ error: unknown attribute `standalone`
11 | | //! bla 11 | | //! bla
12 | | //! ``` 12 | | //! ```
13 | | //! 13 | | //!
14 | | //! ```standalone_crate 14 | | //! ```standalone-crate
15 | | //! bla 15 | | //! bla
16 | | //! ``` 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` = 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 note: the lint level is defined here
--> $DIR/standalone-warning-2024.rs:8:9 --> $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)]` = 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 --> $DIR/standalone-warning-2024.rs:10:1
| |
10 | / //! ```standalone 10 | / //! ```standalone
11 | | //! bla 11 | | //! bla
12 | | //! ``` 12 | | //! ```
13 | | //! 13 | | //!
14 | | //! ```standalone_crate 14 | | //! ```standalone-crate
15 | | //! bla 15 | | //! bla
16 | | //! ``` 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` = 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 error: aborting due to 2 previous errors

View File

@ -5,6 +5,6 @@
//! bla //! bla
//! ``` //! ```
//! //!
//! ```standalone_crate //! ```standalone-crate
//! bla //! bla
//! ``` //! ```