Skip to content

Commit

Permalink
Add missing core::panic::PanicInfo imports in code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-opp committed Jun 14, 2018
1 parent 34f5733 commit afa0337
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ To tell the Rust compiler that we don't want to use the normal entry point chain
#![no_std]
#![no_main]

use core::panic::PanicInfo;

/// This function is called on panic.
#[panic_implementation]
#[no_mangle]
Expand Down Expand Up @@ -313,6 +315,8 @@ A minimal freestanding Rust binary looks like this:
#![no_std] // don't link the Rust standard library
#![no_main] // disable all Rust-level entry points

use core::panic::PanicInfo;

/// This function is called on panic.
#[panic_implementation]
#[no_mangle]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ Compiling for our new target will use Linux conventions (I'm not quite sure why,
#![no_std] // don't link the Rust standard library
#![no_main] // disable all Rust-level entry points

use core::panic::PanicInfo;

/// This function is called on panic.
#[panic_implementation]
#[no_mangle]
Expand Down
3 changes: 3 additions & 0 deletions blog/content/second-edition/posts/04-unit-testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ The problem is that unit tests are built for the host machine, with the `std` li
```rust
// in src/main.rs

#[cfg(not(test))]
use core::panic::PanicInfo;

#[cfg(not(test))] // only compile when the test flag is not set
#[panic_implementation]
#[no_mangle]
Expand Down

0 comments on commit afa0337

Please sign in to comment.