diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-03-19 14:05:20 -0400 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-03-19 14:07:00 -0400 |
| commit | 14df8447445440794d363f6dc3fbb5220bb0a775 (patch) | |
| tree | b8264812a5cf54e80ed544106c0492b9404fdb7f | |
| parent | e67448d397ed8f468170d6fba95ceae081ece624 (diff) | |
| download | rust-14df8447445440794d363f6dc3fbb5220bb0a775.tar.gz rust-14df8447445440794d363f6dc3fbb5220bb0a775.zip | |
Allow custom messages on assert statements
| -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"); +} |
