Skip to content

ICE: coherence failed to report ambiguity with recursive projection in type-contents and  #22918

Closed
@arielb1

Description

@arielb1

I was trying to do things with recursive associated types:

pub struct S<T: Tr> {
    u: <T as Tr>::I,
}

pub trait Tr {
   type I: Tr;
}

impl<T: Tr> Tr for T {
    type I = S<T>;
}

fn main() {}

and got a strange trans coherence error:

<anon>:11:1: 13:2 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `Tr` for the type `<T as Tr>::I`
<anon>:11 impl<T: Tr> Tr for T {
<anon>:12     type I = S<T>;
<anon>:13 }
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<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:129

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)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