about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-19 15:43:02 -0700
committerbors <bors@rust-lang.org>2013-03-19 15:43:02 -0700
commitbc211f5032dc6ca5650b2c8f437ecfd425ddfccd (patch)
tree01f95030ad673bfbcdc3db2a599838d72b4a9678 /src
parent5ae76b5babc48ff8d9ef76cd03da4836d3c74c64 (diff)
parent14df8447445440794d363f6dc3fbb5220bb0a775 (diff)
downloadrust-bc211f5032dc6ca5650b2c8f437ecfd425ddfccd.tar.gz
rust-bc211f5032dc6ca5650b2c8f437ecfd425ddfccd.zip
auto merge of #5436 : alexcrichton/rust/assert-message, r=pcwalton
This would close #2761. I figured that if you're supplying your own custom message, you probably don't mind the stringification of the condition to not be in the message.
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax/ext/expand.rs5
-rw-r--r--src/test/run-fail/issue-2761.rs15
2 files changed, 20 insertions, 0 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index ec693fa1f08..ad05e2f21e6 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -456,6 +456,11 @@ pub fn core_macros() -> ~str {
             if !$cond {
                 ::core::sys::fail_assert(stringify!($cond), file!(), line!())
             }
+        };
+        ($cond:expr, $msg:expr) => {
+            if !$cond {
+                ::core::sys::fail_assert($msg, file!(), line!())
+            }
         }
     )
 
diff --git a/src/test/run-fail/issue-2761.rs b/src/test/run-fail/issue-2761.rs
new file mode 100644
index 00000000000..cf35d9624f3
--- /dev/null
+++ b/src/test/run-fail/issue-2761.rs
@@ -0,0 +1,15 @@
+// Copyright 2013 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.
+
+// error-pattern:custom message
+
+fn main() {
+    fail_unless!(false, "custom message");
+}