-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve messages for un-closed delimiter errors #53949
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
b56bd44
to
61d7db8
Compare
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.
I'm very excited about this. Looks like tests don't quite pass yet, though.
I was wondering whether weirdness could happen because of macros, but I guess not: macro expansions can't introduce unpaired braces, after all. The error would occur when parsing the original file.
r=me once tests pass
| - this might be the culprit... | ||
... | ||
LL | } | ||
| - ...as it matches this but it has different indentation |
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.
omg yes!
.next() // these are in reverse order as they get inserted on close, but | ||
{ // we want the last open/first close | ||
if d == delim { | ||
err.span_label(*open_sp, "this might be the culprit..."); |
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.
I love this language, but perhaps something a touch more formal...
- "this delimiter might not be properly closed" ?
- "this delimiter might be at fault" ?
* When encountering EOF, point at the last opening brace that does not have the same indentation level as its close delimiter. * When encountering the wrong type of close delimiter, point at the likely correct open delimiter to give a better idea of what went wrong.
It was a
The only thing that worries me is that code with wonky indentation will receive subpar suggestions, but I have banged my head trying to come up with better heuristics and they were all much more complicated than this for marginal benefit. |
61d7db8
to
b2d2d83
Compare
I feel like that's ok. |
@bors r=nikomatsakis |
📌 Commit 3192d3d has been approved by |
…akis Improve messages for un-closed delimiter errors
Improve messages for un-closed delimiter errors
☀️ Test successful - status-appveyor, status-travis |
Hmm, sadly, this PR seems to be a massive compilation time hit — I think we have to back it out :( |
Wow, that's terrible. You can revert with my auto approval, as I'm laptop less until Monday. I'll take a look tonight to see if I can find any way to avoid this penalty. Is there a way to run those performance tests locally? |
Don't compute padding of braces unless they are unmatched Follow up to #53949. Attempt to fix # #54083. r? @nikomatsakis
Don't compute padding of braces unless they are unmatched Follow up to #53949. Attempt to fix # #54083. r? @nikomatsakis
No description provided.