diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index e2709c4edde47..26bb69943f8a5 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -33,7 +33,8 @@ macro_rules! fail( // up with the number of calls to fail!() #[inline(always)] fn run_fmt(fmt: &::std::fmt::Arguments) -> ! { - ::core::failure::begin_unwind(fmt, &(file!(), line!())) + static file_line: (&'static str, uint) = (file!(), line!()); + ::core::failure::begin_unwind(fmt, &file_line) } format_args!(run_fmt, $fmt, $($arg)*) }); diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index fd0c72ce313ee..9ce142836cf60 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -38,12 +38,16 @@ /// ``` #[macro_export] macro_rules! fail( - () => ( - ::std::rt::begin_unwind_no_time_to_explain(&(file!(), line!())) - ); - ($msg:expr) => ( - ::std::rt::begin_unwind($msg, file!(), line!()) - ); + () => ({ + // static requires less code at runtime, more constant data + static file_line: (&'static str, uint) = (file!(), line!()); + ::std::rt::begin_unwind_no_time_to_explain(&file_line) + }); + ($msg:expr) => ({ + static file_line: (&'static str, uint) = (file!(), line!()); + let (file, line) = file_line; + ::std::rt::begin_unwind($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 @@ -58,7 +62,8 @@ macro_rules! fail( // up with the number of calls to fail!() #[inline(always)] fn run_fmt(fmt: &::std::fmt::Arguments) -> ! { - ::std::rt::begin_unwind_fmt(fmt, &(file!(), line!())) + static file_line: (&'static str, uint) = (file!(), line!()); + ::std::rt::begin_unwind_fmt(fmt, &file_line) } format_args!(run_fmt, $fmt, $($arg)*) });