diff options
| author | bors <bors@rust-lang.org> | 2013-03-19 15:43:02 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-19 15:43:02 -0700 |
| commit | bc211f5032dc6ca5650b2c8f437ecfd425ddfccd (patch) | |
| tree | 01f95030ad673bfbcdc3db2a599838d72b4a9678 /src | |
| parent | 5ae76b5babc48ff8d9ef76cd03da4836d3c74c64 (diff) | |
| parent | 14df8447445440794d363f6dc3fbb5220bb0a775 (diff) | |
| download | rust-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.rs | 5 | ||||
| -rw-r--r-- | src/test/run-fail/issue-2761.rs | 15 |
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"); +} |
