@@ -1483,10 +1483,12 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
14831483 }
14841484}
14851485
1486- /// Runs `f` in a suitable thread for running `rustc`; returns a
1487- /// `Result` with either the return value of `f` or -- if a panic
1488- /// occurs -- the panic value.
1489- pub fn in_rustc_thread < F , R > ( f : F ) -> Result < R , Box < Any + Send > >
1486+ /// Runs `f` in a suitable thread for running `rustc`; returns a `Result` with either the return
1487+ /// value of `f` or -- if a panic occurs -- the panic value.
1488+ ///
1489+ /// This version applies the given name to the thread. This is used by rustdoc to ensure consistent
1490+ /// doctest output across platforms and executions.
1491+ pub fn in_named_rustc_thread < F , R > ( name : String , f : F ) -> Result < R , Box < Any + Send > >
14901492 where F : FnOnce ( ) -> R + Send + ' static ,
14911493 R : Send + ' static ,
14921494{
@@ -1530,7 +1532,7 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
15301532
15311533 // The or condition is added from backward compatibility.
15321534 if spawn_thread || env:: var_os ( "RUST_MIN_STACK" ) . is_some ( ) {
1533- let mut cfg = thread:: Builder :: new ( ) . name ( "rustc" . to_string ( ) ) ;
1535+ let mut cfg = thread:: Builder :: new ( ) . name ( name ) ;
15341536
15351537 // FIXME: Hacks on hacks. If the env is trying to override the stack size
15361538 // then *don't* set it explicitly.
@@ -1546,6 +1548,16 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
15461548 }
15471549}
15481550
1551+ /// Runs `f` in a suitable thread for running `rustc`; returns a
1552+ /// `Result` with either the return value of `f` or -- if a panic
1553+ /// occurs -- the panic value.
1554+ pub fn in_rustc_thread < F , R > ( f : F ) -> Result < R , Box < dyn Any + Send > >
1555+ where F : FnOnce ( ) -> R + Send + ' static ,
1556+ R : Send + ' static ,
1557+ {
1558+ in_named_rustc_thread ( "rustc" . to_string ( ) , f)
1559+ }
1560+
15491561/// Get a list of extra command-line flags provided by the user, as strings.
15501562///
15511563/// This function is used during ICEs to show more information useful for
0 commit comments