From 6a92c0fdbddbda6fcb0c6215f64240d228e4b2f5 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Thu, 9 Nov 2017 12:36:38 +0100 Subject: [PATCH] Allow a trailing comma in assert_eq/ne macro --- src/libcore/macros.rs | 6 ++++++ .../assert-eq-trailing-comma.rs} | 0 .../assert-ne-trailing-comma.rs} | 0 src/test/ui/macros/assert_eq_trailing_comma.stderr | 8 -------- src/test/ui/macros/assert_ne_trailing_comma.stderr | 8 -------- 5 files changed, 6 insertions(+), 16 deletions(-) rename src/test/{ui/macros/assert_eq_trailing_comma.rs => run-pass/assert-eq-trailing-comma.rs} (100%) rename src/test/{ui/macros/assert_ne_trailing_comma.rs => run-pass/assert-ne-trailing-comma.rs} (100%) delete mode 100644 src/test/ui/macros/assert_eq_trailing_comma.stderr delete mode 100644 src/test/ui/macros/assert_ne_trailing_comma.stderr diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 12667036444e6..c410c2d900470 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -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) => { @@ -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) => { diff --git a/src/test/ui/macros/assert_eq_trailing_comma.rs b/src/test/run-pass/assert-eq-trailing-comma.rs similarity index 100% rename from src/test/ui/macros/assert_eq_trailing_comma.rs rename to src/test/run-pass/assert-eq-trailing-comma.rs diff --git a/src/test/ui/macros/assert_ne_trailing_comma.rs b/src/test/run-pass/assert-ne-trailing-comma.rs similarity index 100% rename from src/test/ui/macros/assert_ne_trailing_comma.rs rename to src/test/run-pass/assert-ne-trailing-comma.rs diff --git a/src/test/ui/macros/assert_eq_trailing_comma.stderr b/src/test/ui/macros/assert_eq_trailing_comma.stderr deleted file mode 100644 index 1b46e94584e6b..0000000000000 --- a/src/test/ui/macros/assert_eq_trailing_comma.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unexpected end of macro invocation - --> $DIR/assert_eq_trailing_comma.rs:12:20 - | -12 | assert_eq!(1, 1,); - | ^ - -error: aborting due to previous error - diff --git a/src/test/ui/macros/assert_ne_trailing_comma.stderr b/src/test/ui/macros/assert_ne_trailing_comma.stderr deleted file mode 100644 index 33d2cb0ed8242..0000000000000 --- a/src/test/ui/macros/assert_ne_trailing_comma.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unexpected end of macro invocation - --> $DIR/assert_ne_trailing_comma.rs:12:20 - | -12 | assert_ne!(1, 2,); - | ^ - -error: aborting due to previous error -