Skip to content

specialization involving associated types of unfullfilled traits can cause a panic #45814

Closed
@42triangles

Description

@42triangles

At least to my understanding, this bug is caused by using the specialization feature with a trait while using an associated type of a possibly unfullfilled trait in one of the impl's.

I tried this code:

#![feature(specialization)]

pub trait Trait<T> { }

default impl<T, U> Trait<T> for U { }

impl<T> Trait<<T as Iterator>::Item> for T { }

fn main() { }

I expected to see this happen: An error because T is not necessarily an Iterator

Instead, this happened: rustc just panics

Meta

rustc --version --verbose:

rustc 1.23.0-nightly (d762b1d6c 2017-11-04)
binary: rustc
commit-hash: d762b1d6c67db12e117186d94d70e46cddb22965
commit-date: 2017-11-04
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0

Backtrace:

Quite large, I put it in a file for that reason (56 steps):
backtrace.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-specializationArea: Trait impl specializationC-bugCategory: This is a bug.F-specialization`#![feature(specialization)]`I-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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions