Mark panic_fmt as no_mangle to work around rust-lang/rust#38281 (#262)

This commit is contained in:
Philipp Oppermann
2016-12-19 11:32:20 +01:00
committed by GitHub
parent f4ff2b0000
commit c5dd983949
3 changed files with 4 additions and 1 deletions

View File

@@ -57,7 +57,7 @@ Now we place our root source file in `src/lib.rs`:
pub extern fn rust_main() {} pub extern fn rust_main() {}
#[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! {loop{}} #[lang = "panic_fmt"] #[no_mangle] extern fn panic_fmt() -> ! {loop{}}
``` ```
Let's break it down: Let's break it down:

View File

@@ -103,6 +103,7 @@ We used `expect` in the code above, which will panic if there is no memory map t
```rust ```rust
#[lang = "panic_fmt"] #[lang = "panic_fmt"]
#[no_mangle]
extern fn panic_fmt() -> ! { extern fn panic_fmt() -> ! {
println!("PANIC"); println!("PANIC");
loop{} loop{}
@@ -112,6 +113,7 @@ Now we get a `PANIC` message. But we can do even better. The `panic_fmt` functio
```rust ```rust
#[lang = "panic_fmt"] #[lang = "panic_fmt"]
#[no_mangle]
extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str,
line: u32) -> ! line: u32) -> !
{ {

View File

@@ -86,6 +86,7 @@ extern "C" fn eh_personality() {}
#[cfg(not(test))] #[cfg(not(test))]
#[lang = "panic_fmt"] #[lang = "panic_fmt"]
#[no_mangle]
extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! { extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
println!("\n\nPANIC in {} at line {}:", file, line); println!("\n\nPANIC in {} at line {}:", file, line);
println!(" {}", fmt); println!(" {}", fmt);