-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
idea: consult git diff for better diagnostics / syntax errors #48911
Comments
Not worth the extra complexity, I would argue: teaching |
Maybe add this feature as "optional" analytic process? Unless, of course, there aren't other scenarios where this may be useful. |
For the specific case of curly brace matching errors, I think the indentation of the braces would be a far better heuristic for user intent than git history. The reason the opening brace on line 4 is "obviously" the unmatched one is because no other curly brace in the example has the same indentation. I'm not sure how to generalize that rule so it works on non-trivial examples, but it seems solvable. (personally, it's not obvious to me that there are any situations where rustc looking at git history could lead to a significantly better error message, much less enough situations to justify the dependency) |
One related thing that gcc and clang do is notice conflict markers from
|
(This is #32059.) |
Closing as #53949 addresses the mismatched braces issue for reasonably formatted code (and there's already another ticket for version control conflict markers). We're unlikely to ever ship with an implementation of |
Just an idea:
Let's say our code looks like this:
The error message is not very helpful here, pointing to lines 1 and 8:
However, since cargo inits new repos as git repo, maybe we can utilize the repo diff and see which brace was added the last:
and give a better diagnostic:
The text was updated successfully, but these errors were encountered: