Rename fail_ lang item to fail, closes #16114

This commit is contained in:
Florian Hahn 2014-09-21 23:35:43 +02:00
parent 45f4081e61
commit 1c7d253ca3
6 changed files with 30 additions and 17 deletions

View File

@ -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`.

View File

@ -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) }
}

View File

@ -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;

View File

@ -488,23 +488,21 @@ 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,
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))
}
//
// Entry point of failure from the libcore crate
#[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.
///

View File

@ -11,7 +11,7 @@
#![no_std]
#![feature(lang_items)]
#[lang="fail_"]
#[lang="fail"]
fn fail(_: &(&'static str, &'static str, uint)) -> ! { loop {} }
#[lang = "stack_exhausted"]

View File

@ -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 {} }