Skip to content

Commit 87ddb38

Browse files
committed
---
yaml --- r: 120390 b: refs/heads/dist-snap c: f2af4ca h: refs/heads/master v: v3
1 parent 7adf565 commit 87ddb38

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: c25556865205e6978e6bc9eb0e6d5e151e1a68d9
9+
refs/heads/dist-snap: f2af4ca3e65ebef040df633c9d563b579540898e
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/macros.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,29 @@
1414
#[macro_export]
1515
macro_rules! fail(
1616
() => (
17-
fail!("explicit failure")
17+
fail!("{}", "explicit failure")
1818
);
1919
($msg:expr) => (
20-
::core::failure::begin_unwind($msg, file!(), line!())
20+
fail!("{}", $msg)
2121
);
22+
($fmt:expr, $($arg:tt)*) => ({
23+
// a closure can't have return type !, so we need a full
24+
// function to pass to format_args!, *and* we need the
25+
// file and line numbers right here; so an inner bare fn
26+
// is our only choice.
27+
//
28+
// LLVM doesn't tend to inline this, presumably because begin_unwind_fmt
29+
// is #[cold] and #[inline(never)] and because this is flagged as cold
30+
// as returning !. We really do want this to be inlined, however,
31+
// because it's just a tiny wrapper. Small wins (156K to 149K in size)
32+
// were seen when forcing this to be inlined, and that number just goes
33+
// up with the number of calls to fail!()
34+
#[inline(always)]
35+
fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
36+
::core::failure::begin_unwind(fmt, file!(), line!())
37+
}
38+
format_args!(run_fmt, $fmt, $($arg)*)
39+
});
2240
)
2341

2442
/// Runtime assertion, for details see std::macros
@@ -29,6 +47,11 @@ macro_rules! assert(
2947
fail!(concat!("assertion failed: ", stringify!($cond)))
3048
}
3149
);
50+
($cond:expr, $($arg:tt)*) => (
51+
if !$cond {
52+
fail!($($arg)*)
53+
}
54+
);
3255
)
3356

3457
/// Runtime assertion, disableable at compile time

0 commit comments

Comments
 (0)