Skip to content

Commit 5f5dbb9

Browse files
bors[bot]taiki-e
andauthored
Merge #783 #784
783: Use `$(,)?` to handle trailing comma r=taiki-e a=taiki-e 784: Enable -Zmiri-symbolic-alignment-check and -Zmiri-check-number-validity in miri CI r=taiki-e a=taiki-e Closes #780 Co-authored-by: Taiki Endo <te316e89@gmail.com>
3 parents 1d99555 + 58c0c3f + 708c2a5 commit 5f5dbb9

File tree

3 files changed

+28
-67
lines changed

3 files changed

+28
-67
lines changed

ci/miri.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ set -euxo pipefail
33
IFS=$'\n\t'
44
cd "$(dirname "$0")"/..
55

6-
MIRIFLAGS="-Zmiri-tag-raw-pointers" \
6+
MIRIFLAGS="-Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-tag-raw-pointers" \
77
cargo miri test \
8-
-p crossbeam-queue
8+
-p crossbeam-queue
99

1010
# -Zmiri-tag-raw-pointers doesn't work with std::thread::Builder::name on Linux: https://github.com/rust-lang/miri/issues/1717
11-
MIRIFLAGS="-Zmiri-disable-isolation" \
11+
MIRIFLAGS="-Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation" \
1212
cargo miri test \
13-
-p crossbeam-utils
13+
-p crossbeam-utils
1414

1515
# -Zmiri-ignore-leaks is needed because we use detached threads in tests/docs: https://github.com/rust-lang/miri/issues/1371
16-
MIRIFLAGS="-Zmiri-tag-raw-pointers -Zmiri-disable-isolation -Zmiri-ignore-leaks" \
16+
MIRIFLAGS="-Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-tag-raw-pointers -Zmiri-disable-isolation -Zmiri-ignore-leaks" \
1717
cargo miri test \
18-
-p crossbeam-channel
18+
-p crossbeam-channel
1919

2020
# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
2121
# -Zmiri-disable-stacked-borrows is needed for https://github.com/crossbeam-rs/crossbeam/issues/545
22-
MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-ignore-leaks -Zmiri-disable-stacked-borrows" \
22+
MIRIFLAGS="-Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks" \
2323
cargo miri test \
24-
-p crossbeam-epoch \
25-
-p crossbeam-skiplist
24+
-p crossbeam-epoch \
25+
-p crossbeam-skiplist
2626

2727
# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
2828
# -Zmiri-disable-stacked-borrows is needed for https://github.com/crossbeam-rs/crossbeam/issues/545
29-
MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-disable-stacked-borrows -Zmiri-compare-exchange-weak-failure-rate=1.0" \
29+
MIRIFLAGS="-Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks -Zmiri-compare-exchange-weak-failure-rate=1.0" \
3030
cargo miri test \
31-
-p crossbeam-deque
31+
-p crossbeam-deque
3232

3333
# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
34-
MIRIFLAGS="-Zmiri-ignore-leaks" \
34+
MIRIFLAGS="-Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-ignore-leaks" \
3535
cargo miri test \
36-
-p crossbeam
36+
-p crossbeam

crossbeam-channel/src/select_macro.rs

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,7 @@ macro_rules! crossbeam_channel_internal {
121121
};
122122
// Only one case remains.
123123
(@list
124-
($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr)
125-
($($head:tt)*)
126-
) => {
127-
$crate::crossbeam_channel_internal!(
128-
@list
129-
()
130-
($($head)* $case ($($args)*) $(-> $res)* => { $body },)
131-
)
132-
};
133-
// Accept a trailing comma at the end of the list.
134-
(@list
135-
($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr,)
124+
($case:ident ($($args:tt)*) $(-> $res:pat)* => $body:expr $(,)?)
136125
($($head:tt)*)
137126
) => {
138127
$crate::crossbeam_channel_internal!(
@@ -373,20 +362,7 @@ macro_rules! crossbeam_channel_internal {
373362

374363
// Check the format of a recv case.
375364
(@case
376-
(recv($r:expr) -> $res:pat => $body:tt, $($tail:tt)*)
377-
($($cases:tt)*)
378-
$default:tt
379-
) => {
380-
$crate::crossbeam_channel_internal!(
381-
@case
382-
($($tail)*)
383-
($($cases)* recv($r) -> $res => $body,)
384-
$default
385-
)
386-
};
387-
// Allow trailing comma...
388-
(@case
389-
(recv($r:expr,) -> $res:pat => $body:tt, $($tail:tt)*)
365+
(recv($r:expr $(,)?) -> $res:pat => $body:tt, $($tail:tt)*)
390366
($($cases:tt)*)
391367
$default:tt
392368
) => {
@@ -428,20 +404,7 @@ macro_rules! crossbeam_channel_internal {
428404

429405
// Check the format of a send case.
430406
(@case
431-
(send($s:expr, $m:expr) -> $res:pat => $body:tt, $($tail:tt)*)
432-
($($cases:tt)*)
433-
$default:tt
434-
) => {
435-
$crate::crossbeam_channel_internal!(
436-
@case
437-
($($tail)*)
438-
($($cases)* send($s, $m) -> $res => $body,)
439-
$default
440-
)
441-
};
442-
// Allow trailing comma...
443-
(@case
444-
(send($s:expr, $m:expr,) -> $res:pat => $body:tt, $($tail:tt)*)
407+
(send($s:expr, $m:expr $(,)?) -> $res:pat => $body:tt, $($tail:tt)*)
445408
($($cases:tt)*)
446409
$default:tt
447410
) => {
@@ -496,20 +459,7 @@ macro_rules! crossbeam_channel_internal {
496459
};
497460
// Check the format of a default case with timeout.
498461
(@case
499-
(default($timeout:expr) => $body:tt, $($tail:tt)*)
500-
$cases:tt
501-
()
502-
) => {
503-
$crate::crossbeam_channel_internal!(
504-
@case
505-
($($tail)*)
506-
$cases
507-
(default($timeout) => $body,)
508-
)
509-
};
510-
// Allow trailing comma...
511-
(@case
512-
(default($timeout:expr,) => $body:tt, $($tail:tt)*)
462+
(default($timeout:expr $(,)?) => $body:tt, $($tail:tt)*)
513463
$cases:tt
514464
()
515465
) => {

crossbeam-channel/tests/select_macro.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,3 +1468,14 @@ fn disconnect_wakes_receiver() {
14681468
})
14691469
.unwrap();
14701470
}
1471+
1472+
#[test]
1473+
fn trailing_comma() {
1474+
let (s, r) = unbounded::<usize>();
1475+
1476+
select! {
1477+
send(s, 1,) -> _ => {},
1478+
recv(r,) -> _ => {},
1479+
default(ms(1000),) => {},
1480+
}
1481+
}

0 commit comments

Comments
 (0)