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:
Simon Sapin
2018-08-22 14:31:14 +02:00
parent bbd6be3989
commit eb086f8d76
2 changed files with 7 additions and 18 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
sudo: false
language: rust
rust:
- 1.8.0
- 1.12.0
- nightly
- beta
- stable
+6 -17
View File
@@ -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)+)),
}
}
}