Skip to content

ICE when not constraining associated type of a trait object #23042

Description

@elinorbgr

Shortest code:

trait Foo {
    type Bar;
    fn foo(&self) -> Self::Bar;
}

fn next(i: &Foo) {
    let _ = i.foo();
}

fn main() {}

produces this output on playpen (rustc 1.0.0-nightly (b4c965ee8 2015-03-02) (built 2015-03-03) according to playbot):

<anon>:7:1: 9:2 warning: function is never used: `next`, #[warn(dead_code)] on by default
<anon>:7 fn next(i: &Foo) {
<anon>:8     let _ = i.foo();
<anon>:9 }
error: internal compiler error: fictitious type <Foo as Foo>::Bar in sizing_type_of()
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:189

My local rustc seems to not be able to produce backtraces, sorry.

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

    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