Uh oh!
There was an error while loading. Please reload this page.
Improve diagnostics when parsing angle args - #80065
Conversation
rust-highfive
commented
Dec 15, 2020
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
fbe3df0Compare
This comment has been minimized.
This comment has been minimized.
12d91f4 to
f9ebeffCompareoli-obk
commented
Dec 16, 2020
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. |
b-naber
commented
Dec 16, 2020
@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 |
oli-obk
commented
Dec 16, 2020
I'm not sure how to detect rust/compiler/rustc_parse/src/parser/path.rs Line 589 in cfed918 |
oli-obk
commented
Dec 16, 2020
r? @oli-obk |
b-naber
commented
Dec 16, 2020
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 |
petrochenkov
commented
Dec 16, 2020
A much simpler alternative - petrochenkov@a759e56. |
b-naber
commented
Dec 19, 2020
@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 |
oli-obk
commented
Dec 19, 2020
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
f4f2c54Compareb-naber
commented
Dec 21, 2020
@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.
oli-obk
left a comment
There was a problem hiding this comment.
Oh, so it looks to me like we can do both your current PR and @petrochenkov 's change. Are you ok with this @petrochenkov ?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1461c9a to
fd28411Comparepetrochenkov
commented
Dec 28, 2020
@oli-obk |
petrochenkov
commented
Dec 28, 2020
Could you assign this to me for a final look once it's otherwise ready? |
oli-obk
commented
Dec 28, 2020
@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 |
oli-obk
commented
Jan 1, 2021
Hmm... while I see that it is a first to special case a generic "expected, found" error where a |
b-naber
commented
Jan 13, 2021
@estebank Thanks for the review. Addressed your comments. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
8bfc096 to
d228142Compareb-naber
commented
Jan 18, 2021
@petrochenkov Thanks for your review. Addressed your comments. |
petrochenkov
commented
Jan 18, 2021
r=me after rebase. |
b-naber
commented
Jan 19, 2021
@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? |
oli-obk
commented
Jan 20, 2021
in stderr files, you can just ignore the conflicts and re-run |
petrochenkov
commented
Jan 20, 2021
@b-naber |
d228142 to
3ba6cf1Compareb-naber
commented
Jan 22, 2021
@petrochenkov rebased. |
oli-obk
commented
Jan 22, 2021
@bors r=petrochenkov |
bors
commented
Jan 22, 2021
📌 Commit 3ba6cf1 has been approved by |
bors
commented
Jan 23, 2021
bors
commented
Jan 23, 2021
☀️ 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