Skip to content

Improve error message for reserved ambiguation #54970

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

Open
npmccallum opened this issue Oct 10, 2018 · 2 comments
Open

Improve error message for reserved ambiguation #54970

npmccallum opened this issue Oct 10, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@npmccallum
Copy link
Contributor

Compiling this code:

trait Foo {
    type not_really_ambiguous_i_promise;
}

impl Foo for isize {
    type not_really_ambiguous_i_promise = usize;
}

fn main() {
    let x: isize::not_really_ambiguous_i_promise = 17;
    println!("{}", x);
}

Produces this error:

error[E0223]: ambiguous associated type
  --> src/main.rs:10:12
   |
10 |     let x: isize::not_really_ambiguous_i_promise = 17;
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
   |
   = note: specify the type using the syntax `<isize as Trait>::not_really_ambiguous_i_promise`

Presuming that this is because such code might become ambiguous in the future, we need a better error message.

@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Oct 10, 2018
bors added a commit that referenced this issue Oct 13, 2018
… r=oli-obk

structured suggestion for E0223 ambiguous associated type

(routine (and when are we going to be done finding these, anyway?) but something that stuck out to me while glancing at #54970)

r? @estebank
@JohnTitor JohnTitor added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 14, 2020
@oli-obk
Copy link
Contributor

oli-obk commented May 19, 2023

The diagnostic is effectively unchanged.

there should be a help stating something around the fact that other traits may have an assoc type of the same name, and thus adding an impl for such a type will become a breaking change.

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` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants
@npmccallum @oli-obk @estebank @JohnTitor and others