1
Fork 0

s/panic_fmt/panic_impl/g in docs

This commit is contained in:
Jorge Aparicio 2018-04-30 10:57:11 +02:00
parent e44ad61a2d
commit 63f18e108a
4 changed files with 22 additions and 21 deletions

View file

@ -19,6 +19,7 @@ sugar for dynamic allocations via `malloc` and `free`:
#![feature(lang_items, box_syntax, start, libc, core_intrinsics)] #![feature(lang_items, box_syntax, start, libc, core_intrinsics)]
#![no_std] #![no_std]
use core::intrinsics; use core::intrinsics;
use core::panic::PanicInfo;
extern crate libc; extern crate libc;
@ -50,7 +51,7 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
} }
#[lang = "eh_personality"] extern fn rust_eh_personality() {} #[lang = "eh_personality"] extern fn rust_eh_personality() {}
#[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { unsafe { intrinsics::abort() } } #[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
#[no_mangle] pub extern fn rust_eh_register_frames () {} #[no_mangle] pub extern fn rust_eh_register_frames () {}
#[no_mangle] pub extern fn rust_eh_unregister_frames () {} #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
@ -110,6 +111,7 @@ in the same format as C:
#![feature(start)] #![feature(start)]
#![no_std] #![no_std]
use core::intrinsics; use core::intrinsics;
use core::panic::PanicInfo;
// Pull in the system libc library for what crt0.o likely requires. // Pull in the system libc library for what crt0.o likely requires.
extern crate libc; extern crate libc;
@ -134,12 +136,9 @@ pub extern fn rust_eh_personality() {
pub extern fn rust_eh_unwind_resume() { pub extern fn rust_eh_unwind_resume() {
} }
#[lang = "panic_fmt"] #[lang = "panic_impl"]
#[no_mangle] #[no_mangle]
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
_file: &'static str,
_line: u32,
_column: u32) -> ! {
unsafe { intrinsics::abort() } unsafe { intrinsics::abort() }
} }
``` ```
@ -155,6 +154,7 @@ compiler's name mangling too:
#![no_std] #![no_std]
#![no_main] #![no_main]
use core::intrinsics; use core::intrinsics;
use core::panic::PanicInfo;
// Pull in the system libc library for what crt0.o likely requires. // Pull in the system libc library for what crt0.o likely requires.
extern crate libc; extern crate libc;
@ -179,12 +179,9 @@ pub extern fn rust_eh_personality() {
pub extern fn rust_eh_unwind_resume() { pub extern fn rust_eh_unwind_resume() {
} }
#[lang = "panic_fmt"] #[lang = "panic_impl"]
#[no_mangle] #[no_mangle]
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
_file: &'static str,
_line: u32,
_column: u32) -> ! {
unsafe { intrinsics::abort() } unsafe { intrinsics::abort() }
} }
``` ```
@ -215,7 +212,7 @@ called. The language item's name is `eh_personality`.
The second function, `rust_begin_panic`, is also used by the failure mechanisms of the The second function, `rust_begin_panic`, is also used by the failure mechanisms of the
compiler. When a panic happens, this controls the message that's displayed on compiler. When a panic happens, this controls the message that's displayed on
the screen. While the language item's name is `panic_fmt`, the symbol name is the screen. While the language item's name is `panic_impl`, the symbol name is
`rust_begin_panic`. `rust_begin_panic`.
A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume` A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume`
@ -259,8 +256,8 @@ the source code.
- `msvc_try_filter`: `libpanic_unwind/seh.rs` (SEH) - `msvc_try_filter`: `libpanic_unwind/seh.rs` (SEH)
- `panic`: `libcore/panicking.rs` - `panic`: `libcore/panicking.rs`
- `panic_bounds_check`: `libcore/panicking.rs` - `panic_bounds_check`: `libcore/panicking.rs`
- `panic_fmt`: `libcore/panicking.rs` - `panic_impl`: `libcore/panicking.rs`
- `panic_fmt`: `libstd/panicking.rs` - `panic_impl`: `libstd/panicking.rs`
- Allocations - Allocations
- `owned_box`: `liballoc/boxed.rs` - `owned_box`: `liballoc/boxed.rs`
- `exchange_malloc`: `liballoc/heap.rs` - `exchange_malloc`: `liballoc/heap.rs`

View file

@ -87,11 +87,13 @@ This condition can be met using `#[used]` and `#[link_section]` plus a linker
script. script.
``` rust,ignore ``` rust,ignore
#![feature(lang_items)] #![feature(panic_implementation)]
#![feature(used)] #![feature(used)]
#![no_main] #![no_main]
#![no_std] #![no_std]
use core::panic::PanicInfo;
extern "C" fn reset_handler() -> ! { extern "C" fn reset_handler() -> ! {
loop {} loop {}
} }
@ -100,8 +102,10 @@ extern "C" fn reset_handler() -> ! {
#[used] #[used]
static RESET_HANDLER: extern "C" fn() -> ! = reset_handler; static RESET_HANDLER: extern "C" fn() -> ! = reset_handler;
#[lang = "panic_fmt"] #[panic_implementation]
fn panic_fmt() {} fn panic_impl(info: &PanicInfo) -> ! {
loop {}
}
``` ```
``` text ``` text

View file

@ -41,7 +41,7 @@
//! dictate the panic message, the file at which panic was invoked, and the //! dictate the panic message, the file at which panic was invoked, and the
//! line and column inside the file. It is up to consumers of this core //! line and column inside the file. It is up to consumers of this core
//! library to define this panic function; it is only required to never //! library to define this panic function; it is only required to never
//! return. This requires a `lang` attribute named `panic_fmt`. //! return. This requires a `lang` attribute named `panic_impl`.
//! //!
//! * `rust_eh_personality` - is used by the failure mechanisms of the //! * `rust_eh_personality` - is used by the failure mechanisms of the
//! compiler. This is often mapped to GCC's personality function, but crates //! compiler. This is often mapped to GCC's personality function, but crates

View file

@ -637,8 +637,8 @@ Erroneous code example:
```compile_fail,E0152 ```compile_fail,E0152
#![feature(lang_items)] #![feature(lang_items)]
#[lang = "panic_fmt"] #[lang = "panic_impl"]
struct Foo; // error: duplicate lang item found: `panic_fmt` struct Foo; // error: duplicate lang item found: `panic_impl`
``` ```
Lang items are already implemented in the standard library. Unless you are Lang items are already implemented in the standard library. Unless you are
@ -824,7 +824,7 @@ A list of available external lang items is available in
#![feature(lang_items)] #![feature(lang_items)]
extern "C" { extern "C" {
#[lang = "panic_fmt"] // ok! #[lang = "panic_impl"] // ok!
fn cake(); fn cake();
} }
``` ```