Defailbloat fail!(&'static str)
This commit is contained in:
parent
9a68da7401
commit
3b9732eae7
@ -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)]
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user