rust-lang/rust

panic_implementation: All closures within body of panic implementation are forced to have the panic implementation signature

eira-fransham opened this issue · 0 comments

Minimal reproduction:

#![no_std]
#![feature(panic_implementation)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(start)]

#[no_mangle]
#[panic_implementation]
pub fn panic_fmt(info: &::core::panic::PanicInfo) -> ! {
    let foo: fn(usize) -> usize = |i| i + 1;
    unsafe {
        ::core::intrinsics::abort()
    }
}

#[lang = "eh_personality"]
extern "C" fn eh_personality() {}

#[lang = "oom"]
#[no_mangle]
pub extern fn oom() -> ! {
    unsafe {
        ::core::intrinsics::abort()
    }
}

#[start]
fn main(argc: isize, argv: *const *const u8) -> isize {
    0
}

This produces the error:

error: return type should be `!`
 --> src/main.rs:9:39
  |
9 |     let foo: fn(usize) -> usize = |i| i + 1;
  |                                       ^

error: argument should be `&PanicInfo`
 --> src/main.rs:9:37
  |
9 |     let foo: fn(usize) -> usize = |i| i + 1;
  |                                     ^