about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/macros.rs12
-rw-r--r--src/test/ui/macros/assert_eq_trailing_comma.rs13
-rw-r--r--src/test/ui/macros/assert_eq_trailing_comma.stderr6
-rw-r--r--src/test/ui/macros/assert_ne_trailing_comma.rs13
-rw-r--r--src/test/ui/macros/assert_ne_trailing_comma.stderr6
5 files changed, 44 insertions, 6 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index bc5392f6b88..66a923f8e58 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -103,7 +103,7 @@ macro_rules! assert {
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! assert_eq {
-    ($left:expr , $right:expr) => ({
+    ($left:expr, $right:expr) => ({
         match (&$left, &$right) {
             (left_val, right_val) => {
                 if !(*left_val == *right_val) {
@@ -113,13 +113,13 @@ macro_rules! assert_eq {
             }
         }
     });
-    ($left:expr , $right:expr, $($arg:tt)*) => ({
+    ($left:expr, $right:expr, $($arg:tt)+) => ({
         match (&($left), &($right)) {
             (left_val, right_val) => {
                 if !(*left_val == *right_val) {
                     panic!("assertion failed: `(left == right)` \
                            (left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
-                           format_args!($($arg)*))
+                           format_args!($($arg)+))
                 }
             }
         }
@@ -146,7 +146,7 @@ macro_rules! assert_eq {
 #[macro_export]
 #[stable(feature = "assert_ne", since = "1.12.0")]
 macro_rules! assert_ne {
-    ($left:expr , $right:expr) => ({
+    ($left:expr, $right:expr) => ({
         match (&$left, &$right) {
             (left_val, right_val) => {
                 if *left_val == *right_val {
@@ -156,13 +156,13 @@ macro_rules! assert_ne {
             }
         }
     });
-    ($left:expr , $right:expr, $($arg:tt)*) => ({
+    ($left:expr, $right:expr, $($arg:tt)+) => ({
         match (&($left), &($right)) {
             (left_val, right_val) => {
                 if *left_val == *right_val {
                     panic!("assertion failed: `(left != right)` \
                            (left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
-                           format_args!($($arg)*))
+                           format_args!($($arg)+))
                 }
             }
         }
diff --git a/src/test/ui/macros/assert_eq_trailing_comma.rs b/src/test/ui/macros/assert_eq_trailing_comma.rs
new file mode 100644
index 00000000000..d98baf640a8
--- /dev/null
+++ b/src/test/ui/macros/assert_eq_trailing_comma.rs
@@ -0,0 +1,13 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    assert_eq!(1, 1,);
+}
diff --git a/src/test/ui/macros/assert_eq_trailing_comma.stderr b/src/test/ui/macros/assert_eq_trailing_comma.stderr
new file mode 100644
index 00000000000..ca590db90e4
--- /dev/null
+++ b/src/test/ui/macros/assert_eq_trailing_comma.stderr
@@ -0,0 +1,6 @@
+error: unexpected end of macro invocation
+  --> $DIR/assert_eq_trailing_comma.rs:12:20
+   |
+12 |     assert_eq!(1, 1,);
+   |                    ^
+
diff --git a/src/test/ui/macros/assert_ne_trailing_comma.rs b/src/test/ui/macros/assert_ne_trailing_comma.rs
new file mode 100644
index 00000000000..4d3c29da8b2
--- /dev/null
+++ b/src/test/ui/macros/assert_ne_trailing_comma.rs
@@ -0,0 +1,13 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    assert_ne!(1, 2,);
+}
diff --git a/src/test/ui/macros/assert_ne_trailing_comma.stderr b/src/test/ui/macros/assert_ne_trailing_comma.stderr
new file mode 100644
index 00000000000..ffabcaeb049
--- /dev/null
+++ b/src/test/ui/macros/assert_ne_trailing_comma.stderr
@@ -0,0 +1,6 @@
+error: unexpected end of macro invocation
+  --> $DIR/assert_ne_trailing_comma.rs:12:20
+   |
+12 |     assert_ne!(1, 2,);
+   |                    ^
+