Skip to content

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

Closed
@eira-fransham

Description

@eira-fransham

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;
  |                                     ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions