Skip to content

Commit 56e18ca

Browse files
committed
Auto merge of rust-lang#78429 - casey:doctest-attribute-splitting, r=jyn514
[librustdoc] Only split lang string on `,`, ` `, and `\t` Split markdown lang strings into tokens on `,`. The previous behavior was to split lang strings into tokens on any character that wasn't a `_`, `_`, or alphanumeric. This is a potentially breaking change, so please scrutinize! See discussion in rust-lang#78344. I noticed some test cases that made me wonder if there might have been some reason for the original behavior: ``` t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None); t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None); t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None); t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None); ``` It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`. I did some digging, and it looks like the test cases were added way back in [this commit from 2014](rust-lang@3fef7a74ca9a) by `@skade.` It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted. Closes rust-lang#78344.
2 parents 7052525 + c929b9d commit 56e18ca

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

core/src/option.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<T> Option<T> {
336336
/// assert_eq!(x.expect("fruits are healthy"), "value");
337337
/// ```
338338
///
339-
/// ```{.should_panic}
339+
/// ```should_panic
340340
/// let x: Option<&str> = None;
341341
/// x.expect("fruits are healthy"); // panics with `fruits are healthy`
342342
/// ```
@@ -372,7 +372,7 @@ impl<T> Option<T> {
372372
/// assert_eq!(x.unwrap(), "air");
373373
/// ```
374374
///
375-
/// ```{.should_panic}
375+
/// ```should_panic
376376
/// let x: Option<&str> = None;
377377
/// assert_eq!(x.unwrap(), "air"); // fails
378378
/// ```
@@ -1114,7 +1114,7 @@ impl<T: fmt::Debug> Option<T> {
11141114
/// }
11151115
/// ```
11161116
///
1117-
/// ```{.should_panic}
1117+
/// ```should_panic
11181118
/// #![feature(option_expect_none)]
11191119
///
11201120
/// use std::collections::HashMap;
@@ -1156,7 +1156,7 @@ impl<T: fmt::Debug> Option<T> {
11561156
/// }
11571157
/// ```
11581158
///
1159-
/// ```{.should_panic}
1159+
/// ```should_panic
11601160
/// #![feature(option_unwrap_none)]
11611161
///
11621162
/// use std::collections::HashMap;

core/src/result.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
//! assert success with [`expect`]. This will panic if the
113113
//! write fails, providing a marginally useful message indicating why:
114114
//!
115-
//! ```{.no_run}
115+
//! ```no_run
116116
//! use std::fs::File;
117117
//! use std::io::prelude::*;
118118
//!
@@ -122,7 +122,7 @@
122122
//!
123123
//! You might also simply assert success:
124124
//!
125-
//! ```{.no_run}
125+
//! ```no_run
126126
//! # use std::fs::File;
127127
//! # use std::io::prelude::*;
128128
//! # let mut file = File::create("valuable_data.txt").unwrap();
@@ -984,7 +984,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
984984
///
985985
/// Basic usage:
986986
///
987-
/// ```{.should_panic}
987+
/// ```should_panic
988988
/// let x: Result<u32, &str> = Err("emergency failure");
989989
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
990990
/// ```
@@ -1024,7 +1024,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
10241024
/// assert_eq!(x.unwrap(), 2);
10251025
/// ```
10261026
///
1027-
/// ```{.should_panic}
1027+
/// ```should_panic
10281028
/// let x: Result<u32, &str> = Err("emergency failure");
10291029
/// x.unwrap(); // panics with `emergency failure`
10301030
/// ```
@@ -1052,7 +1052,7 @@ impl<T: fmt::Debug, E> Result<T, E> {
10521052
///
10531053
/// Basic usage:
10541054
///
1055-
/// ```{.should_panic}
1055+
/// ```should_panic
10561056
/// let x: Result<u32, &str> = Ok(10);
10571057
/// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
10581058
/// ```
@@ -1075,7 +1075,7 @@ impl<T: fmt::Debug, E> Result<T, E> {
10751075
///
10761076
/// # Examples
10771077
///
1078-
/// ```{.should_panic}
1078+
/// ```should_panic
10791079
/// let x: Result<u32, &str> = Ok(2);
10801080
/// x.unwrap_err(); // panics with `2`
10811081
/// ```

0 commit comments

Comments
 (0)