Description
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
:
rust/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Lines 453 to 457 in ce1a7e4
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.
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
-
This is currently computed ad-hoc in
maybe_report_ambiguity
and should be moved into a separate function. ↩