Skip to content

Internal compiler error when using a trait with default implementations as a field in a struct #3694

Description

@andymatuschak

I get this internal compiler error:

rust: task failed at 'option::get none', /Users/andym/Downloads/rust/src/rustc/rustc.rc:1
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/andym/Downloads/rust/src/rustc/driver/rustc.rs:275
rust: domain main @0x7fd1e980c210 root task failed
rust: task failed at 'killed', /Users/andym/Downloads/rust/src/libcore/task.rs:663

When I compile this file:

pub trait Something {
    pure fn thing() -> int;
    pure fn what() -> int { 3 }
}

impl int: Something {
    pure fn thing() -> int { 4 }
}

struct AnotherThing {
    something: Something
}

fn main() {
    let at = AnotherThing {something: 4 as Something};
    at.something.what();
}

If Something has only required methods—no provided methods—then the error is not exhibited.

This is manifesting in rustc built from f96a2a2 on Mac OS 10.8.2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions