about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-09-01 14:56:08 +0000
committerbors <bors@rust-lang.org>2014-09-01 14:56:08 +0000
commiteb7589a1881e7a649cb7c23e973f01a60aac78b3 (patch)
tree22edabb1b6adb9782fc671cce374434757d53161
parentb42e079c6f6445b4e2adfaf9a30e8a06403f75c8 (diff)
parente676b73d64899b1b619e81b2cb760ed658c02e8b (diff)
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
-rw-r--r--src/libcore/failure.rs5
-rw-r--r--src/libcore/macros.rs7
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