Skip to content

Commit

Permalink
Rollup merge of rust-lang#45887 - xfix:assert-eq-trailling-comma, r=d…
Browse files Browse the repository at this point in the history
…tolnay

Allow a trailling comma in assert_eq/ne macro

From Rust beginners IRC:

<???> It sure does annoy me that assert_eq!() does not accept a trailing comma after the last argument.
<???> ???: File an issue against https://github.com/rust-lang/rust and CC @rust-lang/libs

Figured that might as well submit it. Will become insta-stable after merging (danger zone).

cc @rust-lang/libs
  • Loading branch information
kennytm authored Nov 10, 2017
2 parents 20e11db + 6a92c0f commit 253d18e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ macro_rules! assert_eq {
}
}
});
($left:expr, $right:expr,) => ({
assert_eq!($left, $right)
});
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
Expand Down Expand Up @@ -168,6 +171,9 @@ macro_rules! assert_ne {
}
}
});
($left:expr, $right:expr,) => {
assert_ne!($left, $right)
};
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
Expand Down
8 changes: 0 additions & 8 deletions src/test/ui/macros/assert_eq_trailing_comma.stderr

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/ui/macros/assert_ne_trailing_comma.stderr

This file was deleted.

0 comments on commit 253d18e

Please sign in to comment.