From 3b9732eae7560542c684cb0584e76946faaee0e9 Mon Sep 17 00:00:00 2001
From: Tobba <tobias.haegermarck@gmail.com>
Date: Sun, 28 Sep 2014 02:00:13 +0200
Subject: [PATCH] Defailbloat fail!(&'static str)

---
 src/libcore/failure.rs | 11 +++++------
 src/libcore/macros.rs  |  4 ++--
 src/libcore/option.rs  |  2 +-
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs
index f5f45b2f72e..a053c5a839d 100644
--- a/src/libcore/failure.rs
+++ b/src/libcore/failure.rs
@@ -33,6 +33,10 @@
 use fmt;
 use intrinsics;
 
+// NOTE: remove after next snapshot
+#[cfg(stage0)]
+pub use self::fail_ as fail;
+
 // NOTE: remove after next snapshot
 #[cfg(stage0)]
 #[cold] #[inline(never)] // this is the slow path, always
@@ -50,7 +54,7 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
 #[cfg(not(stage0))]
 #[cold] #[inline(never)] // this is the slow path, always
 #[lang="fail"]
-fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
+pub fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
     let (expr, file, line) = *expr_file_line;
     let ref file_line = (file, line);
     format_args!(|args| -> () {
@@ -70,11 +74,6 @@ fn fail_bounds_check(file_line: &(&'static str, uint),
     unsafe { intrinsics::abort() }
 }
 
-#[cold] #[inline(never)]
-pub fn fail_str(msg: &str, file: &(&'static str, uint)) -> ! {
-    format_args!(|fmt| fail_fmt(fmt, file), "{}", msg)
-}
-
 #[cold] #[inline(never)]
 pub fn fail_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
     #[allow(ctypes)]
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 0f972a67029..17fcf025457 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -17,8 +17,8 @@ macro_rules! fail(
         fail!("{}", "explicit failure")
     );
     ($msg:expr) => ({
-        static _FILE_LINE: (&'static str, uint) = (file!(), line!());
-        ::core::failure::fail_str($msg, &_FILE_LINE)
+        static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!());
+        ::core::failure::fail(&_MSG_FILE_LINE)
     });
     ($fmt:expr, $($arg:tt)*) => ({
         // a closure can't have return type !, so we need a full
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 77fe55aadee..1e353708730 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -312,7 +312,7 @@ impl<T> Option<T> {
     pub fn expect(self, msg: &str) -> T {
         match self {
             Some(val) => val,
-            None => fail!(msg),
+            None => fail!("{}", msg),
         }
     }