Skip to content

Commit 0011db6

Browse files
committed
---
yaml --- r: 151741 b: refs/heads/try2 c: f2af4ca h: refs/heads/master i: 151739: c74db03 v: v3
1 parent 74950b0 commit 0011db6

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c25556865205e6978e6bc9eb0e6d5e151e1a68d9
8+
refs/heads/try2: f2af4ca3e65ebef040df633c9d563b579540898e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)