Skip to content

Commit eb7589a

Browse files
committed
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
2 parents b42e079 + e676b73 commit eb7589a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/libcore/failure.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ fn fail_bounds_check(file_line: &(&'static str, uint),
5555
unsafe { intrinsics::abort() }
5656
}
5757

58+
#[cold] #[inline(never)]
59+
pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! {
60+
format_args!(|fmt| begin_unwind(fmt, file), "{}", msg)
61+
}
62+
5863
#[cold] #[inline(never)]
5964
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
6065
#[allow(ctypes)]

src/libcore/macros.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ macro_rules! fail(
1616
() => (
1717
fail!("{}", "explicit failure")
1818
);
19-
($msg:expr) => (
20-
fail!("{}", $msg)
21-
);
19+
($msg:expr) => ({
20+
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
21+
::core::failure::begin_unwind_string($msg, &_FILE_LINE)
22+
});
2223
($fmt:expr, $($arg:tt)*) => ({
2324
// a closure can't have return type !, so we need a full
2425
// function to pass to format_args!, *and* we need the

0 commit comments

Comments
 (0)