about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-02 00:13:40 +0000
committerbors <bors@rust-lang.org>2021-08-02 00:13:40 +0000
commit24bbf7ac2fd6f5e71f5a4873baa4456e45bd648d (patch)
treefdeaa1e770594084a041ef7e386e599f2321a40f /library/core/src
parentcd5a90fb14bb8cb2276d9740925c9858ea507429 (diff)
parentf10da9f50ac7d083b2f5b2bc8b84c777ed411973 (diff)
downloadrust-24bbf7ac2fd6f5e71f5a4873baa4456e45bd648d.tar.gz
rust-24bbf7ac2fd6f5e71f5a4873baa4456e45bd648d.zip
Auto merge of #85272 - ChayimFriedman2:matches-leading-pipe, r=m-ou-se
Allow leading pipe in `matches!()` patterns.

This is allowed in `match` statement, and stated in https://internals.rust-lang.org/t/leading-pipe-in-core-matches/14699/2 that it should be allowed in these macros too.
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/macros/mod.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 8380116010b..87fdbf2dca3 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -140,7 +140,7 @@ macro_rules! assert_ne {
 #[allow_internal_unstable(core_panic)]
 #[rustc_macro_transparency = "semitransparent"]
 pub macro assert_matches {
-    ($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({
+    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({
         match $left {
             $( $pattern )|+ $( if $guard )? => {}
             ref left_val => {
@@ -152,7 +152,7 @@ pub macro assert_matches {
             }
         }
     }),
-    ($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
+    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
         match $left {
             $( $pattern )|+ $( if $guard )? => {}
             ref left_val => {
@@ -320,7 +320,7 @@ pub macro debug_assert_matches($($arg:tt)*) {
 #[macro_export]
 #[stable(feature = "matches_macro", since = "1.42.0")]
 macro_rules! matches {
-    ($expression:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
+    ($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
         match $expression {
             $( $pattern )|+ $( if $guard )? => true,
             _ => false