Skip to content

E0221 needs more helpful information #35970

Closed
@sophiajt

Description

Currently, E0221 can give an error like:

error[E0221]: ambiguous associated type `A` in bounds of `Self`
  --> src/test/compile-fail/E0221.rs:21:16
   |
21 |         let _: Self::A;
   |                ^^^^^^^ ambiguous associated type `A`
   |
note: associated type `Self` could derive from `Foo`
  --> src/test/compile-fail/E0221.rs:21:16
   |
21 |         let _: Self::A;
   |                ^^^^^^^
note: associated type `Self` could derive from `Bar`
  --> src/test/compile-fail/E0221.rs:21:16
   |
21 |         let _: Self::A;
   |                ^^^^^^^

This isn't terribly helpful. Ideally, we'd like to show where these associated types that cause ambiguity are coming from:

error[E0221]: ambiguous associated type `A` in bounds of `Self`
  --> src/test/compile-fail/E0221.rs:21:16
   |
15 |    type A: T1;
   |    ---------- ambiguous `A` from `Foo`
...
19 |    type A: T2;
   |    ---------- ambiguous `A` from `Bar`
20 |    fn do_something() {
21 |         let _: Self::A;
   |                ^^^^^^^ ambiguous associated type `A`

cc @nikomatsakis

Activity

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

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions