Skip to content

feature(generic_associated_types): compiler panicked #51148

Closed
@attdona

Description

@attdona

I'm trying to use generic_associated_types feature but the compiler panics:

#![feature(generic_associated_types)]

use std::ops::Index;
use std::fmt::Display;

fn main() {

    let w = Wrap(vec!['a', 'b']);
    let mut v: Vec<&Index<usize, Output = Display>> = Vec::new();
    v.push(&w as &Index<usize, Output = Display>);

}

struct Wrap<T>(Vec<T>);

impl<T> Index<usize> for Wrap<T>
where T: Display {
    type Output<'a> = Display + 'a;
    fn index<'a>(&'a self, index: usize) -> &'a Self::Output {
        &self.0[index]
    }
}

Output:

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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: rustc 1.27.0-nightly (9fae15374 2018-05-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type systemC-bugCategory: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions