@@ -1497,10 +1497,12 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
1497
1497
}
1498
1498
}
1499
1499
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 > >
1504
1506
where F : FnOnce ( ) -> R + Send + ' static ,
1505
1507
R : Send + ' static ,
1506
1508
{
@@ -1564,7 +1566,7 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<dyn Any + Send>>
1564
1566
1565
1567
// The or condition is added from backward compatibility.
1566
1568
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 ) ;
1568
1570
1569
1571
// FIXME: Hacks on hacks. If the env is trying to override the stack size
1570
1572
// 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>>
1580
1582
}
1581
1583
}
1582
1584
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
+
1583
1595
/// Get a list of extra command-line flags provided by the user, as strings.
1584
1596
///
1585
1597
/// This function is used during ICEs to show more information useful for
0 commit comments