Skip to content

impl Trait for Trait should yield a coherence violation #24015

Closed
@nikomatsakis

Description

@nikomatsakis

Since the compiler now supplies an implementation of the trait for itself, something like http://is.gd/Id71IX:

trait Foo { fn dummy(&self) { } }
impl Foo for Foo { }
fn main() { }```

ought to be reported as overlap. Instead we get an error later when we find an ambiguity:

:2:1: 2:21 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait Foo for the type Foo
:2 impl Foo for Foo { }
^~~~~~~~~~~~~~~~~~~~
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', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

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