-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve diagnostics when parsing angle args #80065
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
6e79a98
to
fbe3df0
Compare
This comment has been minimized.
This comment has been minimized.
12d91f4
to
f9ebeff
Compare
I love the change in diagnostics. I do have some reserves about the implementation though. I wonder if it's tackling it from the wrong side. I'm not sure if this would get us the same result, but it could be worth a try: At the error reporting site of rust/compiler/rustc_parse/src/parser/path.rs Line 589 in cfed918
> . While this would be wrong in various cases, a sufficiently explanatory diagnostic message on the suggestion could probably make that clear?
We could also try to dedupliate/condense the current PR if you prefer. I'll let @rust-lang/wg-diagnostics weigh in, before you have to put in work that others may end up disagreeing with. |
@oli-obk Thanks for looking at the PR. I understand your concerns, I'm also not really satisfied with the implementation that handles the case involving the error you mentioned. I think handling this the way you proposed is probably the better solution. I can remove that part and implement what you suggested. The case in which a syntactically correct equality constraint is parsed (e.g. as in |
I'm not sure how to detect rust/compiler/rustc_parse/src/parser/path.rs Line 589 in cfed918
|
r? @oli-obk |
No, that's not what I meant. You're right, we cannot catch a 'missing closing angle args' error inside rust/compiler/rustc_parse/src/parser/path.rs Line 589 in cfed918
and remove this part But we keep the part in which we handle correctly parsed equality constraints as the last element in Or do you have a problem with this part in |
A much simpler alternative - petrochenkov@a759e56. |
@petrochenkov I was hoping someone from the diagnostics team would weigh in on this. To me these 'expected token' errors are probably good enough in case there is actually a missing closing angle bracket, but I think they might be confusing if we actually have incorrect generic argument types in constraints. E.g. in |
I do like the simplicity of @petrochenkov 's solution, but wearing my wg-diagnostics hat I would also like to see an additional message at the
site. Now since all of these errors are about a "found |
037a4da
to
f4f2c54
Compare
@oli-obk Adding a suggestion to a 'found =' error in @petrochenkov 's solution would have not worked cleanly. Instead I tried to implement what you suggested initially, i.e. giving a suggestion for a 'possibly missing closing angle bracket' whenever there's an 'only types' error when parsing equality constraints. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so it looks to me like we can do both your current PR and @petrochenkov 's change. Are you ok with this @petrochenkov ?
src/test/ui/generic-associated-types/parse/trait-path-missing-closing-angle-bracket.rs
Outdated
Show resolved
Hide resolved
1461c9a
to
fd28411
Compare
@oli-obk |
Could you assign this to me for a final look once it's otherwise ready? |
@b-naber please pull in the commit from petrochenkov mentioned in #80065 (comment) and adjust all tests. I will then reassign to petrochenkov for a last review |
I don't see how these two commits are mergeable. In @petrochenkov 's solution we return |
Hmm... while I see that it is a first to special case a generic "expected, found" error where a |
@estebank Thanks for the review. Addressed your comments. |
8bfc096
to
d228142
Compare
@petrochenkov Thanks for your review. Addressed your comments. |
r=me after rebase. |
@petrochenkov I get pretty bad conflicts in const-generics tests:
Should this error at all? It seems that on master this only errors because the feature is experimental. This seems very wrong, we shouldn't output a parsing error here, should we? |
in stderr files, you can just ignore the conflicts and re-run |
@b-naber |
d228142
to
3ba6cf1
Compare
@petrochenkov rebased. |
@bors r=petrochenkov |
📌 Commit 3ba6cf1 has been approved by |
☀️ Test successful - checks-actions |
#79266 introduced parsing of generic arguments in associated type constraints, this however resulted in possibly very confusing error messages in cases in which closing angle brackets were missing such as in
Vec<(u32, _, _) = vec![]
, which outputs an incorrectly parsed equality constraint error, as noted by @cynecx.This PR tries to provide better error messages in such cases.
r? @petrochenkov