]> git.lizzy.rs Git - rust.git/commitdiff
Run the first block in a parallel! macro directly in the scope which guarantees that...
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Sat, 23 Feb 2019 15:47:13 +0000 (16:47 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Wed, 6 Mar 2019 03:47:03 +0000 (04:47 +0100)
src/librustc_data_structures/sync.rs

index ba1f6eb56fe886eec434fcc1c251c0f577f55a3d..14e625af29923412157f33ee705ce6e867358b4d 100644 (file)
@@ -280,21 +280,22 @@ pub fn lock_mut(&self) -> LockGuard<'_, T> {
 
         #[macro_export]
         macro_rules! parallel {
-            (impl [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
-                parallel!(impl [$block, $($c,)*] [$($rest),*])
+            (impl $fblock:tt [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
+                parallel!(impl $fblock [$block, $($c,)*] [$($rest),*])
             };
-            (impl [$($blocks:tt,)*] []) => {
+            (impl $fblock:tt [$($blocks:tt,)*] []) => {
                 ::rustc_data_structures::sync::scope(|s| {
                     $(
                         s.spawn(|_| $blocks);
                     )*
+                    $fblock;
                 })
             };
-            ($($blocks:tt),*) => {
+            ($fblock:tt, $($blocks:tt),*) => {
                 // Reverse the order of the blocks since Rayon executes them in reverse order
                 // when using a single thread. This ensures the execution order matches that
                 // of a single threaded rustc
-                parallel!(impl [] [$($blocks),*]);
+                parallel!(impl $fblock [] [$($blocks),*]);
             };
         }