mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Add missing core::panic::PanicInfo imports in code snippets (#440)
This commit is contained in:
committed by
GitHub
parent
34f5733114
commit
3372966664
@@ -200,6 +200,8 @@ To tell the Rust compiler that we don't want to use the normal entry point chain
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
/// This function is called on panic.
|
/// This function is called on panic.
|
||||||
#[panic_implementation]
|
#[panic_implementation]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -313,6 +315,8 @@ A minimal freestanding Rust binary looks like this:
|
|||||||
#![no_std] // don't link the Rust standard library
|
#![no_std] // don't link the Rust standard library
|
||||||
#![no_main] // disable all Rust-level entry points
|
#![no_main] // disable all Rust-level entry points
|
||||||
|
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
/// This function is called on panic.
|
/// This function is called on panic.
|
||||||
#[panic_implementation]
|
#[panic_implementation]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
@@ -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_std] // don't link the Rust standard library
|
||||||
#![no_main] // disable all Rust-level entry points
|
#![no_main] // disable all Rust-level entry points
|
||||||
|
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
/// This function is called on panic.
|
/// This function is called on panic.
|
||||||
#[panic_implementation]
|
#[panic_implementation]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ The problem is that unit tests are built for the host machine, with the `std` li
|
|||||||
```rust
|
```rust
|
||||||
// in src/main.rs
|
// in src/main.rs
|
||||||
|
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[cfg(not(test))] // only compile when the test flag is not set
|
#[cfg(not(test))] // only compile when the test flag is not set
|
||||||
#[panic_implementation]
|
#[panic_implementation]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
Reference in New Issue
Block a user