38
38
/// ```
39
39
#[ macro_export]
40
40
macro_rules! fail(
41
- ( ) => (
42
- :: std:: rt:: begin_unwind_no_time_to_explain( & ( file!( ) , line!( ) ) )
43
- ) ;
44
- ( $msg: expr) => (
45
- :: std:: rt:: begin_unwind( $msg, file!( ) , line!( ) )
46
- ) ;
41
+ ( ) => ( {
42
+ // static requires less code at runtime, more constant data
43
+ static file_line: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
44
+ :: std:: rt:: begin_unwind_no_time_to_explain( & file_line)
45
+ } ) ;
46
+ ( $msg: expr) => ( {
47
+ static file_line: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
48
+ let ( file, line) = file_line;
49
+ :: std:: rt:: begin_unwind( $msg, file, line)
50
+ } ) ;
47
51
( $fmt: expr, $( $arg: tt) * ) => ( {
48
52
// a closure can't have return type !, so we need a full
49
53
// function to pass to format_args!, *and* we need the
@@ -58,7 +62,8 @@ macro_rules! fail(
58
62
// up with the number of calls to fail!()
59
63
#[ inline( always) ]
60
64
fn run_fmt( fmt: & :: std:: fmt:: Arguments ) -> ! {
61
- :: std:: rt:: begin_unwind_fmt( fmt, & ( file!( ) , line!( ) ) )
65
+ static file_line: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
66
+ :: std:: rt:: begin_unwind_fmt( fmt, & file_line)
62
67
}
63
68
format_args!( run_fmt, $fmt, $( $arg) * )
64
69
} ) ;
0 commit comments