Skip to content

Commit 03919fe

Browse files
committed
select_macro: Handle block as { $($:tt)* }
1 parent 801385b commit 03919fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

crossbeam-channel/src/select_macro.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,24 @@ macro_rules! crossbeam_channel_internal {
9090
};
9191
// Print an error if there is a semicolon after the block.
9292
(@list
93-
($case:ident $args:tt $(-> $res:pat)* => $body:block; $($tail:tt)*)
93+
($case:ident $args:tt $(-> $res:pat)* => { $($body:tt)* }; $($tail:tt)*)
9494
($($head:tt)*)
9595
) => {
9696
compile_error!(
9797
"did you mean to put a comma instead of the semicolon after `}`?"
9898
)
9999
};
100100
// The first case is separated by a comma.
101+
(@list
102+
($case:ident ($($args:tt)*) $(-> $res:pat)* => { $($body:tt)* }, $($tail:tt)*)
103+
($($head:tt)*)
104+
) => {
105+
$crate::crossbeam_channel_internal!(
106+
@list
107+
($($tail)*)
108+
($($head)* $case ($($args)*) $(-> $res)* => { $($body)* },)
109+
)
110+
};
101111
(@list
102112
($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr, $($tail:tt)*)
103113
($($head:tt)*)
@@ -110,13 +120,13 @@ macro_rules! crossbeam_channel_internal {
110120
};
111121
// Don't require a comma after the case if it has a proper block.
112122
(@list
113-
($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:block $($tail:tt)*)
123+
($case:ident ($($args:tt)*) $(-> $res:pat)* => { $($body:tt)* } $($tail:tt)*)
114124
($($head:tt)*)
115125
) => {
116126
$crate::crossbeam_channel_internal!(
117127
@list
118128
($($tail)*)
119-
($($head)* $case ($($args)*) $(-> $res)* => { $body },)
129+
($($head)* $case ($($args)*) $(-> $res)* => { $($body)* },)
120130
)
121131
};
122132
// Only one case remains.

0 commit comments

Comments
 (0)