-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Fix span handling for EOF tokens to enable proper diagnostics #145350
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
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
This comment has been minimized.
This comment has been minimized.
| LL - const x: () = |&'a| (); | ||
| LL + const x: () = |&| (); |
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 don't feel like that's a good idea to show incorrect suggestion like this
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 thought about whether there might be other good alternatives, but I keep reaching that this code suggestion is definitely unnecessary. I also confirmed that the updated stderr files show poor error indication quality. So, I'll closing this PR. Thanks for the review 👍
| LL - const x: () = |&'a | ||
| LL + const x: () = |& |
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.
It does not make sense at all for me, but I may missing something?
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
You might want to run |
Description
Fixes #134061
When parsing invalid code like
const x: () = |&'a, the compiler failed to generate suggestions due to incorrect span handling in the parser'sbumpfunction. The issue occurred when:<eof>) was encounteredChanges
Change the span assignment from:
to:
This change is also proposed in the original issue. This also ensures that dummy span receive the end position of the previous token rather than its entire span, allowing the diagnostic system to generate proper suggestions.
Results
Before the fix:
After the fix:
Debug Assertions
The fix also resolves debug assertion failures. The assertion in:
rust/compiler/rustc_errors/src/diagnostic.rs
Lines 1047 to 1050 in 1c9952f
This assertion previously could fail when spans were incorrectly handled. With our fix, Produces proper diagnostics without assertion failures.