Skip to content

Commit c929b9d

Browse files
committed
[librustdoc] Reform lang string token splitting
Only split doctest lang strings on `,`, ` `, and `\t`. Additionally, to preserve backwards compatibility with pandoc-style langstrings, strip a surrounding `{}`, and remove leading `.`s from each token. Prior to this change, doctest lang strings were split on all non-alphanumeric characters except `-` or `_`, which limited future extensions to doctest lang string tokens, for example using `=` for key-value tokens. This is a breaking change, although it is not expected to be disruptive, because lang strings using separators other than `,` and ` ` are not very common
1 parent b395eb2 commit c929b9d

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)