Skip to content

Confusing error with trait with multiple associated types #20521

Closed
@apasel422

Description

@apasel422

I'm not sure if the following should work, but the error message is not helpful:

#![feature(associated_types)]

pub trait Foo {
    type L;
    type R;
}

pub struct Bar<C, D>(C, D);

impl<C: Foo, D: Foo<L = C::L, R = C::R>> Foo for Bar<C, D> {
    type L = C::L;
    type R = C::R;
}

On rustc 0.13.0-nightly (c6c786671 2015-01-04 00:50:59 +0000) this yields:

lib.rs:10:1: 13:2 error: type annotations required: cannot resolve `<D as Foo>::L == <C as Foo>::L`
lib.rs:10 impl<C: Foo, D: Foo<L = C::L, R = C::R>> Foo for Bar<C, D> {
lib.rs:11     type L = C::L;
lib.rs:12     type R = C::R;
lib.rs:13 }

Removing the second associated type from Foo (R) compiles successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions