auto merge of #16886 : Tobba/rust/defailbloat-string, r=alexcrichton

by not performing formatting at the failure site

This cuts about 673382 bytes from libcore.rlib
This commit is contained in:
bors 2014-09-01 14:56:08 +00:00
commit eb7589a188
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