about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2014-09-21 23:35:43 +0200
committerFlorian Hahn <flo@fhahn.com>2014-09-25 01:09:09 +0200
commit1c7d253ca3601d2f9caddc52e66bfc1de3bdd441 (patch)
tree4d28ead07c0451d6038972ed6517a817e7230554
parent45f4081e61a1a15e2b5b9c5a09976fddffdac9dc (diff)
downloadrust-1c7d253ca3601d2f9caddc52e66bfc1de3bdd441.tar.gz
rust-1c7d253ca3601d2f9caddc52e66bfc1de3bdd441.zip
Rename `fail_` lang item to `fail`, closes #16114
-rw-r--r--src/doc/guide-unsafe.md2
-rw-r--r--src/libcore/failure.rs17
-rw-r--r--src/librustc/middle/lang_items.rs4
-rw-r--r--src/librustrt/unwind.rs10
-rw-r--r--src/test/auxiliary/lang-item-public.rs2
-rw-r--r--src/test/compile-fail/lint-dead-code-1.rs2
6 files changed, 25 insertions, 12 deletions
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md
index e152f16b7a2..ba79e828150 100644
--- a/src/doc/guide-unsafe.md
+++ b/src/doc/guide-unsafe.md
@@ -706,7 +706,7 @@ Other features provided by lang items include:
   `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
   marked with lang items; those specific four are `eq`, `ord`,
   `deref`, and `add` respectively.
-- stack unwinding and general failure; the `eh_personality`, `fail_`
+- stack unwinding and general failure; the `eh_personality`, `fail`
   and `fail_bounds_checks` lang items.
 - the traits in `std::kinds` used to indicate types that satisfy
   various kinds; lang items `send`, `sync` and `copy`.
diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs
index 8cea7abe963..6f919004874 100644
--- a/src/libcore/failure.rs
+++ b/src/libcore/failure.rs
@@ -33,6 +33,8 @@
 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)) -> ! {
@@ -45,6 +47,19 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
     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_impl(args, file_line);
+    }, "{}", expr);
+
+    unsafe { intrinsics::abort() }
+}
+
 #[cold] #[inline(never)]
 #[lang="fail_bounds_check"]
 fn fail_bounds_check(file_line: &(&'static str, uint),
@@ -65,6 +80,7 @@ pub fn fail_impl(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
     #[allow(ctypes)]
     extern {
 
+        // NOTE: remove after next snapshot
         #[cfg(stage0)]
         #[lang = "begin_unwind"]
         fn fail_impl(fmt: &fmt::Arguments, file: &'static str,
@@ -79,4 +95,3 @@ pub fn fail_impl(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
     let (file, line) = *file_line;
     unsafe { fail_impl(fmt, file, line) }
 }
-
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index 61f7f190729..50c92b45fdf 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -264,7 +264,7 @@ lets_do_this! {
 
     StrEqFnLangItem,                 "str_eq",                  str_eq_fn;
 
-    // A number of failure-related lang items. The `fail_` item corresponds to
+    // A number of failure-related lang items. The `fail` item corresponds to
     // divide-by-zero and various failure cases with `match`. The
     // `fail_bounds_check` item is for indexing arrays.
     //
@@ -273,7 +273,7 @@ lets_do_this! {
     // defined to use it, but a final product is required to define it
     // somewhere. Additionally, there are restrictions on crates that use a weak
     // lang item, but do not have it defined.
-    FailFnLangItem,                  "fail_",                   fail_fn;
+    FailFnLangItem,                  "fail",                    fail_fn;
     FailBoundsCheckFnLangItem,       "fail_bounds_check",       fail_bounds_check_fn;
     FailFmtLangItem,                 "fail_fmt",                fail_fmt;
 
diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs
index 01120980dde..034ed470c97 100644
--- a/src/librustrt/unwind.rs
+++ b/src/librustrt/unwind.rs
@@ -488,24 +488,22 @@ pub mod eabi {
 }
 
 // Entry point of failure from the libcore crate
-#[cfg(not(test))]
-#[cfg(not(stage0))]
+#[cfg(not(test), not(stage0))]
 #[lang = "fail_fmt"]
-pub extern fn rust_begin_unwind1(msg: &fmt::Arguments,
+pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
                                 file: &'static str, line: uint) -> ! {
     begin_unwind_fmt(msg, &(file, line))
 }
+
 //
 // Entry point of failure from the libcore crate
-#[cfg(not(test))]
-#[cfg(stage0)]
+#[cfg(stage0, not(test))]
 #[lang = "begin_unwind"]
 pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
                                 file: &'static str, line: uint) -> ! {
     begin_unwind_fmt(msg, &(file, line))
 }
 
-
 /// The entry point for unwinding with a formatted message.
 ///
 /// This is designed to reduce the amount of code required at the call
diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs
index 5723b59a60b..73bad011472 100644
--- a/src/test/auxiliary/lang-item-public.rs
+++ b/src/test/auxiliary/lang-item-public.rs
@@ -11,7 +11,7 @@
 #![no_std]
 #![feature(lang_items)]
 
-#[lang="fail_"]
+#[lang="fail"]
 fn fail(_: &(&'static str, &'static str, uint)) -> ! { loop {} }
 
 #[lang = "stack_exhausted"]
diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs
index a2d2c02dc43..1efd7b09aac 100644
--- a/src/test/compile-fail/lint-dead-code-1.rs
+++ b/src/test/compile-fail/lint-dead-code-1.rs
@@ -104,5 +104,5 @@ fn g() { h(); }
 fn h() {}
 
 // Similarly, lang items are live
-#[lang="fail_"]
+#[lang="fail"]
 fn fail(_: *const u8, _: *const u8, _: uint) -> ! { loop {} }