Skip to content

improve the way we deal with ambiguity errors #103911

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
lcnr opened this issue Nov 3, 2022 · 2 comments
Open

improve the way we deal with ambiguity errors #103911

lcnr opened this issue Nov 3, 2022 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 3, 2022

right now we report each ambiguity error separately, sprinkling in a bunch of self.is_tainted_by_errors() and friends in there to deduplicate errors.

This can often cause us to emit less useful errors because the more relevant error happens later.
It also restricts us in the suggestions we can emit.

This happens in fn report_fulfillment_errors:

for (error, suppressed) in iter::zip(errors, is_suppressed) {
if !suppressed {
self.report_fulfillment_error(error, body_id, fallback_has_occurred);
}
}

I think ideally what we should do is:

  • look at all CodeAmbiguity errors and merge them by their annotated inference variable1.
  • if there are multiple obligations ambiguous due to the same inference variable, talk about them as part of the same error message, ignoring "less important" obligations.
  • further work: with selection failure: recompute applicable impls #103252 we will have a list of all maybe applicable impls, so if we have multiple trait obligations we can just try each combination of candidates to e.g. be able to say "you may have wanted to specify the type String here" in this example.

cc @estebank @jackh726

Open to review/help out if somebody wants to experiment with this. I won't be able to spend too much time on this though, so it's probably pretty difficult without prior experience with this code.

Footnotes

  1. This is currently computed ad-hoc in maybe_report_ambiguity and should be moved into a separate function.

@lcnr lcnr added C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. A-diagnostics Area: Messages for errors, warnings, and lints E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 3, 2022
@BGR360
Copy link
Contributor

BGR360 commented Nov 6, 2022

Is this related to / will this address #90665 (comment)?

@lcnr
Copy link
Contributor Author

lcnr commented Nov 7, 2022

It's definitely related 🤔 don't expect it to address that issue by itself. Should make it easier to do so in the future however

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 C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. 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

2 participants