Skip to content

Defailbloat fail!(&'static str) #17602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/libcore/failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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| -> () {
Expand All @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down