Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow custom messages on assert statements

  • Loading branch information...
commit 14df8447445440794d363f6dc3fbb5220bb0a775 1 parent e67448d
@alexcrichton alexcrichton authored
Showing with 20 additions and 0 deletions.
  1. +5 −0 src/libsyntax/ext/expand.rs
  2. +15 −0 src/test/run-fail/issue-2761.rs
View
5 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!())
+ }
}
)
View
15 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");
+}

5 comments on commit 14df844

@bors
Collaborator

saw approval from pcwalton
at alexcrichton@14df844

@bors
Collaborator

merging alexcrichton/rust/assert-message = 14df844 into auto

@bors
Collaborator

alexcrichton/rust/assert-message = 14df844 merged ok, testing candidate = bc211f5

@bors
Collaborator

fast-forwarding incoming to auto = bc211f5

Please sign in to comment.
Something went wrong with that request. Please try again.