Skip to content

When encountering an incorrect trait bound referencing the current trait, suggest correct code #65985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
estebank opened this issue Oct 30, 2019 · 0 comments · Fixed by #66042
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Oct 30, 2019

The following snippet is not correct:

trait Bar {}

trait Foo where Foo::Assoc: Bar {
    type Assoc;
}

But these three are:

trait Foo where Self::Assoc: Bar {
    type Assoc;
}
trait Foo where <Self as Foo>::Assoc: Bar {
    type Assoc;
}
trait Foo {
    type Assoc: Bar;
}

For the first we currently emit:

error[E0223]: ambiguous associated type
 --> file.rs:3:17
  |
3 | trait Foo where Foo::Assoc: Bar {
  |                 ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Foo>::Assoc`

but it should suggest one of the two valid snippets above.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. labels Oct 30, 2019
@bors bors closed this as completed in 1d5cb17 Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
1 participant