1
Fork 0

fix matches! and assert_matches! on edition 2021

This commit is contained in:
Lukas Markeffsky 2021-05-25 16:44:20 +02:00
parent fbf1b1a719
commit 3ed90e2424
2 changed files with 4 additions and 3 deletions

View file

@ -138,7 +138,7 @@ macro_rules! assert_ne {
#[unstable(feature = "assert_matches", issue = "82775")]
#[allow_internal_unstable(core_panic)]
macro_rules! assert_matches {
($left:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => ({
($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({
match $left {
$( $pattern )|+ $( if $guard )? => {}
ref left_val => {
@ -150,7 +150,7 @@ macro_rules! assert_matches {
}
}
});
($left:expr, $( $pattern:pat )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
match $left {
$( $pattern )|+ $( if $guard )? => {}
ref left_val => {
@ -315,7 +315,7 @@ macro_rules! debug_assert_matches {
#[macro_export]
#[stable(feature = "matches_macro", since = "1.42.0")]
macro_rules! matches {
($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => {
($expression:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
match $expression {
$( $pattern )|+ $( if $guard )? => true,
_ => false