@@ -1483,10 +1483,12 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
1483
1483
}
1484
1484
}
1485
1485
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 > >
1490
1492
where F : FnOnce ( ) -> R + Send + ' static ,
1491
1493
R : Send + ' static ,
1492
1494
{
@@ -1530,7 +1532,7 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
1530
1532
1531
1533
// The or condition is added from backward compatibility.
1532
1534
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 ) ;
1534
1536
1535
1537
// FIXME: Hacks on hacks. If the env is trying to override the stack size
1536
1538
// then *don't* set it explicitly.
@@ -1546,6 +1548,16 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
1546
1548
}
1547
1549
}
1548
1550
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
+
1549
1561
/// Get a list of extra command-line flags provided by the user, as strings.
1550
1562
///
1551
1563
/// This function is used during ICEs to show more information useful for
0 commit comments