diff options
| author | Tobba <tobias.haegermarck@gmail.com> | 2014-08-30 20:38:47 +0200 |
|---|---|---|
| committer | Tobba <tobias.haegermarck@gmail.com> | 2014-08-30 20:38:47 +0200 |
| commit | e676b73d64899b1b619e81b2cb760ed658c02e8b (patch) | |
| tree | 45c3c2643fbdc45395ccdebf89a312bc220f9c51 | |
| parent | cbacdbc5f3bc4f401a96177df8efd2eb765e8799 (diff) | |
Defailbloat fail!(string)
| -rw-r--r-- | src/libcore/failure.rs | 5 | ||||
| -rw-r--r-- | src/libcore/macros.rs | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs index e764ae17500..ac162c206c6 100644 --- a/src/libcore/failure.rs +++ b/src/libcore/failure.rs @@ -56,6 +56,11 @@ fn fail_bounds_check(file_line: &(&'static str, uint), } #[cold] #[inline(never)] +pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! { + format_args!(|fmt| begin_unwind(fmt, file), "{}", msg) +} + +#[cold] #[inline(never)] pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { #[allow(ctypes)] extern { diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index c80d1ed3451..e846f8dbeb4 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -16,9 +16,10 @@ macro_rules! fail( () => ( fail!("{}", "explicit failure") ); - ($msg:expr) => ( - fail!("{}", $msg) - ); + ($msg:expr) => ({ + static _FILE_LINE: (&'static str, uint) = (file!(), line!()); + ::core::failure::begin_unwind_string($msg, &_FILE_LINE) + }); ($fmt:expr, $($arg:tt)*) => ({ // a closure can't have return type !, so we need a full // function to pass to format_args!, *and* we need the |
