Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eira-fransham opened this issue Jun 5, 2018 · 0 comments

Comments

@eira-fransham
Copy link

eira-fransham commented Jun 5, 2018

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;
  |                                     ^
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 6, 2018
…s, r=eddyb

Fix the use of closures within #[panic_implementation]

Fixes rust-lang#51365.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 7, 2018
…s, r=eddyb

Fix the use of closures within #[panic_implementation]

Fixes rust-lang#51365.
kennytm added a commit to kennytm/rust that referenced this issue Jun 7, 2018
…s, r=eddyb

Fix the use of closures within #[panic_implementation]

Fixes rust-lang#51365.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant