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

ICE: manually implementing Fn traits for unit structs #33687

Closed
jFransham opened this issue May 17, 2016 · 2 comments
Closed

ICE: manually implementing Fn traits for unit structs #33687

jFransham opened this issue May 17, 2016 · 2 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jFransham
Copy link
Contributor

jFransham commented May 17, 2016

I know the Fn traits are unstable and are therefore completely allowed to eat my laundry and sell my dog to ISIS, but this is probably an important bug nontheless: on current nightly (rustc 1.8.0 (db2939409 2016-04-11), unless playground doesn't use current nightly), the following code ICEs

#![feature(unboxed_closures)]
#![feature(fn_traits)]

struct Test;

impl FnOnce<(u32, u32)> for Test {
    type Output = u32;

    extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
        a + b
    }
}

fn main() {
    println!("{:?}", Test(1u32, 2u32));
}

It also ICEs with an empty struct definition (struct Test {} instead of struct Test;). The following code does not ICE:

#![feature(unboxed_closures)]
#![feature(fn_traits)]

struct Dummy;
struct Test(Dummy);

impl FnOnce<(u32, u32)> for Test {
    type Output = u32;

    extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
        a + b
    }
}

fn main() {
    println!("{:?}", Test(Dummy)(1u32, 2u32));
}

Error message:

error: internal compiler error: ../src/librustc_trans/adt.rs:430: adt::represent_type called on non-ADT type: u32
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:584
note: Run with `RUST_BACKTRACE=1` for a backtrace.

playpen: application terminated with error code 101
@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 17, 2016
@durka
Copy link
Contributor

durka commented May 17, 2016

dupe of #22603

@arielb1
Copy link
Contributor

arielb1 commented May 17, 2016

This is fixed by MIR.

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 17, 2016
bors added a commit that referenced this issue Aug 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants