Skip to content

ICE with a simple associated type, causing "index out of bounds" on a vector #25679

Closed
@kvark

Description

@kvark

Broken on both stable and the nightly. Affects a real use case with present() in gfx-rs.

trait Device {
    type Resources;
}
struct Foo<R>(R);

impl<D: Device> Foo<D::Resources> {
    fn present(&self, _dev: &D) {}
}

fn main() {
    struct Res;
    struct Dev;
    impl Device for Dev {
        type Resources = Res;
    }
    struct Win;
    let foo = Foo(Res);
    let dev = Dev;
    foo.present(&dev);
}

Gives me:

<anon>:19:9: 19:22 error: type `Foo<main::Res>` does not implement any method in scope named `present`
<anon>:19     foo.present(&dev);
                  ^~~~~~~~~~~~~
error: internal compiler error: unexpected panic
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 'index out of bounds: the len is 5 but the index is 5', /home/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcollections/vec.rs:1322


playpen: application terminated with error code 101

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