File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ macro_rules! assert_ne {
140
140
#[ allow_internal_unstable( core_panic) ]
141
141
#[ rustc_macro_transparency = "semitransparent" ]
142
142
pub macro assert_matches {
143
- ( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => ( {
143
+ ( $left: expr, $( | ) ? $ ( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => ( {
144
144
match $left {
145
145
$( $pattern ) |+ $( if $guard ) ? => { }
146
146
ref left_val => {
@@ -152,7 +152,7 @@ pub macro assert_matches {
152
152
}
153
153
}
154
154
} ) ,
155
- ( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => ( {
155
+ ( $left: expr, $( | ) ? $ ( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => ( {
156
156
match $left {
157
157
$( $pattern ) |+ $( if $guard ) ? => { }
158
158
ref left_val => {
@@ -320,7 +320,7 @@ pub macro debug_assert_matches($($arg:tt)*) {
320
320
#[ macro_export]
321
321
#[ stable( feature = "matches_macro" , since = "1.42.0" ) ]
322
322
macro_rules! matches {
323
- ( $expression: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => {
323
+ ( $expression: expr, $( | ) ? $ ( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => {
324
324
match $expression {
325
325
$( $pattern ) |+ $( if $guard ) ? => true ,
326
326
_ => 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