1
Fork 0

Defailbloat fail!(string)

This commit is contained in:
Tobba 2014-08-30 20:38:47 +02:00
parent cbacdbc5f3
commit e676b73d64
2 changed files with 9 additions and 3 deletions

View file

@ -55,6 +55,11 @@ fn fail_bounds_check(file_line: &(&'static str, uint),
unsafe { intrinsics::abort() }
}
#[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)]

View file

@ -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