Skip to content

Confusing suggestion when E0719 and E0191 occur at the same time. #100109

Description

@jendrikw

Given the following code: play

trait A {
    type X;
}

trait B: A {
    type X; // note: this is legal
}

impl<X> Clone for Box<dyn B<X=X, X=X>> {
    fn clone(&self) -> Self {
        todo!()
    }
}

The current output is:

error[E0719]: the value of the associated type `X` (from trait `B`) is already specified
 --> src/lib.rs:9:34
  |
9 | impl<X> Clone for Box<dyn B<X=X, X=X>> {
  |                             ---  ^^^ re-bound here
  |                             |
  |                             `X` bound here first

error[E0191] the value of the associated type `X` (from trait `A`) must be specified
 --> src/lib.rs:9:27
  |
2 |     type X;
  |     ------- `X` defined here
...
9 | impl<X> Clone for Box<dyn B<X=X, X=X>> {
  |                           ^^^^^^^^^^^ help: specify the associated type: `B<X=X, X=X, X = Type>`

B<X=X, X=X, X = Type> is wrong, specifying another X=Type isn't going to fix the problem.

Writing just dyn B has a suggestion consider introducing a new type parameter, adding `where` constraints using the fully-qualified path to the associated types, which is good, but the concrete syntax would be nice.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions