Skip to content

Commit 253d18e

Browse files
authored
Rollup merge of rust-lang#45887 - xfix:assert-eq-trailling-comma, r=dtolnay
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
2 parents 20e11db + 6a92c0f commit 253d18e

File tree

5 files changed

+6
-16
lines changed

5 files changed

+6
-16
lines changed

src/libcore/macros.rs

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ macro_rules! assert_eq {
120120
}
121121
}
122122
});
123+
($left:expr, $right:expr,) => ({
124+
assert_eq!($left, $right)
125+
});
123126
($left:expr, $right:expr, $($arg:tt)+) => ({
124127
match (&($left), &($right)) {
125128
(left_val, right_val) => {
@@ -168,6 +171,9 @@ macro_rules! assert_ne {
168171
}
169172
}
170173
});
174+
($left:expr, $right:expr,) => {
175+
assert_ne!($left, $right)
176+
};
171177
($left:expr, $right:expr, $($arg:tt)+) => ({
172178
match (&($left), &($right)) {
173179
(left_val, right_val) => {

src/test/ui/macros/assert_eq_trailing_comma.stderr

-8
This file was deleted.

src/test/ui/macros/assert_ne_trailing_comma.stderr

-8
This file was deleted.

0 commit comments

Comments
 (0)