From 0e32a165c297481aa34b30b4f852bfa63c1e816b Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Mon, 13 Aug 2018 00:12:21 +0100 Subject: [PATCH] satman: Fix build with Rust 1.28 The build was broken in 2648b1b7a1b13e2591c9ba8a53f25022862f17e2. --- artiq/firmware/satman/main.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index fb0546cac..b109ef96f 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -1,4 +1,4 @@ -#![feature(lang_items, never_type)] +#![feature(never_type, panic_implementation, panic_info_message)] #![no_std] #[macro_use] @@ -328,10 +328,18 @@ pub extern fn abort() { loop {} } -#[no_mangle] -#[lang = "panic_fmt"] -pub extern fn panic_fmt(args: core::fmt::Arguments, file: &'static str, - line: u32, column: u32) -> ! { - println!("panic at {}:{}:{}: {}", file, line, column, args); +#[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647} +#[panic_implementation] +pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { + if let Some(location) = info.location() { + print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); + } else { + print!("panic at unknown location"); + } + if let Some(message) = info.message() { + println!(": {}", message); + } else { + println!(""); + } loop {} }