- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
trait Bar {
    type Ok;
    type Sibling: Bar2<Ok=Self::Ok>;
}
trait Bar2 {
    type Ok;
}
struct Foo;
struct Foo2;
impl Bar for Foo {
    type Ok = ();
    type Sibling = Foo2;
}
impl Bar2 for Foo2 {
    type Ok = u32; // <- `u32` instead of `()`
}Errors:
error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
  --> src/lib.rs:14:6
   |
14 | impl Bar for Foo {
   |      ^^^ expected u32, found ()
   |
   = note: expected type `u32`
              found type `()`
I don't like the error message, I would like to see something similar to this
error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
...
LN | type Ok = ();
   | ^^^^^^^^^^^^ associated type Ok defined here
LN | type Sibling: Bar2<Ok=Self::Ok>;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type constrained here
   | ...
LN | type Ok = u32; // <- `u32` instead of `()`
   | ^^^^^^^^^^^^^ type violated here
LukasKalbertodt
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.