From cbc9e112bdf0cb1437520e6d0267c5b7de5f0fc8 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 13 Apr 2017 17:53:34 +0200 Subject: [PATCH] Print a proper message on panics --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index a30dd50..433b051 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,4 +31,11 @@ pub extern fn rust_main(multiboot_information_address: usize) { } #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}} + +#[lang = "panic_fmt"] +#[no_mangle] +pub extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! { + println!("\n\nPANIC in {} at line {}:", file, line); + println!(" {}", fmt); + loop{} +}