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 On Simple Example #16750

Closed
Fizzixnerd opened this issue Aug 25, 2014 · 2 comments · Fixed by #16867
Closed

ICE On Simple Example #16750

Fizzixnerd opened this issue Aug 25, 2014 · 2 comments · Fixed by #16867
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Fizzixnerd
Copy link

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.

@alexcrichton
Copy link
Member

Minimized:

trait Contact { }
fn main() { Contact{name: 0,} }
$ rustc --pretty normal foo.rs | rustc -
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: 4u32} in tcx.tcache', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/middle/ty.rs:3845

@ghost
Copy link

ghost commented Aug 25, 2014

And probably a dupe of #15812.

bors added a commit that referenced this issue Sep 1, 2014
Not sure if this is addressing the root cause or just patching up a symptom. Also not sure if I should be adding a diagnostic code for this.

Fixes #16750
Fixes #15812
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Mar 10, 2024
minor: Mark remove_unnecessary_else as experimental

cc rust-lang/rust-analyzer#16566 (comment) rust-lang/rust-analyzer#16628

There seem to be some leftover issues with this, additionally its a style lint so it's not too nice to see for some people. We should flesh out our diagnostics stuff before adding more style lints I think
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants