smarter blame assignment for lifetime inference errors #45979
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lifetimes
Area: Lifetimes / regions
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
WG-diagnostics
Working group: Diagnostics
Consider this example (try it on play):
I get the error:
This is pretty good, but I think it would be better if we moved the highlight off of
cx
, which has the correct type, and over perhaps tobase
, which does not, or perhaps to the function callty
:I think a better analysis of the region inference graph could tell us what to highlight. Right now I believe we blame the edge that introduced the unsatisfiable constraint. In this case, the edge that introduced
'cx
corresponds to the parametercx
. But we really want to blame the edge that brought the unsatisfiable constraint into "tension", which I think is generally the point where contravariance is introduced (iow, parameters to function calls). But I suspect we can get decent results with just a simple weighting of the causes for introducing each edge.The text was updated successfully, but these errors were encountered: