Skip to content

Commit 3b9732e

Browse files
committed
Defailbloat fail!(&'static str)
1 parent 9a68da7 commit 3b9732e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/libcore/failure.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
use fmt;
3434
use intrinsics;
3535

36+
// NOTE: remove after next snapshot
37+
#[cfg(stage0)]
38+
pub use self::fail_ as fail;
39+
3640
// NOTE: remove after next snapshot
3741
#[cfg(stage0)]
3842
#[cold] #[inline(never)] // this is the slow path, always
@@ -50,7 +54,7 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
5054
#[cfg(not(stage0))]
5155
#[cold] #[inline(never)] // this is the slow path, always
5256
#[lang="fail"]
53-
fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
57+
pub fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
5458
let (expr, file, line) = *expr_file_line;
5559
let ref file_line = (file, line);
5660
format_args!(|args| -> () {
@@ -70,11 +74,6 @@ fn fail_bounds_check(file_line: &(&'static str, uint),
7074
unsafe { intrinsics::abort() }
7175
}
7276

73-
#[cold] #[inline(never)]
74-
pub fn fail_str(msg: &str, file: &(&'static str, uint)) -> ! {
75-
format_args!(|fmt| fail_fmt(fmt, file), "{}", msg)
76-
}
77-
7877
#[cold] #[inline(never)]
7978
pub fn fail_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
8079
#[allow(ctypes)]

src/libcore/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ macro_rules! fail(
1717
fail!("{}", "explicit failure")
1818
);
1919
($msg:expr) => ({
20-
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
21-
::core::failure::fail_str($msg, &_FILE_LINE)
20+
static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!());
21+
::core::failure::fail(&_MSG_FILE_LINE)
2222
});
2323
($fmt:expr, $($arg:tt)*) => ({
2424
// a closure can't have return type !, so we need a full

src/libcore/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<T> Option<T> {
312312
pub fn expect(self, msg: &str) -> T {
313313
match self {
314314
Some(val) => val,
315-
None => fail!(msg),
315+
None => fail!("{}", msg),
316316
}
317317
}
318318

0 commit comments

Comments
 (0)