Skip to content

Commit

Permalink
Rename doctest attribute standalone-crate into standalone_crate f…
Browse files Browse the repository at this point in the history
…or coherency
  • Loading branch information
GuillaumeGomez committed Sep 28, 2024
1 parent 632fed8 commit 4840f99
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion library/core/src/panic/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
//! ```
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions tests/run-make/doctests-merge/doctest-standalone.stdout
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

running 2 tests
test doctest-standalone.rs - (line 4) ... ok
test doctest-standalone.rs - init (line 8) ... ok
running 0 tests

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/standalone-warning-2024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
//! bla
//! ```
//!
//! ```standalone_crate
//! ```standalone-crate
//! bla
//! ```
10 changes: 5 additions & 5 deletions tests/rustdoc-ui/doctest/standalone-warning-2024.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/standalone-warning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
//! bla
//! ```
//!
//! ```standalone_crate
//! ```standalone-crate
//! bla
//! ```

0 comments on commit 4840f99

Please sign in to comment.