Skip to content

ICE On Simple Example #16750

Closed
Closed
@Fizzixnerd

Description

@Fizzixnerd

The following simple definition of a data structure results in an ICE.

Replacing the main function with an empty one results in successful compilations (albeit with many unused-code warnings).

Information:

uname --all:

Linux ultrawalker 3.13.0-27-generic #50-Ubuntu SMP Thu May 15 18:06:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

rustc -v:

rustc 0.12.0-pre (5ad7afc2d 2014-08-24 11:16:02 +0000)

rustc error message:

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'No def'n found for syntax::ast::DefId{krate: 0u32, node: 17u32} in tcx.tcache', /home/matt/src/rust/src/librustc/middle/ty.rs:3845

Offending Code:

// A Contact object.

extern crate core;

use core::fmt;

struct ContactObj {
    name: Name,
    phone: PhoneNumber,
    email: EmailAddress,
}

trait Contact {
    fn name(&self) -> &Name;
    fn phone(&self) -> &PhoneNumber;
    fn email(&self) -> &EmailAddress;
    fn short_name(&self) -> &Name;
}

struct Name {
    honorific: Option<String>,
    first: String,
    middle: Option<String>,
    last: Option<String>,
    post: Option<String>
}

struct PhoneNumber {
    country_code: Option<String>,
    area_code: Option<String>,
    first_half: String,
    second_half: String
}

struct EmailAddress {
    username: String,
    domain: String
}

fn main() {
    let my_contact =
        Contact {
            name: Name {
                honorific: Some("Mr."),
                first: "John",
                middle: Some("F."),
                last: Some("Smith"),
                post: Some("I")
            },
            phone: PhoneNumber {
                country_code: Some("x"),
                area_code: Some("xxx"),
                first_half: "xxx",
                second_half: "xxxx"
            },
            email: EmailAddress {
                username: "john.f.smith",
                domain: "example.com"
            }
        };

    println!("{}", my_contact);
}

Further information is available upon request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-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