fix matches! and assert_matches! on edition 2021
This commit is contained in:
parent
fbf1b1a719
commit
3ed90e2424
2 changed files with 4 additions and 3 deletions
|
@ -168,6 +168,7 @@
|
||||||
#![feature(no_coverage)] // rust-lang/rust#84605
|
#![feature(no_coverage)] // rust-lang/rust#84605
|
||||||
#![feature(int_error_matching)]
|
#![feature(int_error_matching)]
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
#![deny(or_patterns_back_compat)]
|
||||||
|
|
||||||
// allow using `core::` in intra-doc links
|
// allow using `core::` in intra-doc links
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
|
|
|
@ -138,7 +138,7 @@ macro_rules! assert_ne {
|
||||||
#[unstable(feature = "assert_matches", issue = "82775")]
|
#[unstable(feature = "assert_matches", issue = "82775")]
|
||||||
#[allow_internal_unstable(core_panic)]
|
#[allow_internal_unstable(core_panic)]
|
||||||
macro_rules! assert_matches {
|
macro_rules! assert_matches {
|
||||||
($left:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => ({
|
($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({
|
||||||
match $left {
|
match $left {
|
||||||
$( $pattern )|+ $( if $guard )? => {}
|
$( $pattern )|+ $( if $guard )? => {}
|
||||||
ref left_val => {
|
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 {
|
match $left {
|
||||||
$( $pattern )|+ $( if $guard )? => {}
|
$( $pattern )|+ $( if $guard )? => {}
|
||||||
ref left_val => {
|
ref left_val => {
|
||||||
|
@ -315,7 +315,7 @@ macro_rules! debug_assert_matches {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "matches_macro", since = "1.42.0")]
|
#[stable(feature = "matches_macro", since = "1.42.0")]
|
||||||
macro_rules! matches {
|
macro_rules! matches {
|
||||||
($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => {
|
($expression:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
|
||||||
match $expression {
|
match $expression {
|
||||||
$( $pattern )|+ $( if $guard )? => true,
|
$( $pattern )|+ $( if $guard )? => true,
|
||||||
_ => false
|
_ => false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue