about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-23 01:53:38 +0000
committerbors <bors@rust-lang.org>2015-02-23 01:53:38 +0000
commitf0f7ca27de6b4e03f30012656dad270cda55a363 (patch)
tree862b2d4252579c51278661075d8d0cf1f4149dcd /src/libcore
parent67eb38ee4cfd7b28f8498b5b6492da172768dcb9 (diff)
parentfc9fa1a563c48cc928c8c5754597ffba6f53a635 (diff)
downloadrust-f0f7ca27de6b4e03f30012656dad270cda55a363.tar.gz
rust-f0f7ca27de6b4e03f30012656dad270cda55a363.zip
Auto merge of #21769 - brooksbp:column-line-macro, r=nick29581
Please see discussion in #19284 .
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/macros.rs6
-rw-r--r--src/libcore/panicking.rs39
2 files changed, 40 insertions, 5 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 943365d8454..92d50821592 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -15,7 +15,10 @@ macro_rules! panic {
         panic!("explicit panic")
     );
     ($msg:expr) => ({
+        #[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)*) => ({
@@ -23,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.
+        #[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) }
 }