Skip to content

Commit

Permalink
Defailbloat fail!(string)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobba committed Aug 30, 2014
1 parent cbacdbc commit e676b73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/libcore/failure.rs
Expand Up @@ -55,6 +55,11 @@ fn fail_bounds_check(file_line: &(&'static str, uint),
unsafe { intrinsics::abort() }
}

#[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)]
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/macros.rs
Expand Up @@ -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
Expand Down

5 comments on commit e676b73

@bors
Copy link
Contributor

@bors bors commented on e676b73 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Tobba@e676b73

@bors
Copy link
Contributor

@bors bors commented on e676b73 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Tobba/rust/defailbloat-string = e676b73 into auto

@bors
Copy link
Contributor

@bors bors commented on e676b73 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tobba/rust/defailbloat-string = e676b73 merged ok, testing candidate = eb7589a

@bors
Copy link
Contributor

@bors bors commented on e676b73 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = eb7589a

Please sign in to comment.