Skip to content

Commit

Permalink
Mark panic_fmt as no_mangle to work around rust-lang/rust#38281 (#โ€ฆ
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-opp authored Dec 19, 2016
1 parent 61d1f57 commit 3e85195
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion blog/post/03-set-up-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Now we place our root source file in `src/lib.rs`:
pub extern fn rust_main() {}

#[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:

Expand Down
2 changes: 2 additions & 0 deletions blog/post/05-allocating-frames.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ We used `expect` in the code above, which will panic if there is no memory map t

```rust
#[lang = "panic_fmt"]
#[no_mangle]
extern fn panic_fmt() -> ! {
println!("PANIC");
loop{}
Expand All @@ -112,6 +113,7 @@ Now we get a `PANIC` message. But we can do even better. The `panic_fmt` functio

```rust
#[lang = "panic_fmt"]
#[no_mangle]
extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str,
line: u32) -> !
{
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extern "C" fn eh_personality() {}

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

0 comments on commit 3e85195

Please sign in to comment.