-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Bare CR allowed in code causing terrible spans #16480
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
Comments
Two options:
Said translation would have to be done when printing the source and when determining where line breaks are (which I assume the span line has to do), because AFAIK the spans point into the original immutable source. If the source is actually mutable in memory, then you could replace bare CR with LF there and call it a day, but I'm guessing that's not feasible (I've never looked into the file map). |
Actually, CR isn't the only character that breaks error spans. E.g. a stray LS (U+2028) also leads to some span wonkiness. A non-committal solution would be to let things be from the language specification standpoint, and just replace all of these wonky whitespace characters with spaces for the purposes of error reporting. |
Triage: no change. |
Still the same: fn main() {
let a = 0;
}
same, main.rs, but with cr endings:
|
Since #90462 we have replacement machinery for arbitrary codepoints that we could use for this. At the very least it would be easy to replace these with |
…lnicola Remove unused Subtree::visit_ids function Completely unused, nothing else even shows up when searching for `visit_ids`.
This was fixed by #127528. |
E.g. consider this code (save it to a file with CR line endings):
Error:
I'm pretty sure this did not used to happen.
I suggest disallowing bare CRs rather than fixing this span issue.
The text was updated successfully, but these errors were encountered: