about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2014-09-21 23:11:33 +0200
committerFlorian Hahn <flo@fhahn.com>2014-09-24 23:44:00 +0200
commit9a01da9460a9e7a8be88896e9da0306fd47823a1 (patch)
tree57c5a8770ffd7062eeff8e02f98e6f2c21f449f7
parente0bd16c5ec7ff4c5445fa3991bd679b4d7d4e966 (diff)
downloadrust-9a01da9460a9e7a8be88896e9da0306fd47823a1.tar.gz
rust-9a01da9460a9e7a8be88896e9da0306fd47823a1.zip
Rename `begin_unwind` lang item to `fail_fmt`, refs #16114
-rw-r--r--src/doc/guide-unsafe.md8
-rw-r--r--src/libcore/failure.rs8
-rw-r--r--src/librustc/middle/lang_items.rs2
-rw-r--r--src/librustc/middle/weak_lang_items.rs2
-rw-r--r--src/librustrt/unwind.rs11
-rw-r--r--src/test/compile-fail/weak-lang-item.rs2
6 files changed, 26 insertions, 7 deletions
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md
index 8c67634d57a..e152f16b7a2 100644
--- a/src/doc/guide-unsafe.md
+++ b/src/doc/guide-unsafe.md
@@ -573,8 +573,8 @@ pub extern fn dot_product(a: *const u32, a_len: u32,
     return ret;
 }
 
-#[lang = "begin_unwind"]
-extern fn begin_unwind(args: &core::fmt::Arguments,
+#[lang = "fail_fmt"]
+extern fn fail_fmt(args: &core::fmt::Arguments,
                        file: &str,
                        line: uint) -> ! {
     loop {}
@@ -587,8 +587,8 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
 ```
 
 Note that there is one extra lang item here which differs from the examples
-above, `begin_unwind`. This must be defined by consumers of libcore because the
-core library declares failure, but it does not define it. The `begin_unwind`
+above, `fail_fmt`. This must be defined by consumers of libcore because the
+core library declares failure, but it does not define it. The `fail_fmt`
 lang item is this crate's definition of failure, and it must be guaranteed to
 never return.
 
diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs
index ac162c206c6..b8586f00675 100644
--- a/src/libcore/failure.rs
+++ b/src/libcore/failure.rs
@@ -64,9 +64,17 @@ pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! {
 pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
     #[allow(ctypes)]
     extern {
+
+        #[cfg(stage0)]
         #[lang = "begin_unwind"]
         fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
                         line: uint) -> !;
+
+        #[cfg(not(stage0))]
+        #[lang = "fail_fmt"]
+        fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
+                        line: uint) -> !;
+
     }
     let (file, line) = *file_line;
     unsafe { begin_unwind(fmt, file, line) }
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index daba3b701c0..61f7f190729 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -275,7 +275,7 @@ lets_do_this! {
     // lang item, but do not have it defined.
     FailFnLangItem,                  "fail_",                   fail_fn;
     FailBoundsCheckFnLangItem,       "fail_bounds_check",       fail_bounds_check_fn;
-    BeginUnwindLangItem,             "begin_unwind",            begin_unwind;
+    FailFmtLangItem,                 "fail_fmt",                fail_fmt;
 
     ExchangeMallocFnLangItem,        "exchange_malloc",         exchange_malloc_fn;
     ExchangeFreeFnLangItem,          "exchange_free",           exchange_free_fn;
diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs
index 81099da3fac..79faf3aa147 100644
--- a/src/librustc/middle/weak_lang_items.rs
+++ b/src/librustc/middle/weak_lang_items.rs
@@ -118,7 +118,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
 ) )
 
 weak_lang_items!(
-    begin_unwind,       BeginUnwindLangItem,        rust_begin_unwind;
+    fail_fmt,           FailFmtLangItem,            rust_begin_unwind;
     stack_exhausted,    StackExhaustedLangItem,     rust_stack_exhausted;
     eh_personality,     EhPersonalityLangItem,      rust_eh_personality;
 )
diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs
index acef05e0867..01120980dde 100644
--- a/src/librustrt/unwind.rs
+++ b/src/librustrt/unwind.rs
@@ -489,12 +489,23 @@ pub mod eabi {
 
 // Entry point of failure from the libcore crate
 #[cfg(not(test))]
+#[cfg(not(stage0))]
+#[lang = "fail_fmt"]
+pub extern fn rust_begin_unwind1(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)]
 #[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/compile-fail/weak-lang-item.rs b/src/test/compile-fail/weak-lang-item.rs
index 636adefb95e..74ec56f7bd9 100644
--- a/src/test/compile-fail/weak-lang-item.rs
+++ b/src/test/compile-fail/weak-lang-item.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 // aux-build:weak-lang-items.rs
-// error-pattern: language item required, but not found: `begin_unwind`
+// error-pattern: language item required, but not found: `fail_fmt`
 // error-pattern: language item required, but not found: `stack_exhausted`
 // error-pattern: language item required, but not found: `eh_personality`