mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Merge pull request #276 from phil-opp/p
Make panic_fmt public to fix private_no_mangle_fns warning
This commit is contained in:
@@ -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"] #[no_mangle] extern fn panic_fmt() -> ! {loop{}}
|
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}
|
||||||
```
|
```
|
||||||
Let's break it down:
|
Let's break it down:
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,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]
|
#[no_mangle]
|
||||||
extern fn panic_fmt() -> ! {
|
pub extern fn panic_fmt() -> ! {
|
||||||
println!("PANIC");
|
println!("PANIC");
|
||||||
loop{}
|
loop{}
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,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]
|
#[no_mangle]
|
||||||
extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str,
|
pub extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str,
|
||||||
line: u32) -> !
|
line: u32) -> !
|
||||||
{
|
{
|
||||||
println!("\n\nPANIC in {} at line {}:", file, line);
|
println!("\n\nPANIC in {} at line {}:", file, line);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ extern "C" fn eh_personality() {}
|
|||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
#[lang = "panic_fmt"]
|
#[lang = "panic_fmt"]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
pub 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);
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
Reference in New Issue
Block a user