diff options
| author | Brian Brooks <brooks.brian@gmail.com> | 2015-02-21 17:26:29 -0500 |
|---|---|---|
| committer | Brian Brooks <brooks.brian@gmail.com> | 2015-02-21 17:26:29 -0500 |
| commit | fc9fa1a563c48cc928c8c5754597ffba6f53a635 (patch) | |
| tree | c8b6dce437b1f392a9508ffa32b4538c553794b7 /src/libcore | |
| parent | 1212fd8abc7602f6c506c936908a799c76549a14 (diff) | |
| download | rust-fc9fa1a563c48cc928c8c5754597ffba6f53a635.tar.gz rust-fc9fa1a563c48cc928c8c5754597ffba6f53a635.zip | |
Resolve barriers to changing column!() / line!() return type to u32 in #19284 . Address review comments in #21769 .
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/macros.rs | 11 | ||||
| -rw-r--r-- | src/libcore/panicking.rs | 39 |
2 files changed, 42 insertions, 8 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index d02ed7c2538..92d50821592 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -15,8 +15,10 @@ macro_rules! panic { panic!("explicit panic") ); ($msg:expr) => ({ - static _MSG_FILE_LINE: (&'static str, &'static str, usize) = - ($msg, file!(), line!() as usize); + #[cfg(stage0)] + static _MSG_FILE_LINE: (&'static str, &'static str, usize) = ($msg, file!(), line!()); + #[cfg(not(stage0))] + static _MSG_FILE_LINE: (&'static str, &'static str, u32) = ($msg, file!(), line!()); ::core::panicking::panic(&_MSG_FILE_LINE) }); ($fmt:expr, $($arg:tt)*) => ({ @@ -24,7 +26,10 @@ macro_rules! panic { // used inside a dead function. Just `#[allow(dead_code)]` is // insufficient, since the user may have // `#[forbid(dead_code)]` and which cannot be overridden. - static _FILE_LINE: (&'static str, usize) = (file!(), line!() as usize); + #[cfg(stage0)] + static _FILE_LINE: (&'static str, usize) = (file!(), line!()); + #[cfg(not(stage0))] + static _FILE_LINE: (&'static str, u32) = (file!(), line!()); ::core::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE) }); } diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 61b4284e1dd..168dcf4978c 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -34,26 +34,55 @@ use fmt; #[cold] #[inline(never)] // this is the slow path, always #[lang="panic"] -pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { +#[cfg(stage0)] +pub fn panic(expr_file_line: &(&'static str, &'static str, usize)) -> ! { + let (expr, file, line) = *expr_file_line; + panic_fmt(format_args!("{}", expr), &(file, line)) +} +#[cold] #[inline(never)] // this is the slow path, always +#[lang="panic"] +#[cfg(not(stage0))] +pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! { let (expr, file, line) = *expr_file_line; panic_fmt(format_args!("{}", expr), &(file, line)) } #[cold] #[inline(never)] #[lang="panic_bounds_check"] -fn panic_bounds_check(file_line: &(&'static str, uint), - index: uint, len: uint) -> ! { +#[cfg(stage0)] +fn panic_bounds_check(file_line: &(&'static str, usize), + index: usize, len: usize) -> ! { + panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}", + len, index), file_line) +} +#[cold] #[inline(never)] +#[lang="panic_bounds_check"] +#[cfg(not(stage0))] +fn panic_bounds_check(file_line: &(&'static str, u32), + index: usize, len: usize) -> ! { panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}", len, index), file_line) } #[cold] #[inline(never)] -pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, uint)) -> ! { +#[cfg(stage0)] +pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, usize)) -> ! { + #[allow(improper_ctypes)] + extern { + #[lang = "panic_fmt"] + fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: uint) -> !; + } + let (file, line) = *file_line; + unsafe { panic_impl(fmt, file, line as uint) } +} +#[cold] #[inline(never)] +#[cfg(not(stage0))] +pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> ! { #[allow(improper_ctypes)] extern { #[lang = "panic_fmt"] fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: uint) -> !; } let (file, line) = *file_line; - unsafe { panic_impl(fmt, file, line) } + unsafe { panic_impl(fmt, file, line as uint) } } |
