RISCV: panic_abort: false positive "unused"?

Hi,

I tried building https://github.com/riscv-rust/picosoc-example but had some errors. After adding the appended patch, build succeeds, but I'm warned about unsued import of "panic_abort". If I remove the statement "use panic_abort;", then I get an error.

warning: unused import: `panic_abort`
 --> src/main.rs:7:5
  |
7 | use panic_abort;
  |     ^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

Error when removing "use" statement:

error: `#[panic_handler]` function required, but not found

error: aborting due to previous error

error: Could not compile `rust-picosoc`.

Patch needed to build the example:

diff --git a/Cargo.lock b/Cargo.lock
index c17d4f6..e367f16 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,3 +1,8 @@
+[[package]]
+name = "panic-abort"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
 [[package]]
 name = "r0"
 version = "0.2.2"
@@ -7,8 +12,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 name = "rust-picosoc"
 version = "0.1.0"
 dependencies = [
+ "panic-abort 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [metadata]
+"checksum panic-abort 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c14a66511ed17b6a8b4256b868d7fd207836d891db15eea5195dbcaf87e630f"
 "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f"
diff --git a/Cargo.toml b/Cargo.toml
index 328ee0f..1236529 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,8 @@
 name = "rust-picosoc"
 version = "0.1.0"
 authors = ["David Craven <david@craven.ch>"]
+edition = "2018"
 
 [dependencies]
-r0 = "0.2.2"
\ No newline at end of file
+r0 = "0.2.2"
+panic-abort = "0.3.1"
diff --git a/src/main.rs b/src/main.rs
index 9d87975..3b76c2d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,11 @@
-#![feature(extern_prelude)]
 #![feature(global_asm)]
-#![feature(panic_implementation)]
 #![no_main]
 #![no_std]
 
 const LED_ADDRESS: u32 = 0x0300_0000;
 
+use panic_abort;
+
 // The reset handler
 #[no_mangle]
 pub unsafe extern "C" fn Reset() -> ! {
@@ -35,11 +35,6 @@ extern "C" {
     static _sidata: u32;
 }
 
-#[panic_implementation]
-#[no_mangle]
-pub fn panic_fmt(_info: &core::panic::PanicInfo) -> ! {
-    loop {}
-}
 
 // Make sure there is an abort when linking
 #[cfg(target_arch = "riscv32")]

Is this a false positive warning, or should it be reported ?

This seems like a bug in the compiler's handling of #[panic_handler]. The use shouldn't be required.

In my embedded code, replacing use with the old-style extern crate works around this issue:

extern crate panic_abort;