Skip to content

Stack overflow with specialization enabled #39618

Closed
@ghost

Description

#![feature(specialization)]

trait Foo {
    fn foo(&self);
}

trait Bar {
    fn bar(&self);
}

impl<T> Bar for T where T: Foo {
    fn bar(&self) {}
}

impl<T> Foo for T where T: Bar {
    fn foo(&self) {}
}

impl Foo for u64 {}

fn main() {
}

Compiling this code results in:

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow

There is no backtrace.

If I disable specialization feature, rustc reports an error:

error[E0119]: conflicting implementations of trait `Foo` for type `u64`

Rustc details:

rustc 1.17.0-nightly (0648517fa 2017-02-03)
binary: rustc
commit-hash: 0648517faf1e2cf37c8b6770cbd0180a816ed9a0
commit-date: 2017-02-03
host: x86_64-unknown-linux-gnu
release: 1.17.0-nightly
LLVM version: 3.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-specializationArea: Trait impl specializationC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-specialization`#![feature(specialization)]`I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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