Skip to content

Commit 9a01da9

Browse files
committed
Rename begin_unwind lang item to fail_fmt, refs rust-lang#16114
1 parent e0bd16c commit 9a01da9

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

src/doc/guide-unsafe.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ pub extern fn dot_product(a: *const u32, a_len: u32,
573573
return ret;
574574
}
575575
576-
#[lang = "begin_unwind"]
577-
extern fn begin_unwind(args: &core::fmt::Arguments,
576+
#[lang = "fail_fmt"]
577+
extern fn fail_fmt(args: &core::fmt::Arguments,
578578
file: &str,
579579
line: uint) -> ! {
580580
loop {}
@@ -587,8 +587,8 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
587587
```
588588

589589
Note that there is one extra lang item here which differs from the examples
590-
above, `begin_unwind`. This must be defined by consumers of libcore because the
591-
core library declares failure, but it does not define it. The `begin_unwind`
590+
above, `fail_fmt`. This must be defined by consumers of libcore because the
591+
core library declares failure, but it does not define it. The `fail_fmt`
592592
lang item is this crate's definition of failure, and it must be guaranteed to
593593
never return.
594594

src/libcore/failure.rs

+8
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! {
6464
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
6565
#[allow(ctypes)]
6666
extern {
67+
68+
#[cfg(stage0)]
6769
#[lang = "begin_unwind"]
6870
fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
6971
line: uint) -> !;
72+
73+
#[cfg(not(stage0))]
74+
#[lang = "fail_fmt"]
75+
fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
76+
line: uint) -> !;
77+
7078
}
7179
let (file, line) = *file_line;
7280
unsafe { begin_unwind(fmt, file, line) }

src/librustc/middle/lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ lets_do_this! {
275275
// lang item, but do not have it defined.
276276
FailFnLangItem, "fail_", fail_fn;
277277
FailBoundsCheckFnLangItem, "fail_bounds_check", fail_bounds_check_fn;
278-
BeginUnwindLangItem, "begin_unwind", begin_unwind;
278+
FailFmtLangItem, "fail_fmt", fail_fmt;
279279

280280
ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn;
281281
ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn;

src/librustc/middle/weak_lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
118118
) )
119119

120120
weak_lang_items!(
121-
begin_unwind, BeginUnwindLangItem, rust_begin_unwind;
121+
fail_fmt, FailFmtLangItem, rust_begin_unwind;
122122
stack_exhausted, StackExhaustedLangItem, rust_stack_exhausted;
123123
eh_personality, EhPersonalityLangItem, rust_eh_personality;
124124
)

src/librustrt/unwind.rs

+11
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,23 @@ pub mod eabi {
489489

490490
// Entry point of failure from the libcore crate
491491
#[cfg(not(test))]
492+
#[cfg(not(stage0))]
493+
#[lang = "fail_fmt"]
494+
pub extern fn rust_begin_unwind1(msg: &fmt::Arguments,
495+
file: &'static str, line: uint) -> ! {
496+
begin_unwind_fmt(msg, &(file, line))
497+
}
498+
//
499+
// Entry point of failure from the libcore crate
500+
#[cfg(not(test))]
501+
#[cfg(stage0)]
492502
#[lang = "begin_unwind"]
493503
pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
494504
file: &'static str, line: uint) -> ! {
495505
begin_unwind_fmt(msg, &(file, line))
496506
}
497507

508+
498509
/// The entry point for unwinding with a formatted message.
499510
///
500511
/// This is designed to reduce the amount of code required at the call

src/test/compile-fail/weak-lang-item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// aux-build:weak-lang-items.rs
12-
// error-pattern: language item required, but not found: `begin_unwind`
12+
// error-pattern: language item required, but not found: `fail_fmt`
1313
// error-pattern: language item required, but not found: `stack_exhausted`
1414
// error-pattern: language item required, but not found: `eh_personality`
1515

0 commit comments

Comments
 (0)