@@ -1497,10 +1497,12 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
14971497 }
14981498}
14991499
1500- /// Runs `f` in a suitable thread for running `rustc`; returns a
1501- /// `Result` with either the return value of `f` or -- if a panic
1502- /// occurs -- the panic value.
1503- pub fn in_rustc_thread < F , R > ( f : F ) -> Result < R , Box < dyn Any + Send > >
1500+ /// Runs `f` in a suitable thread for running `rustc`; returns a `Result` with either the return
1501+ /// value of `f` or -- if a panic occurs -- the panic value.
1502+ ///
1503+ /// This version applies the given name to the thread. This is used by rustdoc to ensure consistent
1504+ /// doctest output across platforms and executions.
1505+ pub fn in_named_rustc_thread < F , R > ( name : String , f : F ) -> Result < R , Box < dyn Any + Send > >
15041506 where F : FnOnce ( ) -> R + Send + ' static ,
15051507 R : Send + ' static ,
15061508{
@@ -1564,7 +1566,7 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<dyn Any + Send>>
15641566
15651567 // The or condition is added from backward compatibility.
15661568 if spawn_thread || env:: var_os ( "RUST_MIN_STACK" ) . is_some ( ) {
1567- let mut cfg = thread:: Builder :: new ( ) . name ( "rustc" . to_string ( ) ) ;
1569+ let mut cfg = thread:: Builder :: new ( ) . name ( name ) ;
15681570
15691571 // FIXME: Hacks on hacks. If the env is trying to override the stack size
15701572 // then *don't* set it explicitly.
@@ -1580,6 +1582,16 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<dyn Any + Send>>
15801582 }
15811583}
15821584
1585+ /// Runs `f` in a suitable thread for running `rustc`; returns a
1586+ /// `Result` with either the return value of `f` or -- if a panic
1587+ /// occurs -- the panic value.
1588+ pub fn in_rustc_thread < F , R > ( f : F ) -> Result < R , Box < dyn Any + Send > >
1589+ where F : FnOnce ( ) -> R + Send + ' static ,
1590+ R : Send + ' static ,
1591+ {
1592+ in_named_rustc_thread ( "rustc" . to_string ( ) , f)
1593+ }
1594+
15831595/// Get a list of extra command-line flags provided by the user, as strings.
15841596///
15851597/// This function is used during ICEs to show more information useful for
0 commit comments