Skip to content

Commit 1c7d253

Browse files
committed
Rename fail_ lang item to fail, closes #16114
1 parent 45f4081 commit 1c7d253

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

src/doc/guide-unsafe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ Other features provided by lang items include:
706706
`==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
707707
marked with lang items; those specific four are `eq`, `ord`,
708708
`deref`, and `add` respectively.
709-
- stack unwinding and general failure; the `eh_personality`, `fail_`
709+
- stack unwinding and general failure; the `eh_personality`, `fail`
710710
and `fail_bounds_checks` lang items.
711711
- the traits in `std::kinds` used to indicate types that satisfy
712712
various kinds; lang items `send`, `sync` and `copy`.

src/libcore/failure.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
use fmt;
3434
use intrinsics;
3535

36+
// NOTE: remove after next snapshot
37+
#[cfg(stage0)]
3638
#[cold] #[inline(never)] // this is the slow path, always
3739
#[lang="fail_"]
3840
fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
@@ -45,6 +47,19 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
4547
unsafe { intrinsics::abort() }
4648
}
4749

50+
#[cfg(not(stage0))]
51+
#[cold] #[inline(never)] // this is the slow path, always
52+
#[lang="fail"]
53+
fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
54+
let (expr, file, line) = *expr_file_line;
55+
let ref file_line = (file, line);
56+
format_args!(|args| -> () {
57+
fail_impl(args, file_line);
58+
}, "{}", expr);
59+
60+
unsafe { intrinsics::abort() }
61+
}
62+
4863
#[cold] #[inline(never)]
4964
#[lang="fail_bounds_check"]
5065
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)) -> ! {
6580
#[allow(ctypes)]
6681
extern {
6782

83+
// NOTE: remove after next snapshot
6884
#[cfg(stage0)]
6985
#[lang = "begin_unwind"]
7086
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)) -> ! {
7995
let (file, line) = *file_line;
8096
unsafe { fail_impl(fmt, file, line) }
8197
}
82-

src/librustc/middle/lang_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ lets_do_this! {
264264

265265
StrEqFnLangItem, "str_eq", str_eq_fn;
266266

267-
// A number of failure-related lang items. The `fail_` item corresponds to
267+
// A number of failure-related lang items. The `fail` item corresponds to
268268
// divide-by-zero and various failure cases with `match`. The
269269
// `fail_bounds_check` item is for indexing arrays.
270270
//
@@ -273,7 +273,7 @@ lets_do_this! {
273273
// defined to use it, but a final product is required to define it
274274
// somewhere. Additionally, there are restrictions on crates that use a weak
275275
// lang item, but do not have it defined.
276-
FailFnLangItem, "fail_", fail_fn;
276+
FailFnLangItem, "fail", fail_fn;
277277
FailBoundsCheckFnLangItem, "fail_bounds_check", fail_bounds_check_fn;
278278
FailFmtLangItem, "fail_fmt", fail_fmt;
279279

src/librustrt/unwind.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -488,24 +488,22 @@ pub mod eabi {
488488
}
489489

490490
// Entry point of failure from the libcore crate
491-
#[cfg(not(test))]
492-
#[cfg(not(stage0))]
491+
#[cfg(not(test), not(stage0))]
493492
#[lang = "fail_fmt"]
494-
pub extern fn rust_begin_unwind1(msg: &fmt::Arguments,
493+
pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
495494
file: &'static str, line: uint) -> ! {
496495
begin_unwind_fmt(msg, &(file, line))
497496
}
497+
498498
//
499499
// Entry point of failure from the libcore crate
500-
#[cfg(not(test))]
501-
#[cfg(stage0)]
500+
#[cfg(stage0, not(test))]
502501
#[lang = "begin_unwind"]
503502
pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
504503
file: &'static str, line: uint) -> ! {
505504
begin_unwind_fmt(msg, &(file, line))
506505
}
507506

508-
509507
/// The entry point for unwinding with a formatted message.
510508
///
511509
/// This is designed to reduce the amount of code required at the call

src/test/auxiliary/lang-item-public.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![no_std]
1212
#![feature(lang_items)]
1313

14-
#[lang="fail_"]
14+
#[lang="fail"]
1515
fn fail(_: &(&'static str, &'static str, uint)) -> ! { loop {} }
1616

1717
#[lang = "stack_exhausted"]

src/test/compile-fail/lint-dead-code-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ fn g() { h(); }
104104
fn h() {}
105105

106106
// Similarly, lang items are live
107-
#[lang="fail_"]
107+
#[lang="fail"]
108108
fn fail(_: *const u8, _: *const u8, _: uint) -> ! { loop {} }

0 commit comments

Comments
 (0)