Skip to content

Commit d2923e5

Browse files
committed
Run the first block in a parallel! macro directly in the scope which guarantees that it will run immediately
1 parent d5bb71c commit d2923e5

File tree

1 file changed

+6
-5
lines changed
  • src/librustc_data_structures

1 file changed

+6
-5
lines changed

src/librustc_data_structures/sync.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,22 @@ cfg_if! {
280280

281281
#[macro_export]
282282
macro_rules! parallel {
283-
(impl [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
284-
parallel!(impl [$block, $($c,)*] [$($rest),*])
283+
(impl $fblock:tt [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
284+
parallel!(impl $fblock [$block, $($c,)*] [$($rest),*])
285285
};
286-
(impl [$($blocks:tt,)*] []) => {
286+
(impl $fblock:tt [$($blocks:tt,)*] []) => {
287287
::rustc_data_structures::sync::scope(|s| {
288288
$(
289289
s.spawn(|_| $blocks);
290290
)*
291+
$fblock;
291292
})
292293
};
293-
($($blocks:tt),*) => {
294+
($fblock:tt, $($blocks:tt),*) => {
294295
// Reverse the order of the blocks since Rayon executes them in reverse order
295296
// when using a single thread. This ensures the execution order matches that
296297
// of a single threaded rustc
297-
parallel!(impl [] [$($blocks),*]);
298+
parallel!(impl $fblock [] [$($blocks),*]);
298299
};
299300
}
300301

0 commit comments

Comments
 (0)