-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Reduce text size for fail invocations #15983
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
Changes from all commits
4636b32
f7ab07c
a43e7d5
cf7a89f
53f0eae
f49f157
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,12 +38,15 @@ | |
/// ``` | ||
#[macro_export] | ||
macro_rules! fail( | ||
() => ( | ||
::std::rt::begin_unwind_no_time_to_explain(file!(), line!()) | ||
); | ||
($msg:expr) => ( | ||
::std::rt::begin_unwind($msg, file!(), line!()) | ||
); | ||
() => ({ | ||
fail!("explicit failure") | ||
}); | ||
($msg:expr) => ({ | ||
// static requires less code at runtime, more constant data | ||
static FILE_LINE: (&'static str, uint) = (file!(), line!()); | ||
let (file, line) = FILE_LINE; | ||
::std::rt::begin_unwind($msg, file, line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems a little odd to have a static with the two together, but then it's immediately destructed? Is that because changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and I'm going to do a followup to make that change. |
||
}); | ||
($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 +61,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)*) | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally prefer to remove the special case of 0 arguments, I think that this change has much more impact than not moving the message into place for this fairly uncommon case of
fail!()