about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-09-25 05:17:31 +0000
committerbors <bors@rust-lang.org>2014-09-25 05:17:31 +0000
commit9ff308137afcacb4bc0d47e00d1dbb730229d932 (patch)
tree52985a732dcb1238b59d9e99a79e1d78c212172b /src/libcore
parent5e13d3aa00e8cfdf1a64f58f6c649460400231c0 (diff)
parentc8b767dd3d06fcabc2df753cbb9fd694ebc0eec6 (diff)
downloadrust-9ff308137afcacb4bc0d47e00d1dbb730229d932.tar.gz
rust-9ff308137afcacb4bc0d47e00d1dbb730229d932.zip
auto merge of #17428 : fhahn/rust/issue-16114-rename-begin-unwind-2, r=alexcrichton
This is a PR for #16114 and includes to following things:

* Rename `begin_unwind` lang item to `fail_fmt`
*  Rename `core::failure::begin_unwind` to `fail_impl`
* Rename `fail_` lang item to `fail`
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/failure.rs41
-rw-r--r--src/libcore/macros.rs4
2 files changed, 34 insertions, 11 deletions
diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs
index ac162c206c6..f5f45b2f72e 100644
--- a/src/libcore/failure.rs
+++ b/src/libcore/failure.rs
@@ -16,7 +16,7 @@
 //! interface for failure is:
 //!
 //! ```ignore
-//! fn begin_unwind(fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
+//! fn fail_impl(fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
 //! ```
 //!
 //! This definition allows for failing with any general message, but it does not
@@ -33,13 +33,28 @@
 use fmt;
 use intrinsics;
 
+// NOTE: remove after next snapshot
+#[cfg(stage0)]
 #[cold] #[inline(never)] // this is the slow path, always
 #[lang="fail_"]
 fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
     let (expr, file, line) = *expr_file_line;
     let ref file_line = (file, line);
     format_args!(|args| -> () {
-        begin_unwind(args, file_line);
+        fail_fmt(args, file_line);
+    }, "{}", expr);
+
+    unsafe { intrinsics::abort() }
+}
+
+#[cfg(not(stage0))]
+#[cold] #[inline(never)] // this is the slow path, always
+#[lang="fail"]
+fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
+    let (expr, file, line) = *expr_file_line;
+    let ref file_line = (file, line);
+    format_args!(|args| -> () {
+        fail_fmt(args, file_line);
     }, "{}", expr);
 
     unsafe { intrinsics::abort() }
@@ -50,25 +65,33 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
 fn fail_bounds_check(file_line: &(&'static str, uint),
                      index: uint, len: uint) -> ! {
     format_args!(|args| -> () {
-        begin_unwind(args, file_line);
+        fail_fmt(args, file_line);
     }, "index out of bounds: the len is {} but the index is {}", len, index);
     unsafe { intrinsics::abort() }
 }
 
 #[cold] #[inline(never)]
-pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! {
-    format_args!(|fmt| begin_unwind(fmt, file), "{}", msg)
+pub fn fail_str(msg: &str, file: &(&'static str, uint)) -> ! {
+    format_args!(|fmt| fail_fmt(fmt, file), "{}", msg)
 }
 
 #[cold] #[inline(never)]
-pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
+pub fn fail_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
     #[allow(ctypes)]
     extern {
+
+        // NOTE: remove after next snapshot
+        #[cfg(stage0)]
         #[lang = "begin_unwind"]
-        fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
+        fn fail_impl(fmt: &fmt::Arguments, file: &'static str,
                         line: uint) -> !;
+
+        #[cfg(not(stage0))]
+        #[lang = "fail_fmt"]
+        fn fail_impl(fmt: &fmt::Arguments, file: &'static str,
+                        line: uint) -> !;
+
     }
     let (file, line) = *file_line;
-    unsafe { begin_unwind(fmt, file, line) }
+    unsafe { fail_impl(fmt, file, line) }
 }
-
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index e846f8dbeb4..0f972a67029 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -18,7 +18,7 @@ macro_rules! fail(
     );
     ($msg:expr) => ({
         static _FILE_LINE: (&'static str, uint) = (file!(), line!());
-        ::core::failure::begin_unwind_string($msg, &_FILE_LINE)
+        ::core::failure::fail_str($msg, &_FILE_LINE)
     });
     ($fmt:expr, $($arg:tt)*) => ({
         // a closure can't have return type !, so we need a full
@@ -40,7 +40,7 @@ macro_rules! fail(
         #[inline(always)]
         fn _run_fmt(fmt: &::std::fmt::Arguments) -> ! {
             static _FILE_LINE: (&'static str, uint) = (file!(), line!());
-            ::core::failure::begin_unwind(fmt, &_FILE_LINE)
+            ::core::failure::fail_fmt(fmt, &_FILE_LINE)
         }
         format_args!(_run_fmt, $fmt, $($arg)*)
     });