Skip to content

Commit

Permalink
Resolve semicolon_in_expressions_from_macros warning in serde_test
Browse files Browse the repository at this point in the history
    warning: trailing semicolon in macro used in expression position
       --> serde_test/src/ser.rs:44:10
        |
    44  |         );
        |          ^
    ...
    152 |             Some(&Token::BorrowedStr(_)) => assert_next_token!(self, BorrowedStr(v)),
        |                                             ---------------------------------------- in this macro invocation
        |
        = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: this warning originates in the macro `assert_next_token` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: trailing semicolon in macro used in expression position
       --> serde_test/src/ser.rs:36:76
        |
    36  |         assert_next_token!($ser, stringify!($actual), Token::$actual, true);
        |                                                                            ^
    ...
    386 |             Token::TupleVariantEnd => assert_next_token!(self.ser, TupleVariantEnd),
        |                                       --------------------------------------------- in this macro invocation
        |
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: this warning originates in the macro `assert_next_token` (in Nightly builds, run with -Z macro-backtrace for more info)
  • Loading branch information
dtolnay committed Jul 31, 2021
1 parent 9c39115 commit 8b840c3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions serde_test/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ impl<'a> Serializer<'a> {
}

macro_rules! assert_next_token {
($ser:expr, $actual:ident) => {
($ser:expr, $actual:ident) => {{
assert_next_token!($ser, stringify!($actual), Token::$actual, true);
};
($ser:expr, $actual:ident($v:expr)) => {
}};
($ser:expr, $actual:ident($v:expr)) => {{
assert_next_token!(
$ser,
format_args!(concat!(stringify!($actual), "({:?})"), $v),
Token::$actual(v),
v == $v
);
};
($ser:expr, $actual:ident { $($k:ident),* }) => {
}};
($ser:expr, $actual:ident { $($k:ident),* }) => {{
let compare = ($($k,)*);
let field_format = || {
use std::fmt::Write;
Expand All @@ -59,7 +59,7 @@ macro_rules! assert_next_token {
Token::$actual { $($k),* },
($($k,)*) == compare
);
};
}};
($ser:expr, $actual:expr, $pat:pat, $guard:expr) => {
match $ser.next_token() {
Some($pat) if $guard => {}
Expand Down

0 comments on commit 8b840c3

Please sign in to comment.