Skip to content

ICE possibly related to empty trait and type alias  #25349

Closed
@ragnard

Description

@ragnard

I got a consistent ICE on a piece of code. I'm a rust newbie so I can't characterise the code well, but I've manage to narrow it down to the following:

use std::collections::HashMap;

trait Empty { }

struct S;
impl Empty for S { }

type U = HashMap<String, Empty>;

trait F {
    fn f(self, u: U);
}

impl F for S {
    fn f(self, u: U) { }
}

Error message:

src/lib.rs:1:1: 1:1 error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate(core::marker::Sized)),depth=2),Unimplemented)]` fulfilling during trans
src/lib.rs:1 use std::collections::HashMap;
             ^
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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /tmp/nix-build-rustc-1.0.0-dev-g0cf99c3.drv-0/rust-0cf99c3/src/libsyntax/diagnostic.rs:149

Meta

rustc 1.0.0-dev (built 2015-04-28)
binary: rustc
commit-hash: unknown
commit-date: unknown
build-date: 2015-04-28
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

Stacktrace: If I run with RUST_BACKTRACE=1 I don't get a stacktrace, only "Illegal Instruction":

$ RUST_BACKTRACE=1 rustc src/lib.rs --crate-name rust_ice --crate-type lib -g -C metadata=0fbc93cfda687298 -C extra-filename=-0fbc93cfda687298 --out-dir /home/ragge/projects/github/ragnard/rust-ice/target/debug --emit=dep-info,link -L dependency=/home/ragge/projects/github/ragnard/rust-ice/target/debug -L dependency=/home/ragge/projects/github/ragnard/rust-ice/target/debug/deps
src/lib.rs:5:1: 5:10 warning: struct is never used: `S`, #[warn(dead_code)] on by default
src/lib.rs:5 struct S;
             ^~~~~~~~~
src/lib.rs:15:16: 15:17 warning: unused variable: `u`, #[warn(unused_variables)] on by default
src/lib.rs:15     fn f(self, u: U) { }
                             ^
src/lib.rs:1:1: 1:1 error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate(core::marker::Sized)),depth=2),Unimplemented)]` fulfilling during trans
src/lib.rs:1 use std::collections::HashMap;
             ^
Illegal instruction

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