File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ macro_rules! assert_ne {
141
141
#[allow_internal_unstable(core_panic)]
142
142
#[rustc_macro_transparency = "semitransparent"]
143
143
pub macro assert_matches {
144
- ($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({
144
+ ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({
145
145
match $left {
146
146
$( $pattern )|+ $( if $guard )? => {}
147
147
ref left_val => {
@@ -153,7 +153,7 @@ pub macro assert_matches {
153
153
}
154
154
}
155
155
}),
156
- ($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
156
+ ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
157
157
match $left {
158
158
$( $pattern )|+ $( if $guard )? => {}
159
159
ref left_val => {
@@ -321,7 +321,7 @@ pub macro debug_assert_matches($($arg:tt)*) {
321
321
#[macro_export]
322
322
#[stable(feature = "matches_macro", since = "1.42.0")]
323
323
macro_rules! matches {
324
- ($expression:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
324
+ ($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
325
325
match $expression {
326
326
$( $pattern )|+ $( if $guard )? => true,
327
327
_ => false
Original file line number Diff line number Diff line change @@ -12,3 +12,9 @@ fn assert_escape() {
12
12
fn assert_ne_trailing_comma() {
13
13
assert_ne!(1, 2,);
14
14
}
15
+
16
+ #[rustfmt::skip]
17
+ #[test]
18
+ fn matches_leading_pipe() {
19
+ matches!(1, | 1 | 2 | 3);
20
+ }
You can’t perform that action at this time.
0 commit comments