File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#![ feature( abi_x86_interrupt) ]
33#![ feature( type_alias_impl_trait) ]
44
5- extern crate alloc;
65#[ macro_use]
76extern crate log;
87extern crate libm;
@@ -13,8 +12,6 @@ pub use utils::*;
1312
1413mod drivers;
1514
16- pub use alloc:: format;
17-
1815use boot:: BootInfo ;
1916use uefi:: { Status , runtime:: ResetType } ;
2017
Original file line number Diff line number Diff line change 1- use alloc:: string:: ToString ;
2- use core:: { arch:: asm, fmt:: * } ;
1+ use core:: { arch:: asm, fmt:: * , panic:: Location } ;
32
43use x86_64:: instructions:: interrupts;
54
@@ -74,20 +73,20 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
7473 // force unlock serial for panic output
7574 unsafe { SERIAL . get ( ) . unwrap ( ) . force_unlock ( ) } ;
7675
77- let location = if let Some ( location ) = info . location ( ) {
78- alloc :: format! (
79- "{}:{}:{}" ,
80- location . file ( ) ,
81- location . line ( ) ,
82- location . column ( )
83- )
84- } else {
85- "Unknown location" . to_string ( )
86- } ;
76+ struct PanicLocation < ' a > ( Option < & ' a Location < ' a > > ) ;
77+
78+ impl Display for PanicLocation < ' _ > {
79+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result {
80+ match self . 0 {
81+ Some ( loc ) => Display :: fmt ( loc , f ) ,
82+ None => f . write_str ( "unknown location" ) ,
83+ }
84+ }
85+ }
8786
8887 error ! (
8988 "\n \n \r ERROR: panicked at {}\n \n \r {}\n " ,
90- location,
89+ PanicLocation ( info . location( ) ) ,
9190 info. message( )
9291 ) ;
9392
Original file line number Diff line number Diff line change 11#![ cfg_attr( not( test) , no_std) ]
22#![ allow( dead_code, unused_imports) ]
3- #![ feature( alloc_error_handler) ]
3+ #![ cfg_attr ( not ( test ) , feature( alloc_error_handler) ) ]
44
55#[ macro_use]
66pub mod macros;
Original file line number Diff line number Diff line change 11#![ allow( dead_code, unused_imports) ]
2- #![ feature( alloc_error_handler) ]
2+ #![ cfg_attr ( not ( test ) , feature( alloc_error_handler) ) ]
33#![ cfg_attr( not( test) , no_std) ]
44
55#[ macro_use]
You can’t perform that action at this time.
0 commit comments