8000 fix: Make span_to_lines return at least one line by Muscraft · Pull Request #225 · rust-lang/annotate-snippets-rs · GitHub
[go: up one dir, main page]

Skip to content

fix: Make span_to_lines return at least one line #225

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

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

Muscraft
Copy link
Member

While running rustc's lintdoc tests, I encountered a corner case with SourceMap::span_to_lines, where it would return no LineInfo when it was passed the range 0..0, which ultimately caused a panic down the line. To address this, I made it so span_to_lines would only stop including lines when the range end was less than a LineInfo's start_byte (end < line_info.start_byte). This seems to be the correct fix, as we use its negation (end >= line_info.start_byte) when determining what line a byte falls on.

@epage epage merged commit 557126c into rust-lang:master Jun 25, 2025
15 checks passed
@Muscraft Muscraft deleted the fix-span-to-lines branch June 25, 2025 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0