mirror of
https://github.com/openharmony/third_party_rust_rust-std-candidates.git
synced 2026-06-30 20:47:55 -04:00
Remove "tt as expr" macro hack, unneeded since Rust 1.12
Whether increasing the minimum required Rust version is a SemVer breaking change that should be reflected in the crate’s version number is arguable. I chose not to do this here, since 1.12 has been stable for almost two years (2016-09-29) so I expect the impact to be negligible.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
sudo: false
|
||||
language: rust
|
||||
rust:
|
||||
- 1.8.0
|
||||
- 1.12.0
|
||||
- nightly
|
||||
- beta
|
||||
- stable
|
||||
|
||||
+6
-17
@@ -30,22 +30,13 @@
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! matches {
|
||||
($expression:expr, $($pattern:tt)+) => {
|
||||
_matches_tt_as_expr_hack! {
|
||||
match $expression {
|
||||
$($pattern)+ => true,
|
||||
_ => false
|
||||
}
|
||||
match $expression {
|
||||
$($pattern)+ => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Work around "error: unexpected token: `an interpolated tt`", whatever that means.
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! _matches_tt_as_expr_hack {
|
||||
($value:expr) => ($value)
|
||||
}
|
||||
|
||||
/// Assert that an expression matches a refutable pattern.
|
||||
///
|
||||
/// Syntax: `assert_matches!(` *expression* `,` *pattern* `)`
|
||||
@@ -67,11 +58,9 @@ macro_rules! _matches_tt_as_expr_hack {
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! assert_matches {
|
||||
($expression:expr, $($pattern:tt)+) => {
|
||||
_matches_tt_as_expr_hack! {
|
||||
match $expression {
|
||||
$($pattern)+ => (),
|
||||
ref e => panic!("assertion failed: `{:?}` does not match `{}`", e, stringify!($($pattern)+)),
|
||||
}
|
||||
match $expression {
|
||||
$($pattern)+ => (),
|
||||
ref e => panic!("assertion failed: `{:?}` does not match `{}`", e, stringify!($($pattern)+)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user